Duncan McIntyre / UniGraphic

Dependents:   TouchScreenCalibrate TouchScreenGUIDemo

Fork of UniGraphic by GraphicsDisplay

Revision:
32:f5f3df66420e
Parent:
22:f9a37f22b9cb
Child:
34:091b954c3205
--- a/Graphics/GraphicsDisplay.cpp	Sat Mar 19 15:36:19 2016 +0000
+++ b/Graphics/GraphicsDisplay.cpp	Mon Mar 28 10:48:45 2016 +0000
@@ -365,6 +365,38 @@
     if(auto_up) copy_to_lcd();
 }
 
+
+void GraphicsDisplay::Bitmap_FG_BG(int x, int y, int w, int h,unsigned char *bitmap) {
+    int  j,k;
+    unsigned char  padd;
+    unsigned short *bitmap_ptr = (unsigned short *)bitmap;    
+
+    padd = w%2; // the lines are padded to multiple of 4 bytes in a bitmap
+    if(x<0) x=0;
+    else if(x>=oriented_width) return;
+    if(y<0) y=0;
+    else if(y>=oriented_height) return;
+    int cropX = (x+w)-oriented_width;
+    if(cropX<0) cropX=0;
+    int cropY = (y+h)-oriented_height;
+    if(cropY<0) cropY=0;
+    window(x, y, w-cropX, h-cropY);
+    bitmap_ptr += ((h - 1)* (w + padd)); // begin of last line in array (first line of image)(standard bmp scan direction is left->right bottom->top)
+    for (j = 0; j < h-cropY; j++) {         //Lines
+        for(k=0; k<w-cropX; k++) {
+            if(*(bitmap_ptr+k) == 0x0000) {
+                window_pushpixel(_foreground);
+            } else {
+                window_pushpixel(_background);
+            }
+           // bitmap_ptr++;
+        }   
+        //window_pushpixelbuf(bitmap_ptr, w-cropX);
+        bitmap_ptr -= w+padd;
+    }
+    if(auto_up) copy_to_lcd();
+}
+
 // local filesystem is not implemented in kinetis board , but you can add a SD card
 // fixme this whole functions needs testing and speedup
 int GraphicsDisplay::BMP_16(int x, int y, const char *Name_BMP)