Bodmer / JPEGDecoder

A JPEG decoder library
Other
220 stars 64 forks source link

ui.drawJpeg bleeds with some images #20

Closed al-ang closed 6 years ago

al-ang commented 6 years ago

Are there rules to follow when resizing jpeg images? Best sizes, resolutions, etc...? I've resized several jpeg images and when using TFT-eSPI ui.drawJpeg I get "bleeding". The bleeding can take on several forms; I don't see a pattern. When the jpeg is viewed normally within Windows, the image looks normal. Bottom line, not sure what's causing the bleeding, so I'm not sure how to fix it.

This is an example of an original image:

m12

And this is a snapshot of the image on the screen when displayed with ui.drawJpeg("/m12.jpg", 30, 90):

mx1

Bodmer commented 6 years ago

There was a bug in some examples in the sketch render function that required the image width to be a multiple of 16. I fixed this in later sketches. Where did you find the ui.drawJpeg function?

al-ang commented 6 years ago

I found ui.drawJpeg in TFT-eSPI/examples/320x240/weather-station-v8. Sicne I found it I've converted all BMP images to JPG once I saw the file savings (it's a HUGE difference).

I'll update my libraries, and then test widths in multiple of 16 to see if that'll fix my issue.

al-ang commented 6 years ago

Resizing width to a multiple of 16 worked (tried two different sizes). Will update library to see if it affect other sizes.

al-ang commented 6 years ago

After updating both JPEGdecoder and TFT-eSPI libraries an image width not divisible by 16 still bleeds. But I think this might be due to some jpeg information being carried along as a local library. I started a project with the weather-station demo and it has a local copy of GfxUI -- perhaps it has older code?

I can happily use images with widths that are multiple of 16 and consider that a solution for the time being.

al-ang commented 6 years ago

I found where you had already addressed this issue and successfully ran the code from https://github.com/Bodmer/TFT_eSPI/blob/master/examples/480%20x%20320/TFT_flash_jpg/TFT_flash_jpg.ino#L157-L172

Jpeg images now display correctly even if their width is not a multiple of 16.

Bodmer commented 6 years ago

Ok, I fogot about the weather station sketch. I will update the render function. Glad to hear you found the solution.