bitbank2 / JPEGDEC

An optimized JPEG decoder suitable for microcontrollers and PCs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extra black areas appear when using esp32_jpeg.ino

qiaobaaa opened this issue · comments

Hi,I use the st7789 screen (240320) to display a 2020 pixel jpg picture, but the serial port prints it out twice. The results of pDraw->iWidth and pDraw->iHeight twice are size=32 * 16 and size=32 * 4. Although the picture is displayed completely, there is an extra black area of 12 * 20. The actual pixel area of the picture is only 20 * 20. I don't know how to solve this problem. Can I only display the 20 * 20 pixel area?

int drawMCUs(JPEGDRAW pDraw)
{
int iCount;
iCount = pDraw->iWidth * pDraw->iHeight; // number of pixels to draw in this call
Serial.printf("Draw pos = %d,%d. size = %d x %d\n", pDraw->x, pDraw->y, pDraw->iWidth, pDraw->iHeight);
spilcdSetPosition(&lcd, pDraw->x, pDraw->y, pDraw->iWidth, pDraw->iHeight, DRAW_TO_LCD);
spilcdWriteDataBlock(&lcd, (uint8_t )pDraw->pPixels, iCount2, DRAW_TO_LCD | DRAW_WITH_DMA);
return 1; // returning true (1) tells JPEGDEC to continue decoding. Returning false (0) would quit decoding immediately.
} /
drawMCUs() */

There is a member of the JPEGDRAW structure named iWidthUsed which will tell you the number of pixels to display in the current block. This is necessary because the pitch (bytes per line) will be reflected in the iWidth member.

There is a member of the JPEGDRAW structure named iWidthUsed which will tell you the number of pixels to display in the current block. This is necessary because the pitch (bytes per line) will be reflected in the iWidth member.

Thank you very much. It feels amazing that the problem has been solved. I found that this problem will not occur when using photoshop to generate photos of 20 * 20 pixels (the image saving quality is high or above). Before, I used the drawing tool that comes with win10 to process the images. , from top to bottom, they are processed by PS: worst quality pictures, medium quality pictures, high quality pictures, best quality pictures, pictures processed by drawing tools. It is obvious that black areas will appear in some pictures.
微信图片_20231129215148