Skip to content

Commit aad430d

Browse files
committed
Allow for drawing bitmaps in RAM (not in progmem).
1 parent b11992a commit aad430d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Adafruit_GFX.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,22 @@ 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
406407
// Draw colored bitmap (each pixel is a uint16_t, with colors defined by
407408
// the drawpixel method of your graphical backend.
409+
// progmem defaults to true for bitmaps defined as static const uint16_t PROGMEM
410+
// but you can set it to false to send a bitmap array in RAM.
408411
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
409-
const uint16_t *bitmap, int16_t w, int16_t h) {
412+
const uint16_t *bitmap, int16_t w, int16_t h, bool progmem) {
410413
int16_t i, j;
411414

412415
for(j=0; j<h; j++) {
413416
for(i=0; i<w; i++ ) {
414-
drawPixel(x+i, y+j, pgm_read_word(bitmap + j * w + i));
417+
if (progmem) {
418+
drawPixel(x+i, y+j, pgm_read_word(bitmap + j * w + i));
419+
} else {
420+
drawPixel(x+i, y+j, (uint16_t) *(bitmap + j * w + i));
421+
}
415422
}
416423
}
417424
}

Adafruit_GFX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Adafruit_GFX : public Print {
5353
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
5454
int16_t w, int16_t h, uint16_t color),
5555
drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap,
56-
int16_t w, int16_t h),
56+
int16_t w, int16_t h,bool progmem=true),
5757
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
5858
uint16_t bg, uint8_t size),
5959
setCursor(int16_t x, int16_t y),

0 commit comments

Comments
 (0)