I want to manipulate JPEG images with C++ using the decoder Mini Jpeg Decoder.
The problem is: I want to read pixel per pixel, but the decoder only returns an imageData-array, similar as libjpeg does.
I can’t make a method like this:
char getPixel(char x, char y, unsigned char* imageData)
{
//...???
}
The return (the char variable) should contain the luminance of the pixel.
(I work with grayscale images…)
How can I solve this problem?
As far as I can tell, the
Decoderclass delivers a byte array of color values with theGetImage()method. So you could write a function that looks like this:I’m uncertain of the pixel layout, so maybe the array access is not right. Also this only works for grey-scale images, or else you would get the luminance of the Red color value at the position only. HTH