Hello,
I recently tried downloading a few random images and then getting their pixel values via either mouse over the image or just printing out all the pixel values by looping through them. Just a note, display the image works fine.
What happens is with most images I get a return of 0-255 for RGBA values but certain images return 0,0,0,255 and the warning ofLog(OF_LOG_ERROR,“ofPixels: image type not supported”); both images I’m testing with are .jpg and when I open inspector on them they are both RGB. Here are the images I’m using:
image.resize(1);
image.load("test.jpg");
image.setImageType(OF_IMAGE_COLOR_ALPHA); // NOTE: I've tried running this and also commented out
unsigned char *data = image.getPixels().getData();
int components = image.getPixels().getBitsPerPixel() / 8;
for (int y=0; y<image.getHeight(); y++) {
for (int x=0; x<image.getWidth(); x++) {
int index = components * (x + image.getWidth() * y);
int red = data[ index ];
int green = data[ index + 1 ];
int blue = data[ index + 2 ];
cout << "Pixels: " << red << " " << green << " " << blue << endl;
}
}
NOTE: here are the images I’m using where I see the problem LINK 1 WORKS and LINK 2 DOES NOT
To go further here are the printed out properties I find when running the ‘file’ command in terminal on MAC:
LINK 1 IMAGE
file moon1.jpg
moon1.jpg:
JPEG image data, JFIF standard 1.01,
resolution (DPI), density 72x72, segment length 16,
Exif Standard: [TIFF image data, big-endian, direntries=0],
comment: “NASA false color moon mosaic retouched by Kevin N. Haw, http://www.theHaws.org, to remove alia”, baseline, precision 8, 2600x2910, frames 3
LINK 2 IMAGE
file landscape.jpg
landscape.jpg:
JPEG image data, JFIF standard 1.01,
resolution (DPI), density 300x300, segment length 16,
comment: “File source: https://commons.wikimedia.org/wiki/File:RUS-2016-Aerial-SPB-Tauride_Palace_(crop)”, baseline, precision 8, 1920x1233, frames 3