我想检查屏幕上的像素是否为红色。我正在使用快板 5。这是我的代码
ALLEGRO_BITMAP *bitmap ;
int x , y;
x=*xIter-20;
y=*yIter;
ALLEGRO_COLOR red_color = al_map_rgb (255,0,0);
ALLEGRO_COLOR new_color = al_get_pixel (bitmap , x , y);
if(new_color==red_color)
return 1;
但是报语法错误
error C2678: binary '==' : no operator found which takes a left-hand operand of type 'ALLEGRO_COLOR' (or there is no acceptable conversion)
最佳答案
unsigned char r,g,b;
al_unmap_rgb(new_color, &r, &g, &b);
bool isColorRed = (r == 255 && g == 0 && b == 0);
关于c++ - 检查像素颜色 Allegro 5 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16958922/