Forked para SNOCC

Dependencies:   GPS

Dependents:   SNOCC_V1 SNOCC_V2

Fork of RA8875 by SNOCC

Revision:
72:ecffe56af969
Parent:
69:636867df24a1
Child:
79:544eb4964795
diff -r dcac8efd842d -r ecffe56af969 GraphicsDisplay.cpp
--- a/GraphicsDisplay.cpp	Sat Oct 04 17:45:50 2014 +0000
+++ b/GraphicsDisplay.cpp	Sat Oct 11 17:24:29 2014 +0000
@@ -350,105 +350,13 @@
     RGBQUAD q;
     
     memset(&q, 0, sizeof(q));
-    q.rgbBlue  = (c & 0x001F) << 3;      /* Blue value */
-    q.rgbGreen = (c & 0x07E0) >> 3;      /* Green value */
-    q.rgbRed   = (c & 0xF800) >> 8;      /* Red value */
+    q.rgbBlue  = ((c & 0x001F) << 3) | (c & 0x07);          /* Blue value */
+    q.rgbGreen = ((c & 0x07E0) >> 3) | ((c >> 7) & 0x03);   /* Green value */
+    q.rgbRed   = ((c & 0xF800) >> 8) | ((c >> 11) & 0x07);  /* Red value */
     q.rgbReserved = 0;
     return q;
 }
 
-
-RetCode_t GraphicsDisplay::PrintScreen(loc_t x, loc_t y, dim_t w, dim_t h, const char *Name_BMP)
-{
-    BITMAPFILEHEADER BMP_Header;
-    BITMAPINFOHEADER BMP_Info;
-    
-    INFO("(%d,%d) - (%d,%d) %s", x,y,w,h,Name_BMP);
-    if (x >= 0 && x < width()
-    && y >= 0 && y < height()
-    && w > 0 && x + w <= width()
-    && h > 0 && y + h <= height()) {
-
-        BMP_Header.bfType = BF_TYPE;
-        BMP_Header.bfSize = (w * h * sizeof(RGBQUAD)) + sizeof(BMP_Header) + sizeof(BMP_Header);
-        BMP_Header.bfReserved1 = 0;
-        BMP_Header.bfReserved2 = 0;
-        BMP_Header.bfOffBits = sizeof(BMP_Header) + sizeof(BMP_Header);
-        
-        BMP_Info.biSize = sizeof(BMP_Info);
-        BMP_Info.biWidth = w;
-        BMP_Info.biHeight = h;
-        BMP_Info.biPlanes = 1;
-        BMP_Info.biBitCount = 24;
-        BMP_Info.biCompression = BI_RGB;
-        BMP_Info.biSizeImage = 0;
-        BMP_Info.biXPelsPerMeter = 0;
-        BMP_Info.biYPelsPerMeter = 0;
-        BMP_Info.biClrUsed = 0;
-        BMP_Info.biClrImportant = 0;
-
-        INFO("Writing {%s}", Name_BMP);
-        FILE *Image = fopen(Name_BMP, "wb");
-        if (!Image) {
-            ERR("File not found");
-            return(file_not_found);
-        }
-
-        // Be optimistic - don't check for errors.
-        //HexDump("BMP_Header", (uint8_t *)&BMP_Header, sizeof(BMP_Header));
-        fwrite(&BMP_Header, sizeof(char), sizeof(BMP_Header), Image);
-        //INFO("fwrite returned %d", r);
-        
-        //HexDump("BMP_Info", (uint8_t *)&BMP_Info, sizeof(BMP_Info));
-        fwrite(&BMP_Info, sizeof(char), sizeof(BMP_Info), Image);
-        //INFO("fwrite returned %d", r);
-        
-        int lineBufSize = ((24 * w + 7)/8);
-        uint8_t * lineBuffer = (uint8_t *)malloc(lineBufSize);
-        if (lineBuffer == NULL) {
-            fclose(Image);
-            ERR("Not enough RAM for lineBuffer");
-            return(not_enough_ram);
-        }
-        color_t * pixelBuffer = (color_t *)malloc(w * sizeof(color_t));
-        if (pixelBuffer == NULL) {
-            fclose(Image);
-            free(lineBuffer);
-            ERR("Not enough RAM for pixelBuffer");
-            return(not_enough_ram);
-        }
-        
-        // Read the display from the last line toward the top
-        // so we can write the file in one pass.
-        for (int j = h - 1; j >= 0; j--) {
-            // Read one line of pixels to a local buffer
-            if (getPixelStream(pixelBuffer, w, x,y+j) != noerror) {
-                ERR("getPixelStream error, and no recovery handler...");
-            }
-            // Convert the local buffer to RGBQUAD format
-            int lb = 0;
-            for (int i=0; i<w; i++) {
-                color_t pixel = pixelBuffer[x+i];
-                // Scale to 24-bits
-                RGBQUAD q = RGB16ToRGBQuad(pixel);
-                lineBuffer[lb++] = q.rgbBlue;
-                lineBuffer[lb++] = q.rgbGreen;
-                lineBuffer[lb++] = q.rgbRed;
-            }
-            // Write to disk
-            //HexDump("Line", lineBuffer, lineBufSize);
-            fwrite(lineBuffer, sizeof(char), lb, Image);
-        }
-        fclose(Image);
-        free(pixelBuffer);  // don't leak memory.
-        free(lineBuffer);
-        INFO("Image closed"); 
-        return noerror;
-    } else {
-        return bad_parameter;
-    }
-}
-
 RetCode_t GraphicsDisplay::_RenderBitmap(loc_t x, loc_t y, uint32_t fileOffset, FILE * Image)
 {
     BITMAPINFOHEADER BMP_Info;