I was trying to compress a 160 * 120 rgb565 image into a png file using ESP32-Pico-D4. I defined the PNG class and everything executed properly until I hit addRGB565Lines. Here is my code and error log:
PNG png;
void PNG_encode() {
int rc;
uint8_t tempLine[1280]; // 160 pixels per line, so it should be more than enough to hold one line of pixels
Serial.println("mallocing...");
pOutput = (uint8_t *)malloc(160 * 120);
// open the png image
Serial.println("opening png...");
rc = png.open(pOutput, 160*120);
Serial.println("opening png success");
if (rc != PNG_SUCCESS) {
Serial.println("Error opening the output file");
return;
}
// begin png encoder
Serial.println("initializing encoder...");
rc = png.encodeBegin(160, 120, PNG_PIXEL_TRUECOLOR, 24, NULL, 9);
Serial.println("encoder initialized");
// encoding line by line
if (rc == PNG_SUCCESS) {
Serial.println("add RGB565 lines...");
for (int y = 0; y < 120 && rc == PNG_SUCCESS; y++) {
rc = png.addRGB565Line(&rgb565Buffer[160 * y], (void *)tempLine);
}
} else {
Serial.println("Error beginning the encoder");
}
Serial.println("png compressed");
// get the output
if (rc == PNG_SUCCESS) {
Serial.println("getting png size...");
iDataSize = png.close();
} else {
Serial.println("Error encoding the png file");
}
Serial.println("png size fetched");
}
The error code says that CPU accessed an invalid address for instruction. The PC went to zero instead of locating at a valid instruction address (0x4xxxxxxx). Details about this error can be found here.
Hello bitbank! Hope you are doing good!
I was trying to compress a 160 * 120 rgb565 image into a png file using ESP32-Pico-D4. I defined the PNG class and everything executed properly until I hit addRGB565Lines. Here is my code and error log:
And here is my error log:
The error code says that CPU accessed an invalid address for instruction. The PC went to zero instead of locating at a valid instruction address (0x4xxxxxxx). Details about this error can be found here.
Any clue for this error is appreciated!