Bodmer / TJpg_Decoder

Jpeg decoder library based on Tiny JPEG Decompressor
Other
227 stars 43 forks source link

Problem while rendering JPEG Image. #22

Closed viveky1794 closed 3 years ago

viveky1794 commented 3 years ago

I am doing a project where I need to store my jpeg file into SPIFFS for later use. I am using Arduino IDE. So I am putting 2 JPEG images into "data" folder. Then Updating after going "Tool>ESP32 sketch upload" section.

Arduino IDE ESP32 Dev it Rpi TFT, 480x320, ili9486, SPI protocol at 40Mb

@Problem : One Image name " AA.jpg " Is rendering. But Second image namely "ABC.jpg" is not rendering. Can anyone suggest the possible reason and solution.

@Code :

include

include

include

include

include

include

include

include "Arduino.h"

include

// Include the jpeg decoder library

include

using namespace std;

TFT_eSPI tft = TFT_eSPI(); // Invoke custom library

define SPL Serial.println

define SP Serial.print

bool tft_output(int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t* bitmap) { // Stop further decoding as image is running off bottom of screen if ( y >= tft.height() ) return 0;

// This function will clip the image block rendering automatically at the TFT boundaries tft.pushImage(x, y, w, h, bitmap);

// Return 1 to decode next block return 1; }

void setup() { Serial.begin(9600); // DEBUG WINDOW // Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1); // Keypad interface // Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); // Weight Mechine SPI.beginTransaction(SPISettings(40000000, MSBFIRST, SPI_MODE0));

tft.init(); tft.fillScreen(TFT_BLACK); tft.setRotation(1); uint16_t calData[5] = { 329, 3444, 448, 3193, 2 }; tft.setTouch(calData); tft.fillScreen(TFT_BLACK);

// Initialise SPIFFS if (!SPIFFS.begin()) { Serial.println("SPIFFS initialisation failed!"); while (1) yield(); // Stay here twiddling thumbs waiting } //SPIFFS.flush(); Serial.println("\r\nInitialisation done."); tft.setSwapBytes(true); // We need to swap the colour bytes (endianess)

// The jpeg image can be scaled by a factor of 1, 2, 4, or 8 TJpgDec.setJpgScale(1);

// The decoder must be given the exact name of the rendering function above TJpgDec.setCallback(tft_output);

// Draw the image, top left at 0,0 TJpgDec.drawFsJpg(0, 0, "/ABC.jpg"); // Not Wroking delay(2000); }

void loop() { TJpgDec.drawFsJpg(0, 0, "/AA.jpg"); // Working }

@Images : 1 : AA

AA

2 : ABC ABC

Koxx3 commented 3 years ago

did you find any solution ? I have the same trouble (panda sample displaying ... my image isn't. no progressive jpg, nothing special)

Bodmer commented 3 years ago

I tried the second image above and can confirm that it will not be decoded. I then opened it in MS Paint, saved it again and it worked fine. Here is that image:

TJPG_Issue_22p.zip

So there must be something incompatible in the format, maybe it contains a "thumb nail image?

Bodmer commented 3 years ago

I tried the JPEGDecoder library which uses a different decode engine and it reports "Jpeg file format not supported!", so this means it is encoded in an unsupported format.

The JPEGDecoder library did load the image version posted above.

I ran analysis on the original image and it is in progressive format which is not supported:

image