Prechádzať zdrojové kódy

Manual merge of TheNotary's RAM-based bitmap functions.

Phillip Burgess 10 rokov pred
rodič
commit
fb9e169398
2 zmenil súbory, kde vykonal 32 pridanie a 0 odobranie
  1. 28 0
      Adafruit_GFX.cpp
  2. 4 0
      Adafruit_GFX.h

+ 28 - 0
Adafruit_GFX.cpp

@@ -388,6 +388,34 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
   }
 }
 
+void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
+ 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(bitRead(bitmap[j], 7-i)) drawPixel(x+i, y+j, color);
+    }
+  }
+}
+
+// Draw a 1-bit color bitmap at the specified x, y position from the
+// provided bitmap buffer (NOT PROGMEM memory nor a const) using color
+// as the foreground color and bg as the background color.
+void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
+ uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg) {
+
+  int16_t i, j, byteWidth = (w + 7) / 8;
+
+  for(j=0; j<h; j++) {
+    for(i=0; i<w; i++ ) {
+      if(bitRead(bitmap[j], 7-i)) drawPixel(x+i, y+j, color);
+      else                        drawPixel(x+i, y+j, bg);
+    }
+  }
+}
+
 //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

+ 4 - 0
Adafruit_GFX.h

@@ -56,6 +56,10 @@ class Adafruit_GFX : public Print {
       int16_t w, int16_t h, uint16_t color),
     drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,
       int16_t w, int16_t h, uint16_t color, uint16_t bg),
+    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
+      int16_t w, int16_t h, uint16_t color),
+    drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,
+      int16_t w, int16_t h, uint16_t color, uint16_t bg),
     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,