|
How to compare colors? (Allegro 5) |
Henrique Rocha
Member #13,042
July 2011
|
Hello everybody! I am trying to convert my project from A4 to A5 but I have a little problem. ALLEGRO 4.2.2 #define MAGENTA makecol (255,0,255) int x_empty(BITMAP * bmp,int x){ for(y=0; y<bmp->h; ++y){ ALLEGRO 5 #define MAGENTA al_map_rgb(255,0,255) int x_empty(ALLEGRO_BITMAP * bmp,int x){ for(y=0; y<al_get_bitmap_height(bmp); ++y){ I am having this error: I have this include: And I compile like this: I don't know where is the problem. Can someone help me?
|
Matthew Leverton
Supreme Loser
January 1999
|
You can memcmp the two: if (!memcmp(&c1, &c2, sizeof(ALLEGRO_COLOR))) // same However, if you want more of a fuzzy match since they are floats, you can just do: Obviously you can also compare alpha if you want. (The memcmp version does.) |
Henrique Rocha
Member #13,042
July 2011
|
Thanks
|
Johan Halmén
Member #1,550
September 2001
|
My guess is that in A5, ALLEGRO_COLOR is a struct, not a single 32 bit int, as the colours in A4 were. TFM said:
typedef struct ALLEGRO_COLOR ALLEGRO_COLOR;
An ALLEGRO_COLOR structure describes a color in a device independant way. Use al_map_rgb et al.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest. |
Matthew Leverton
Supreme Loser
January 1999
|
It's one of the few structs that is not opaque: struct ALLEGRO_COLOR { float r, g, b, a; } So you don't really need to use the unmap functions if you just want to compare floats. |
Mark Oates
Member #1,146
March 2001
|
That's a cool trick. -- |
|