HELP !! LOADING .RAW OR .C IMAGE FILE ON MY 3.5" 480X320 LCD ARDUINO MEGA

I am currently working with my Touchscreen LCD. What i want to know is how can I insert images on my LCD. I found an online converter of jpeg/png to .raw and .c file to UTFT from Rinky-Dink Electronics
My problem is how can I insert my converted files in my LCD. Do i need to use Sd card ? how can i code it to my arduino mega ? Thanks for your advice :slight_smile:

Well, a .c file becomes part of your sketch - it creates a big array in progmem. Of course, there needs to be enough progmem for the data. From there. you can feed it into your LCD. Probably your cld library directly suppoers thins.

A .raw file probably needs to be put on an SD card and read with an SD card reader. More complicated, but you can put gigabytes of image on an SD card.

[b]DON'T SHOUT!!![/b]

(or, as my daughter says to my grandson, "I can always be louder than you!")

Emsy23:
@PaulMurrayCbr thanks for your reply. i just realized that I need to use the attach sd card reader from my TFT since i will use a lot of images that will consume more memory in my arduino mega. My problem is when I inserted the sd card which is tested working in my phone , I cannot successful loadbitmaps from it . What library should I use to know if my sd card was read by module and well functioning ? thanks for your reply

I don't know, I have never done Arduino SD card programming.

However further research eventually turned up a web page called RinkyDink Electronics (http://www.rinkydinkelectronics.com). This site deals in LCD modules and they have written a handy converter to change your graphics (in png, jpeg and gif format) to a raw format that the LCD screen understands.

For our demo I will use the online converter tool (as some people will reluctant to run “exe” programs from the internet). On this web page (Rinky-Dink Electronics) click “Choose File” and choose the “Save Icon” file you downloaded from this site earlier. Click “Make File”, this will take you to another page, click “Click here to download your file“. It will download as “name.c” where name is the name of the image file you uploaded (“DiskIcon” if you used mine). Open this file in your text editor of your choice and you should see this code;

#include <Adafruit_GFX.h>    // Core graphics library
#include <XTronical_ST7735.h> // Hardware-specific library
#include <SPI.h>
 
// set up pins we are going to use to talk to the screen
#define TFT_DC     D4       // register select (stands for Data Control perhaps!)
#define TFT_RST   D3         // Display reset pin, you can also connect this to the Arduino reset
                            // in which case, set this #define pin to -1!
#define TFT_CS   D2       // Display enable (Chip select), if not enabled will not talk on SPI bus
 
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);  
 
const unsigned short DiskIcon[256] PROGMEM={
0x8D38, 0xF7DF, 0x53D7, 0x4397, 0x3B57, 0x3B57, 0x3B57, 0x3B57, 0x3B57, 0x3B57, 0x3B57, 0x3B57, 0x4397, 0x5C37, 0xA578, 0xC618,   // 0x0010 (16) pixels
0x74B8, 0xCEFE, 0xCEFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xBE7D, 0x6479, 0x9578,   // 0x0020 (32) pixels
0x4BD7, 0xCEFE, 0x7D7C, 0xFFFF, 0xFFFF, 0x6479, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xBE7D, 0xBE7D, 0x4397,   // 0x0030 (48) pixels
0x4397, 0xCEFE, 0x7D3C, 0xFFFF, 0xFFFF, 0x6479, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7D3C, 0xC6BD, 0x3356,   // 0x0040 (64) pixels
0x3B57, 0xCEFE, 0x7D3C, 0xFFFF, 0xFFFF, 0x6479, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7D3C, 0xAE3C, 0x3356,   // 0x0050 (80) pixels
0x3B57, 0xCEFE, 0x7D3C, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x74FB, 0xA5FC, 0x3316,   // 0x0060 (96) pixels
0x3B57, 0xC6BE, 0x7D3C, 0x6479, 0x6479, 0x6479, 0x6CB9, 0x6CB9, 0x6CB9, 0x6479, 0x6479, 0x6479, 0x6479, 0x74FA, 0x9DBB, 0x3316,   // 0x0070 (112) pixels
0x3B57, 0xC6BE, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x74FB, 0x74FA, 0x74FA, 0x74FA, 0x74FA, 0x9DBB, 0x3316,   // 0x0080 (128) pixels
0x3B57, 0xC6BD, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x74FB, 0x74FA, 0x74FA, 0x74FA, 0x74FA, 0x95BB, 0x3315,   // 0x0090 (144) pixels
0x3B57, 0xBE7D, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x7D3C, 0x74FA, 0x74FA, 0x74FA, 0x74FA, 0x74FA, 0x74FA, 0x8D7A, 0x3315,   // 0x00A0 (160) pixels
0x3B57, 0xBE7D, 0x7D3C, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x6CBA, 0x8D3A, 0x3315,   // 0x00B0 (176) pixels
0x3B57, 0xB67D, 0x7D3C, 0xFFFF, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0xFFFF, 0x6CB9, 0x8539, 0x3315,   // 0x00C0 (192) pixels
0x3B57, 0xB67D, 0x7D3C, 0xFFFF, 0xC6F7, 0xC6F7, 0xC6F7, 0xC6F7, 0xC6F7, 0xC6F7, 0xC6F7, 0xC6F7, 0xFFFF, 0x6CB9, 0x84F9, 0x3315,   // 0x00D0 (208) pixels
0x3B57, 0xB67D, 0x7D3C, 0xFFFF, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0x8E2C, 0xFFFF, 0x6479, 0x7CF8, 0x3314,   // 0x00E0 (224) pixels
0x4B97, 0xAE3C, 0xAE3C, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x7CF8, 0xDF1E, 0x3B55,   // 0x00F0 (240) pixels
0xDF1E, 0x6437, 0x4397, 0x3356, 0x3356, 0x3316, 0x3316, 0x3316, 0x3315, 0x3315, 0x3315, 0x3315, 0x3315, 0x3314, 0x3B15, 0x53D5,   // 0x0100 (256) pixels
};
 
void setup(void) {
  tft.init();   // initialize a ST7735S chip,
  tft.setRotation(0);
  tft.fillScreen(ST7735_BLACK);
    tft.drawRGBBitmap(56,56,DiskIcon,16,16);
}
 
void loop() {
   // nothing to do
}
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
		const uint16_t *bitmap, int16_t w, int16_t h, bool progmem) {
  int16_t i, j;

  for(j=0; j<h; j++) {
    for(i=0; i<w; i++ ) {
	if (progmem) {
	  drawPixel(x+i, y+j, pgm_read_word(bitmap + j * w + i));
	} else {
	  drawPixel(x+i, y+j, (uint16_t) *(bitmap + j * w + i));
	}
    }
  }
}