Skip to content

Instantly share code, notes, and snippets.

@amotl
Last active September 25, 2023 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amotl/f22768b7923d7ca89bdf65a600da1c24 to your computer and use it in GitHub Desktop.
Save amotl/f22768b7923d7ca89bdf65a600da1c24 to your computer and use it in GitHub Desktop.
Unfinished spike to load PNG via HTTP and display on e-Paper display with ESP32
/*
Unfinished spike to load PNG via HTTP and display on e-Paper display with ESP32.
Please fill in teh gaps. Currently, it will probably not even compile.
The primitives have been taken from:
- https://github.com/lagunax/ESP32-upng
- https://github.com/ZinggJM/GxEPD2/blob/master/examples/GxEPD2_GFX_Example/BitmapDisplay.cpp
*/
// Acquire PNG image using HTTP.
const unsigned png_buffer* = <fetch with http>;
const int_8 png_length = 3000;
// Read PNG image.
upng_t* upng;
upng = upng_new_from_bytes(png_buffer, png_length);
if (upng != NULL) {
// Decode PNG image.
upng_decode(upng);
if (upng_get_error(upng) == UPNG_EOK) {
// Get pointer to bitmap buffer.
const uint8_t *bitmap = upng_get_buffer(upng);
// Display bitmap on e-Paper.
//display.fillScreen(GxEPD_WHITE);
display.writeScreenBuffer(); // use default for white
display.drawImage(bitmap, 0, 0, 200, 200, false, false, true);
//display.writeImage(bitmap, 0, 0, 200, 200, false, false, true);
display.refresh(true);
}
upng_free(upng);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment