Closed mrcodetastic closed 1 year ago
I think I figured it out. I just use the LSB.
int drawMCUs(JPEGDRAW *pDraw)
{
int w = pDraw->iWidth;
int h = pDraw->iHeight;
for(int i = 0; i < w * h; i++)
{
uint8_t value = pDraw->pPixels[i] & 0xFF;
Serial.print(value, DEC);
Serial.print(", ");
}
Serial.println("");
return 1; // returning true (1) tells JPEGDEC to continue decoding. Returning false (0) would quit decoding immediately.
} /* drawMCUs() */
You should cast the uint16_t to uint8_t . Each pixel is 8-bits. See JPEGPutMCU8BitGray() in jpeg.inl.
Hi Larry. Awesome library as always. I have a large colour JPEG image (Image size: 1600 x 1200, orientation: 0, bpp: 24) that I want to load as a greyscale at 1/8 resolution and then do some basic processing of it values when the drawMCUs function is called over the blocks.
My question is: How does pDraw->pPixels[i] work with an image decoded as 8bit greyscale (given it returns a uint16_t for each pixel)? What bits do I drop from the uint16_t for that pixel?
For each 8bit greyscale pixel (element in pPixels) I'm getting large values like (in binary below):
I would have through the MSB's be 0'd our or something.
The width returned from each call to 'drawMCUs' is 200 which is 1600/8. From looking at the library code, this is correct as it does a whole row when decoding as EIGHT_BIT_GRAYSCALE.
So the question is, which byte do I use?