Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
961 views
Welcome To Ask or Share your Answers For Others

1 Answer

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);

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...