bitbank2 / JPEGDEC

An optimized JPEG decoder for Arduino
Apache License 2.0
365 stars 47 forks source link

Extra black areas appear when using esp32_jpeg.ino #62

Closed qiaobaaa closed 7 months ago

qiaobaaa commented 7 months ago

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() /

bitbank2 commented 7 months ago

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.

qiaobaaa commented 7 months ago

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