Color Bitmap image from PROGMEM

Hi All,

I'm working on a project that will display an color image matrix that I have stored in progmem. Is this possible? Here are the details that hopefully are help:

#include <Adafruit_ST7735.h>
#include "bitmaps.h"
#include <Adafruit_SPITFT.h>

I have a bitmaps.h file containing the image:

const unsigned char bitmapImage [] PROGMEM = 
{ 0x00, 0xFF, 0x3A, etc };

I am then confused on how to display it. I have done a black and white image no problem. But can't figure out the colored image. Here's how I did the black and white:

tft.fillRect(0,0,128,128,ST77XX_WHITE);
  tft.drawBitmap(0,0,bitmapImage,128,128,ST77XX_BLACK);

The board does not have an SD card slot.

This is my first arduino project and still getting a feel for the lay of the land. Any and all help is appreciated! i've read this pdf and it appears it's not possible? I'm wondering if I have to just draw each pixel individually with its respective color? But that seems awfully difficult.. surely there's a way around this?

Go on. Post your image. Either paste the array in a CODE window or attach the "bitmaps.h" file.

You have already used one of the drawBitmap() methods. Just look at the methods available with Adafruit_GFX.h

    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color),
    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h, uint16_t color, uint16_t bg),
    drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h, uint16_t color),
    drawGrayscaleBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
      int16_t w, int16_t h),
    drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap,
      int16_t w, int16_t h),
    drawGrayscaleBitmap(int16_t x, int16_t y,
      const uint8_t bitmap[], const uint8_t mask[],
      int16_t w, int16_t h),
    drawGrayscaleBitmap(int16_t x, int16_t y,
      uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
      int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,
      int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y,
      const uint16_t bitmap[], const uint8_t mask[],
      int16_t w, int16_t h),
    drawRGBBitmap(int16_t x, int16_t y,
      uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h),

Hint. 16-bit Colour is RGB.

There are several common PC formats e.g. .JPG, .PNG, .BMP, .GIF, ...
These contain information about image dimensions, colour depth, ...

The Adafruit_GFX methods expect RAW arrays. You need to know the dimensions etc. And specify in the method's arguments.

David.

Thank you David!

So, I attempted a different technique and it "sort of" works. At least I have the colored image properly on the display.. I'll keep messing with it. Here's my current code:

  int h = 128,w = 91, row, col, buffidx=0;
  for (row=0; row<h; row++) { 
    for (col=0; col<w; col++) { 
      tft.drawPixel(col, row, pgm_read_word(myImageInBitmaps.h+ buffidx));
      buffidx++;
    } 
  }

I would use:

    drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
      int16_t w, int16_t h),

e.g.

    tft.drawRGBBitmap(0, 0, myImageInBitmaps, 91, 128);

David.

Guys, and how to take a part of the BMP only? I.e. i have a 100x100 pixels big BMP but i need to display only 10x10 pixels part starting from some x,y coordinates.

Take pencil and paper. Draw your 100x100 pixels.

0,0 @ 0, 0
0,1 @ 0, 100
0,2 @ 0, 200
... ...

e.g.

    for (int row = 0; row< 10; row++) {
        tft.drawRGBBitmap(x, y + row, myImageInBitmaps + row * 100, 10, 1);
    }