Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XBitmap support (direct usage GIMP *.xbm files) #31

Merged
merged 4 commits into from
Sep 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Adafruit_GFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,24 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
}
}

//Draw XBitMap Files (*.xbm), exported from GIMP,
//Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
//C Array can be directly used with this function
void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h,
uint16_t color) {

int16_t i, j, byteWidth = (w + 7) / 8;

for(j=0; j<h; j++) {
for(i=0; i<w; i++ ) {
if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (1 << (i % 8))) {
drawPixel(x+i, y+j, color);
}
}
}
}

#if ARDUINO >= 100
size_t Adafruit_GFX::write(uint8_t c) {
#else
Expand Down
2 changes: 2 additions & 0 deletions Adafruit_GFX.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Adafruit_GFX : public Print {
int16_t radius, uint16_t color),
drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
int16_t w, int16_t h, uint16_t color),
drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
int16_t w, int16_t h, uint16_t color),
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
13 changes: 13 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Current additions:

- XBitMap support (*.xbm)
Use exported xbm files from GIMP with bitmap data directly in your sources.
(fits perfectly with SSD1306 library from Adafruit)
New function: Adafruit_GFX::drawXBitmap()
Usage: Export bitmap with GIMP as *.xbm file,
Rename the *.xbm to *.c,
Open file in editor,
Use C array directly in your sources.

----------------------------------

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).

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