Skip to content

Commit 4dc78f0

Browse files
committed
Add XBitmap (*.xbm) support
add XBitmap(*.xbm) support, to directly use exported GIMP xbm files. (Rename the file to *.c and open in editor.)
1 parent 33a4bdf commit 4dc78f0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Adafruit_GFX.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,24 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
363363
}
364364
}
365365

366+
//Draw XBitMap Files (*.xbm), exported from GIMP,
367+
//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
368+
//C Array can be directly used with this function
369+
void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
370+
const uint8_t *bitmap, int16_t w, int16_t h,
371+
uint16_t color) {
372+
373+
int16_t i, j, byteWidth = (w + 7) / 8;
374+
375+
for(j=0; j<h; j++) {
376+
for(i=0; i<w; i++ ) {
377+
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (1 << (i % 8))) {
378+
drawPixel(x+i, y+j, color);
379+
}
380+
}
381+
}
382+
}
383+
366384
#if ARDUINO >= 100
367385
size_t Adafruit_GFX::write(uint8_t c) {
368386
#else

0 commit comments

Comments
 (0)