A basic graphics package for the LPC4088 Display Module.

Dependents:   lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more

Fork of DMBasicGUI by EmbeddedArtists AB

Revision:
0:4977187e90c7
Child:
1:46c8df4608c8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Application/Image.h	Thu Dec 11 11:03:57 2014 +0000
@@ -0,0 +1,89 @@
+
+#ifndef IMAGE_H
+#define IMAGE_H
+
+/**
+ * LcdController example
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "Image.h"
+ *
+ * const unsigned char cube_image1[] = { 137,80,78,71, ... };
+ * int cube_image1_sz = sizeof(cube_image1);
+ *
+ * int main(void) {
+ *    // initialize the display
+ *    ...
+ *
+ *    // decode an image from an array
+ *    Image::ImageData_t img;
+ *    if (Image::decode(cube_image1, cube_image1_sz, &img) == 0) {
+ *         // draw on display using img.pixels, img.width and img.height
+ *         ...
+ *         free(img.pixels);
+ *    }
+ *
+ *    // decode an image from a file
+ *    if (Image::decode("/ram/image.png", &img) == 0) {
+ *         // draw on display using img.pixels, img.width and img.height
+ *         ...
+ *         free(img.pixels);
+ *    }
+ * }
+ * @endcode
+ */
+class Image {
+public:
+
+    enum Type {
+        BMP = 0,
+        PNG,
+        UNKNOWN
+    };
+    
+    enum Resolution {
+        RES_16BIT,
+        RES_24BIT
+    };
+    
+    typedef struct {
+        uint16_t*  pixels;
+        uint32_t   width;
+        uint32_t   height;
+        Resolution res;
+    } ImageData_t;
+
+    /** Decodes the specified image data
+     *
+     *  Note that if this function returns a zero, indicating success,
+     *  the pixels member of the pDataOut structure must be
+     *  deallocated using lpc_free() when no longer needed.
+     *
+     *  @param pDataIn the image data
+     *  @param sizeIn the number of bytes in the pDataIn array
+     *  @param Resolution the format of the display
+     *  @param pDataOut the decoded image (only valid if 0 is returned)
+     *
+     *  @returns
+     *       0 on success
+     *       1 on failure
+     */
+    static int decode(const unsigned char* pDataIn, unsigned int sizeIn, Resolution res, ImageData_t* pDataOut);
+
+    static int decode(const char* filename, Resolution res, ImageData_t* pDataOut);
+    
+private:
+
+    /** No instance needed
+     *
+     */
+    Image();
+    
+    static Type imageType(const unsigned char* pDataIn, unsigned int sizeIn);
+
+    static uint32_t fileSize(FILE* f);
+};
+
+#endif
+