【发布时间】:2014-10-08 18:16:06
【问题描述】:
我收到多个错误,说明“'RGBApixel' 没有名为 'red' 的成员”、“'RGBApixel' 没有名为 'green' 的成员,以及“'RGBApixel' 没有名为 'blue' 的成员”。不知道为什么,因为我使用的是 EasyBMP 库。
在下面的函数中,我在 BMP 图像中定位一个像素,然后将该像素的 rgb 值与 color1 和 color2 rgb 值进行比较。像素将变为最接近它的颜色:
BMP Preprocessor (BMP pix, RGBApixel color1, RGBApixel color2, int xlow, int xhigh, int ylow, int yhigh){
for (int i = xlow; i < xhigh; i++){
for (int j = ylow; j < yhigh; j++){
RGBApixel pixel = pix.GetPixel(i,j);
double distance1 = abs(pixel.red - color1.red) + abs(pixel.green - color1.green) + abs(pixel.blue - color1.blue);
double distance2 = abs(pixel.red - color2.red) + abs(pixel.green - color2.green) + abs(pixel.blue - color2.blue);
if (distance1 < distance2) { // pixel color closest to color1
pixel.red = color1.red;
pixel.green = color1.green;
pixel.blue = color1.blue;
}
else { // pixel color closest to color2
pixel.red = color2.red;
pixel.green = color2.green;
pixel.blue = color2.blue;
}
}
}
return pix;
}
【问题讨论】:
-
你如何包含库的标题?
-
你能告诉我们RGBApixel的定义吗?
-
#include "EasyBMP.h"
-
Easy BMP用户手册scribd.com/doc/4084197/EasyBMP-UserManual