tags:

views:

95

answers:

2

Hi, this is my first question here; hope I'll be clear enough...

I've got this struct available

typedef struct COLORTRIPLE
{
  byte blue;
  byte green;
  byte red;
}

which is contained in another struct like that:

struct color_temp
{ 
  COLORTRIPLE color;
  int temp;
};

And (EDIT)

#define PIXEL(image, row, column)  \
    image.pixel [(row) * image.width + (column)]

is a macro.

So there will be PIXEL(bmpin,row,column).red, PIXEL(bmpin,row,column).green and PIXEL(bmpin,row,column).blue.

I need to scan a bitmap file pixel by pixel and check if the current pixel is equal to one color of the color_temp struct.

I tried something like:

if ((PIXEL(bmpin,row,column))==(map[n].color))
{...}

where

struct color_temp map[]

is a vector of color_temp.

But cygwin gcc says:

error:request for member 'color' in something not a struct or a union

Any suggestions?

Thanks

Mark

+2  A: 

Try this:

int is_pixels_equal (COLORTRIPLE a, COLORTRIPLE b) {
  return (a.red == b.red && a.green == b.green && a.blue == b.blue);
}
Williham Totland
Shouldn't that be "are_pixels_equal()"?
unwind
@unwind: Whatever. P:
Williham Totland
A: 

You can't directly compare structs in C, it doesn't define such an operator. Therefore you have to implement it yourself, as Williham Totland suggested. For more discussion, see for instance this question.

unwind
@unwind : ok, I don't get it before :) Now I'll try. Thanks!
Madrac