Skip to content

Commit

Permalink
Merge pull request #39 from marcmerlin/drawrgb
Browse files Browse the repository at this point in the history
Added support for multicolor pixmaps in drawRGBBitmap.
  • Loading branch information
PaintYourDragon committed May 5, 2017
2 parents cb95e03 + aad430d commit 4b1a8a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Adafruit_GFX.cpp
Expand Up @@ -649,6 +649,27 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
} // End classic vs custom font
}

// Draw colored bitmap (each pixel is a uint16_t, with colors defined by
// Draw colored bitmap (each pixel is a uint16_t, with colors defined by
// the drawpixel method of your graphical backend.
// progmem defaults to true for bitmaps defined as static const uint16_t PROGMEM
// but you can set it to false to send a bitmap array in RAM.
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
const uint16_t *bitmap, int16_t w, int16_t h, bool progmem) {
int16_t i, j;

for(j=0; j<h; j++) {
for(i=0; i<w; i++ ) {
if (progmem) {
drawPixel(x+i, y+j, pgm_read_word(bitmap + j * w + i));
} else {
drawPixel(x+i, y+j, (uint16_t) *(bitmap + j * w + i));
}
}
}
}


#if ARDUINO >= 100
size_t Adafruit_GFX::write(uint8_t c) {
#else
Expand Down
2 changes: 2 additions & 0 deletions Adafruit_GFX.h
Expand Up @@ -74,6 +74,8 @@ class Adafruit_GFX : public Print {
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),
drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap,
int16_t w, int16_t h,bool progmem=true),
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
uint16_t bg, uint8_t size),
setCursor(int16_t x, int16_t y),
Expand Down

0 comments on commit 4b1a8a6

Please sign in to comment.