Skip to content

Commit 2261b1e

Browse files
committed
Added support for multicolor pixmaps in drawRGBBitmap.
1 parent a9e5bc4 commit 2261b1e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Adafruit_GFX.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,20 @@ void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
403403
}
404404
}
405405

406+
// Draw colored bitmap (each pixel is a uint16_t, with colors defined by
407+
// the drawpixel method of your graphical backend.
408+
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
409+
const uint16_t *bitmap, int16_t w, int16_t h) {
410+
int16_t i, j;
411+
412+
for(j=0; j<h; j++) {
413+
for(i=0; i<w; i++ ) {
414+
drawPixel(x+i, y+j, pgm_read_byte(bitmap + j * w + i));
415+
}
416+
}
417+
}
418+
419+
406420
#if ARDUINO >= 100
407421
size_t Adafruit_GFX::write(uint8_t c) {
408422
#else

Adafruit_GFX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class Adafruit_GFX : public Print {
5252
int16_t w, int16_t h, uint16_t color, uint16_t bg),
5353
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
5454
int16_t w, int16_t h, uint16_t color),
55+
drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap,
56+
int16_t w, int16_t h),
5557
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
5658
uint16_t bg, uint8_t size),
5759
setCursor(int16_t x, int16_t y),

0 commit comments

Comments
 (0)