FreeImage:获取像素颜色 [英] FreeImage: Get pixel color
问题描述
我在写一个小应用程序,读取图像中每个像素的颜色并将其写入文件。首先我在Python中做了,在大图片上,它太慢了。然后我发现FreeImage库,我可以使用,但我不明白如何使用GetPixelColor方法。
你能提供一个例子来说明如何获得像素[50:50]的颜色?
以下是有关GetPixelColor的信息: http://freeimage.sourceforge.net/fnet /html/13E6BB72.htm 。
非常感谢!
I'm writing a little application that reads color of each pixel in image and writes it to file. First I did it in Python, buit it's too slow on big images. Then I discovered FreeImage library, which I could use, but I can't understand how to use GetPixelColor method. Could you please provide an example on how to get color, for example, of pixel[50:50]? Here is information about GetPixelColor: http://freeimage.sourceforge.net/fnet/html/13E6BB72.htm. Thank you very much!
推荐答案
FreeImagePlus使用24或32位图像, ,50将如下所示:
With FreeImagePlus using a 24 or 32 bit image, getting the pixel at coords 50, 50 would look like this:
fipImage input;
RGBQUAD pixel;
input.load("myimage.png");
height = in.getHeight();
in.getPixelColor(50, height-1-50, &pixel);
请注意,在FreeImage中,原点位于左下角,因此y值可能需要从上面的图像高度减去y。
Be aware that in FreeImage the origin is bottom left, so y values will probably need to be inverted by subtracting y from the image height as above.
这篇关于FreeImage:获取像素颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!