]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/AtmelFiles/libboard_sama5d4x-ek/include/bmp.h
Core kernel files:
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D4x_EK_IAR / AtmelFiles / libboard_sama5d4x-ek / include / bmp.h
diff --git a/FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/AtmelFiles/libboard_sama5d4x-ek/include/bmp.h b/FreeRTOS/Demo/CORTEX_A5_SAMA5D4x_EK_IAR/AtmelFiles/libboard_sama5d4x-ek/include/bmp.h
new file mode 100644 (file)
index 0000000..60470f3
--- /dev/null
@@ -0,0 +1,250 @@
+/* ----------------------------------------------------------------------------\r
+ *         SAM Software Package License \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2011, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ *  \file\r
+ *  \section Purpose\r
+ * \r
+ *  Utility for BMP\r
+ * \r
+ */\r
+\r
+#ifndef BMP_H\r
+#define BMP_H\r
+\r
+/**  BMP magic number ('BM'). */\r
+#define BMP_TYPE       0x4D42\r
+\r
+/**  headerSize must be set to 40 */\r
+#define BITMAPINFOHEADER   40\r
+\r
+/*------------------------------------------------------------------------------\r
+ *         Exported types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*\r
+ * In case of IAR EWARM use, we define an empty macro to turn useless GCC and MDK __attribute__ keyword\r
+ */\r
+#if defined __ICCARM__ || defined __CC_ARM || defined __GNUC__\r
+#    pragma pack( 1 )\r
+#endif\r
+\r
+/** BMP (Windows) File Header Format */\r
+typedef struct _BMPFileHeader\r
+{\r
+    /** signature, must be 4D42 hex */\r
+    uint16_t type;\r
+    /** size of BMP file in bytes (unreliable) */\r
+    uint32_t fileSize;\r
+    /** reserved, must be zero */\r
+    uint16_t reserved1;\r
+    /** reserved, must be zero */\r
+    uint16_t reserved2;\r
+    /** offset to start of image data in bytes */\r
+    uint32_t offset;\r
+} BMPFileHeader;\r
+\r
+/** BMP (Windows 2.x) Header */\r
+typedef struct _BMP2XHeader\r
+{\r
+    /** size of this header in bytes */\r
+    uint32_t size;\r
+    /** image width in pixels */\r
+    uint16_t width;\r
+    /** image height in pixels */\r
+    uint16_t height;\r
+    /** number of color planes */\r
+    uint16_t planes;\r
+    /** number of bits per pixel */\r
+    uint16_t bitsPerPixel;\r
+} BMP2XHeader;\r
+\r
+/** BMP (Windows 3.x) Header, 40 bytes */\r
+typedef struct _BMP3XHeader\r
+{\r
+    /** size of this header in bytes */\r
+    uint32_t size;\r
+    /** image width in pixels */\r
+    int32_t  width;\r
+    /** image height in pixels */\r
+    int32_t  height;\r
+    /** number of color planes */\r
+    uint16_t planes;\r
+    /** number of bits per pixel */\r
+    uint16_t bitsPerPixel;\r
+    /** Compression methods used */\r
+    uint32_t compression;\r
+    /** Size of bitmap in bytes */\r
+    uint32_t sizeOfBitmap;\r
+    /** horizontal resolution in pixels per meter */\r
+    int32_t  xResolution;\r
+    /** vertical resolution in pixels per meter */\r
+    int32_t  yResolution;\r
+    /** number of colors in the image */\r
+    uint32_t colorsUsed;\r
+    /** minimum number of important colors */\r
+    uint32_t colorsImportant;\r
+}  BMP3XHeader;\r
+\r
+/** BMP (Windows 95, V4) Header, 108 bytes */\r
+typedef struct _BMP4Header\r
+{\r
+    /** size of this header in bytes */\r
+    uint32_t size;\r
+    /** image width in pixels */\r
+    int32_t  width;\r
+    /** image height in pixels */\r
+    int32_t  height;\r
+    /** number of color planes */\r
+    uint16_t planes;\r
+    /** number of bits per pixel */\r
+    uint16_t bitsPerPixel;\r
+    /** Compression methods used */\r
+    uint32_t compression;\r
+    /** Size of bitmap in bytes */\r
+    uint32_t sizeOfBitmap;\r
+    /** horizontal resolution in pixels per meter */\r
+    int32_t  xResolution;\r
+    /** vertical resolution in pixels per meter */\r
+    int32_t  yResolution;\r
+    /** number of colors in the image */\r
+    uint32_t colorsUsed;\r
+    /** minimum number of important colors */\r
+    uint32_t colorsImportant;\r
+\r
+    /** Mask identifying bits of red component */\r
+    uint32_t redMask;\r
+    /** Mask identifying bits of green component */\r
+    uint32_t greenMask;\r
+    /** Mask identifying bits of blue component */\r
+    uint32_t blueMask;\r
+    /** Mask identifying bits of alpha component */\r
+    uint32_t alphaMask;\r
+    /** Color space type */\r
+    uint32_t csType;\r
+    /** X coordinate of red endpoint */\r
+    int32_t  redX;\r
+    /** Y coordinate of red endpoint */\r
+    int32_t  redY;\r
+    /** Z coordinate of red endpoint */\r
+    int32_t  redZ;\r
+    /** X coordinate of green endpoint */\r
+    int32_t  greenX;\r
+    /** Y coordinate of green endpoint */\r
+    int32_t  greenY;\r
+    /** Z coordinate of green endpoint */\r
+    int32_t  greenZ;\r
+    /** X coordinate of blue endpoint */\r
+    int32_t  blueX;\r
+    /** Y coordinate of blue endpoint */\r
+    int32_t  blueY;\r
+    /** Z coordinate of blue endpoint */\r
+    int32_t  blueZ;\r
+    /** Gamma red coordinate scale value */\r
+    uint32_t gammaRed;\r
+    /** Gamma green coordinate scale value */\r
+    uint32_t gammaGreen;\r
+    /** Gamma blue coordinate scale value */\r
+    uint32_t gammaBlue;\r
+}  BMP4Header;\r
+\r
+/** BMP (Windows) Header Format */\r
+typedef struct _BMPHeader\r
+{\r
+    /*  signature, must be 4D42 hex */\r
+    uint16_t type;\r
+    /*  size of BMP file in bytes (unreliable) */\r
+    uint32_t fileSize;\r
+    /*  reserved, must be zero */\r
+    uint16_t reserved1;\r
+    /*  reserved, must be zero */\r
+    uint16_t reserved2;\r
+    /*  offset to start of image data in bytes */\r
+    uint32_t offset;\r
+    /*  size of BITMAPINFOHEADER structure, must be 40 */\r
+    uint32_t headerSize;\r
+    /*  image width in pixels */\r
+    uint32_t width;\r
+    /*  image height in pixels */\r
+    uint32_t height;\r
+    /*  number of planes in the image, must be 1 */\r
+    uint16_t planes;\r
+    /*  number of bits per pixel (1, 4, 8, 16, 24, 32) */\r
+    uint16_t bits;\r
+    /*  compression type (0=none, 1=RLE-8, 2=RLE-4) */\r
+    uint32_t compression;\r
+    /*  size of image data in bytes (including padding) */\r
+    uint32_t imageSize;\r
+    /*  horizontal resolution in pixels per meter (unreliable) */\r
+    uint32_t xresolution;\r
+    /*  vertical resolution in pixels per meter (unreliable) */\r
+    uint32_t yresolution;\r
+    /*  number of colors in image, or zero */\r
+    uint32_t ncolours;\r
+    /*  number of important colors, or zero */\r
+    uint32_t importantcolours;\r
+\r
+} BMPHeader  ; // GCC\r
+\r
+#if defined __ICCARM__ || defined __CC_ARM || defined __GNUC__\r
+#    pragma pack()\r
+#endif\r
+\r
+/*------------------------------------------------------------------------------\r
+ *         Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+extern uint8_t BMP_IsValid(void *file);\r
+\r
+extern uint32_t BMP_GetFileSize(void *file);\r
+\r
+extern uint8_t BMP_Decode(\r
+    void *file,\r
+    uint8_t*buffer,\r
+    uint32_t width,\r
+    uint32_t height,\r
+    unsigned char bpp);\r
+\r
+extern void WriteBMPheader(uint32_t* pAddressHeader,\r
+                    uint32_t  bmpHSize,\r
+                    uint32_t  bmpVSize,\r
+                    uint8_t bmpRgb,\r
+                    uint8_t nbByte_Pixels);\r
+\r
+extern void BMP_displayHeader(uint32_t* pAddressHeader);\r
+\r
+extern void RGB565toBGR555(\r
+    uint8_t *fileSource,\r
+    uint8_t *fileDestination,\r
+    uint32_t width,\r
+    uint32_t height,\r
+    uint8_t bpp);\r
+\r
+#endif //#ifndef BMP_H\r
+\r