00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** 00031 * \file 00032 * \section Purpose 00033 * 00034 * Utility for BMP 00035 * 00036 */ 00037 00038 #ifndef BMP_H 00039 #define BMP_H 00040 00041 /** BMP magic number ('BM'). */ 00042 #define BMP_TYPE 0x4D42 00043 00044 /** headerSize must be set to 40 */ 00045 #define BITMAPINFOHEADER 40 00046 00047 /*------------------------------------------------------------------------------ 00048 * Exported types 00049 *------------------------------------------------------------------------------*/ 00050 00051 #pragma pack(1) 00052 00053 /** BMP (Windows) Header Format */ 00054 typedef struct _BMPHeader { 00055 /* signature, must be 4D42 hex */ 00056 uint16_t type; 00057 /* size of BMP file in bytes (unreliable) */ 00058 uint32_t fileSize; 00059 /* reserved, must be zero */ 00060 uint16_t reserved1; 00061 /* reserved, must be zero */ 00062 uint16_t reserved2; 00063 /* offset to start of image data in bytes */ 00064 uint32_t offset; 00065 /* size of BITMAPINFOHEADER structure, must be 40 */ 00066 uint32_t headerSize; 00067 /* image width in pixels */ 00068 uint32_t width; 00069 /* image height in pixels */ 00070 uint32_t height; 00071 /* number of planes in the image, must be 1 */ 00072 uint16_t planes; 00073 /* number of bits per pixel (1, 4, 8, 16, 24, 32) */ 00074 uint16_t bits; 00075 /* compression type (0=none, 1=RLE-8, 2=RLE-4) */ 00076 uint32_t compression; 00077 /* size of image data in bytes (including padding) */ 00078 uint32_t imageSize; 00079 /* horizontal resolution in pixels per meter (unreliable) */ 00080 uint32_t xresolution; 00081 /* vertical resolution in pixels per meter (unreliable) */ 00082 uint32_t yresolution; 00083 /* number of colors in image, or zero */ 00084 uint32_t ncolours; 00085 /* number of important colors, or zero */ 00086 uint32_t importantcolours; 00087 } BMPHeader; 00088 00089 #pragma pack() 00090 00091 /*------------------------------------------------------------------------------ 00092 * Exported functions 00093 *------------------------------------------------------------------------------*/ 00094 extern uint8_t BMP_IsValid(void *file); 00095 extern uint32_t BMP_GetFileSize(void *file); 00096 00097 extern uint8_t BMP_Decode( 00098 void *file, 00099 uint8_t *buffer, 00100 uint32_t width, 00101 uint32_t height, 00102 uint8_t bpp); 00103 00104 extern void WriteBMPheader( 00105 uint32_t *pAddressHeader, 00106 uint32_t bmpHSize, 00107 uint32_t bmpVSize, 00108 uint8_t nbByte_Pixels); 00109 00110 extern void BMP_displayHeader(uint32_t *pAddressHeader); 00111 extern void RGB565toBGR555( 00112 uint8_t *fileSource, 00113 uint8_t *fileDestination, 00114 uint32_t width, 00115 uint32_t height, 00116 uint8_t bpp); 00117 00118 #endif //#ifndef BMP_H 00119