Skip to content

Commit 5b4b8cb

Browse files
committed
Merge branch 'subsonicpulse-master'
2 parents dfa6443 + bf5ab38 commit 5b4b8cb

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Adafruit_GFX.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,24 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
385385
}
386386
}
387387

388+
//Draw XBitMap Files (*.xbm), exported from GIMP,
389+
//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
390+
//C Array can be directly used with this function
391+
void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
392+
const uint8_t *bitmap, int16_t w, int16_t h,
393+
uint16_t color) {
394+
395+
int16_t i, j, byteWidth = (w + 7) / 8;
396+
397+
for(j=0; j<h; j++) {
398+
for(i=0; i<w; i++ ) {
399+
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (1 << (i % 8))) {
400+
drawPixel(x+i, y+j, color);
401+
}
402+
}
403+
}
404+
}
405+
388406
#if ARDUINO >= 100
389407
size_t Adafruit_GFX::write(uint8_t c) {
390408
#else

Adafruit_GFX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class Adafruit_GFX : public Print {
5050
int16_t w, int16_t h, uint16_t color),
5151
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
5252
int16_t w, int16_t h, uint16_t color, uint16_t bg),
53+
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
54+
int16_t w, int16_t h, uint16_t color),
5355
drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color,
5456
uint16_t bg, uint8_t size),
5557
setCursor(int16_t x, int16_t y),

README.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
Current additions:
2+
3+
- XBitMap support (*.xbm)
4+
Use exported xbm files from GIMP with bitmap data directly in your sources.
5+
(fits perfectly with SSD1306 library from Adafruit)
6+
New function: Adafruit_GFX::drawXBitmap()
7+
Usage: Export bitmap with GIMP as *.xbm file,
8+
Rename the *.xbm to *.c,
9+
Open file in editor,
10+
Use C array directly in your sources.
11+
12+
----------------------------------
13+
114
This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions).
215

316
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!

0 commit comments

Comments
 (0)