Display bitmap from web to eInk display


I'm using the really cool lib GxEPD to show some informations on a ESP8622 with a waveshare 4.2" display (reference GxGDEW042T2 on the lib).

So I build up a http server that serve bitmap data from my own images. The thing is, how to show them on the waveshare display?

There is some example with BitmapExample1, BitmapExample2, using function display.drawExampleBitmap(BitmapExample1, 0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, GxEPD_BLACK); for instance... but I'm quite new on Arduino platforms, and I can't manage to do it.

Any ideas or tips that can make me go further?

As images are quite big, I'm reading data from a http stream, e.g.:

int len = http.getSize();
uint8_t buff[128] = { 0 };

WiFiClient * stream = http.getStreamPtr();

while (http.connected() && (len > 0 || len == -1)) {
  // get available data size
  size_t size = stream->available();

  if (size) {
    // read up to 128 byte
    int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));

    // write it to Serial
    USE_SERIAL.write(buff, c);

    if (len > 0) {
      len -= c;

The easiest solution is to have a buffer of the size of the picture.
Read the whole picture from the stream to the buffer.
Then use one of the Adafruit_GFX drawBitmap() methods to draw the buffer to the buffer of the display class.
Then call display.update().

You can also use the smaller buffer of your example.
Keep track of the x,y coordinates of the picture part in the buffer.
Draw each picture part using one of the Adafruit_GFX drawBitmap() methods.
Finally call display.update().

Explanation: the drawBitmap() and drawExampleBitmap() methods expect the bitmap data to be in program space, therefore you need to use a Adafruit_GFX method. It will use the method with matching signature to the buffer parameter, hopefully. I have never tried.


For the first tip, if image is too large, I don’t think it could be handled by the ESP RAM… :confused:

I think it’s a great idea to keep track about coordinate of buffers (like sprites actually), but I can’t see how I can get that informations from http buffers…

Thanks a lot tho!

I think you have no other chance. Either you know the dimensions of your pictures in advance, and how they are sent by pieces, or you need to transfer this information also.

There is code in this example (mostly in this file)that fetches around 1 Mbyte of images from the internet (e.g. Imgur) and saves them to the SPIFFS filing system (FLASH based) then renders them to screen as required. it only takes a few seconds to get an image and you can reserve 3Mbytes to SPIFFS. The other option is to save them to an SD card or convert and render in "real-time" to the display.

Although ePaper screens are slow to refresh they have a built in frame store that can be updated in smaller blocks.

If you have say a 200x200 pixel ePaper display then a frame buffer (1 bit per pixel) only uses 200x200/8 = 5000 bytes of RAM which can easily be accommodated in an ESP8266.