Hi everyone.
the example from TFT_eSPI library of [Flash_PNG] works well and shown a panda, if I convert another picture of a dog into the Hex(0x00) and replaced the code of panda, just not show, why?
panda_png.h (678.9 KB)
dog.h (6.7 KB)
Used Arduino ESP32 + GC9A01.
Thanks
Adam
the panda and dog attached.
// This example renders a png file that is stored in a FLASH array
// using the PNGdec library (available via library manager).
// Include the PNG decoder library
#include <PNGdec.h>
#include "panda_png.h" // Image is stored here in an 8 bit array
//// #include "duck_png.h" // Image is stored here in an 8 bit array
//#include "m2_png.h" // Image is stored here in an 8 bit array
PNG png; // PNG decoder inatance
#define MAX_IMAGE_WDITH 240 // Adjust for your images
int16_t xpos = 0;
int16_t ypos = 0;
// Include the TFT library https://github.com/Bodmer/TFT_eSPI
#include "SPI.h"
#include <TFT_eSPI.h> // Hardware-specific library
TFT_eSPI tft = TFT_eSPI(); // Invoke custom library
//====================================================================================
// Setup
//====================================================================================
void setup()
{
Serial.begin(115200);
Serial.println("\n\n Using the PNGdec library");
// Initialise the TFT
tft.begin();
tft.fillScreen(TFT_BLACK);
Serial.println("\r\nInitialisation done.");
}
//====================================================================================
// Loop
//====================================================================================
void loop()
{
int16_t rc = png.openFLASH((uint8_t *)panda_png, sizeof(panda_png), pngDraw);
//// int16_t rc = png.openFLASH((uint8_t *)duck_png, sizeof(duck_png), pngDraw);
//// int16_t rc = png.openFLASH((uint8_t *)m2_png, sizeof(m2_png), pngDraw);
if (rc == PNG_SUCCESS) {
Serial.println("Successfully png file");
Serial.printf("image specs: (%d x %d), %d bpp, pixel type: %d\n", png.getWidth(), png.getHeight(), png.getBpp(), png.getPixelType());
tft.startWrite();
uint32_t dt = millis();
rc = png.decode(NULL, 0);
Serial.print(millis() - dt); Serial.println("ms");
tft.endWrite();
// png.close(); // not needed for memory->memory decode
}
delay(3000);
tft.fillScreen(random(0x10000));
}
//=========================================v==========================================
// pngDraw
//====================================================================================
// This next function will be called during decoding of the png file to
// render each image line to the TFT. If you use a different TFT library
// you will need to adapt this function to suit.
// Callback function to draw pixels to the display
void pngDraw(PNGDRAW *pDraw) {
uint16_t lineBuffer[MAX_IMAGE_WDITH];
png.getLineAsRGB565(pDraw, lineBuffer, PNG_RGB565_BIG_ENDIAN, 0xffffffff);
tft.pushImage(xpos, ypos + pDraw->y, pDraw->iWidth, 1, lineBuffer);
}


