Display images (jpg/png) on a 3.2" display from SD card

Hi. I wrote a topic few hours later. So here is my other question. Can I displlay jpg or png images from SD card on a 3.2" display using arduino? I have bought this display module and I have arduino mega. Is there any way to do that? PS: If I can use UTFT library to do this I will be very happy :slight_smile: because I have all pins connected to mega this way as displayed on this site.

Can I displlay jpg or png images from SD card on a 3.2" display using arduino?

Using that library, no. Jpeg and PNG images are compressed. You would first need to decompress them. The Arduino does not have enough memory to do that.

You could display a bitmap file. It would be possible, if you have enough memory, to read the whole bitmap file into memory, and display it using drawBitmap(), since you are using a mega.

You could read the bitmap file one byte at a time, and determine where that byte corresponded to on the screen, and what color that pixel should be, and use drawPixel() to color that pixel.

But..... If you mean to do .c file from that image I already tried to do that but I need to have 320x240 image and can't burn it into mega because of not enough memory.....

If you mean to do .c file from that image I already tried to do that

I can just about imagine doing JPEG decoding on a Mega, for a very restricted set of JPEG files.
It would be exceedingly slow, and an exercise in advanced hair-loss.

It may be possible to do some other form of compression on the image, but it really depends on the image content.

If you've already got an SD card, store the image in a file as a BMP.

Change the .c file to a .txt file and store it on the SD card.

Open the file, parse it a line at a time, and send it to the display one byte at a time, as mentioned earlier.

What Paul posted, use a .BMP file which can be read a pixel at a time... you -can- change a pixel at a time on the display?

Format Factory is free and will do the conversion.

There is the library UTFT_tinyFAT, it's an addon for the UTFT and tinyFAT libraries, it adds the function loadBitmap, which will do all the work for you... but, .bmp images only!

http://www.henningkarlsen.com/electronics/library.php?id=53

guix:
but, .bmp images only!

Not quite correct there :slight_smile:

loadBitmap() will only load raw, pre-processed files, but a conversion tool for Windows is included with UTFT, and there is also an online version on my website.

/Henning

AWOL:

If you mean to do .c file from that image I already tried to do that

I can just about imagine doing JPEG decoding on a Mega, for a very restricted set of JPEG files.
It would be exceedingly slow, and an exercise in advanced hair-loss.

It may be possible to do some other form of compression on the image, but it really depends on the image content.

If you've already got an SD card, store the image in a file as a BMP.

It's possible on the Mega for almost all JPEGs (only progressive jpegs are not supported), costs only 2.5Kb of SRAM while decoding and it's surprisingly fast. See my demo video at the bottom of this article. It won't work on the standard (2Kb SRAM) arduino - the huffman tables are just too large.

doc_norway:
Not quite correct there :slight_smile:

loadBitmap() will only load raw, pre-processed files, but a conversion tool for Windows is included with UTFT, and there is also an online version on my website.

/Henning

Sorry! I think you could easily add .bmp support, skip the first 54 bytes of the .bmp file, the rest is pixel data (you probably know that already!)..or is it more complex than that?

Very cool :slight_smile:

You might want to read the header to be more sure of the file (always check for errors! alternative is crash, lock or show garbage on error. our world is not perfect!) and handle different size pictures.

guix:
..or is it more complex than that?

I am afraid it is quite a bit more complex... Take a look at this: BMP file format - Wikipedia

/Henning