Pages: [1]   Go Down
Author Topic: Display images (jpg/png) on a 3.2" display from SD card  (Read 2343 times)
0 Members and 1 Guest are viewing this topic.
Localhost 127.0.0.1, World Wide Web
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley because I have all pins connected to mega this way as displayed on this site.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 654
Posts: 50934
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Localhost 127.0.0.1, World Wide Web
Offline Offline
Newbie
*
Karma: 0
Posts: 34
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.....
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26637
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Edison Member
*
Karma: 33
Posts: 1481
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4837
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

France
Offline Offline
Edison Member
*
Karma: 38
Posts: 1012
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Oslo, Norway
Offline Offline
Full Member
***
Karma: 6
Posts: 126
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

but, .bmp images only!

Not quite correct there smiley

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
Logged

Essex, UK
Offline Offline
Full Member
***
Karma: 4
Posts: 150
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Home of the Nokia QVGA TFT LCD hacks: http://andybrown.me.uk

France
Offline Offline
Edison Member
*
Karma: 38
Posts: 1012
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not quite correct there smiley

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?

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.

Very cool smiley
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4837
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Oslo, Norway
Offline Offline
Full Member
***
Karma: 6
Posts: 126
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

..or is it more complex than that?

I am afraid it is quite a bit more complex... Take a look at this: http://en.wikipedia.org/wiki/BMP_file_format

/Henning
Logged

Pages: [1]   Go Up
Jump to: