bitbank2 / PNGdec

Arduino PNG image decoder library
Apache License 2.0
162 stars 25 forks source link

openRAM from ps_malloc on ESP32 #14

Closed tomtobback closed 1 year ago

tomtobback commented 1 year ago

Hi, great library, i'm using it in my ESP32 project to decode PNG files from FATFS. In the same application i want to decode a PNG file coming in as UDP packets, available in RAM. I was hoping to use the ESP32's PSRAM, with uint8_t * png_file = (uint8_t *)ps_malloc(png_size); but openRAM() gives me error code 6 = PNG_INVALID_FILE. Is there a way to make this work? My current workaround is increasing the task stack size of the AsyncUDP library, to be able to handle files over 4KB with a common uint8_t png_file[png_size]; , but that is not ideal. Please advise.

bitbank2 commented 1 year ago

The openRAM() function just assumes that the pointer has valid PNG data and doesn't really care what type of memory it's pointing to. I would first assume that something is happening to your data reception. Try printing out the first few bytes of the received file as HEX to make sure that it's being received properly.