Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:44

0001 /* ---------------------------------------------------------------------------- */
0002 /*                  Atmel Microcontroller Software Support                      */
0003 /*                       SAM Software Package License                           */
0004 /* ---------------------------------------------------------------------------- */
0005 /* Copyright (c) 2015, Atmel Corporation                                        */
0006 /*                                                                              */
0007 /* All rights reserved.                                                         */
0008 /*                                                                              */
0009 /* Redistribution and use in source and binary forms, with or without           */
0010 /* modification, are permitted provided that the following condition is met:    */
0011 /*                                                                              */
0012 /* - Redistributions of source code must retain the above copyright notice,     */
0013 /* this list of conditions and the disclaimer below.                            */
0014 /*                                                                              */
0015 /* Atmel's name may not be used to endorse or promote products derived from     */
0016 /* this software without specific prior written permission.                     */
0017 /*                                                                              */
0018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
0019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
0020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
0021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
0022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
0023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
0024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
0025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
0026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
0027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
0028 /* ---------------------------------------------------------------------------- */
0029 
0030 /**
0031  *  \file
0032  *  \section Purpose
0033  *
0034  *  Utility for BMP
0035  *
0036  */
0037 
0038 #ifndef BMP_H
0039 #define BMP_H
0040 
0041 /**  BMP magic number ('BM'). */
0042 #define BMP_TYPE       0x4D42
0043 
0044 /**  headerSize must be set to 40 */
0045 #define BITMAPINFOHEADER   40
0046 
0047 /*------------------------------------------------------------------------------
0048  *         Exported types
0049  *------------------------------------------------------------------------------*/
0050 
0051 #pragma pack(1)
0052 
0053 /** BMP (Windows) Header Format */
0054 typedef struct _BMPHeader {
0055     /*  signature, must be 4D42 hex */
0056     uint16_t type;
0057     /*  size of BMP file in bytes (unreliable) */
0058     uint32_t fileSize;
0059     /*  reserved, must be zero */
0060     uint16_t reserved1;
0061     /*  reserved, must be zero */
0062     uint16_t reserved2;
0063     /*  offset to start of image data in bytes */
0064     uint32_t offset;
0065     /*  size of BITMAPINFOHEADER structure, must be 40 */
0066     uint32_t headerSize;
0067     /*  image width in pixels */
0068     uint32_t width;
0069     /*  image height in pixels */
0070     uint32_t height;
0071     /*  number of planes in the image, must be 1 */
0072     uint16_t planes;
0073     /*  number of bits per pixel (1, 4, 8, 16, 24, 32) */
0074     uint16_t bits;
0075     /*  compression type (0=none, 1=RLE-8, 2=RLE-4) */
0076     uint32_t compression;
0077     /*  size of image data in bytes (including padding) */
0078     uint32_t imageSize;
0079     /*  horizontal resolution in pixels per meter (unreliable) */
0080     uint32_t xresolution;
0081     /*  vertical resolution in pixels per meter (unreliable) */
0082     uint32_t yresolution;
0083     /*  number of colors in image, or zero */
0084     uint32_t ncolours;
0085     /*  number of important colors, or zero */
0086     uint32_t importantcolours;
0087 } BMPHeader;
0088 
0089 #pragma pack()
0090 
0091 /*------------------------------------------------------------------------------
0092  *         Exported functions
0093  *------------------------------------------------------------------------------*/
0094 extern uint8_t BMP_IsValid(void *file);
0095 extern uint32_t BMP_GetFileSize(void *file);
0096 
0097 extern uint8_t BMP_Decode(
0098     void *file,
0099     uint8_t *buffer,
0100     uint32_t width,
0101     uint32_t height,
0102     uint8_t bpp);
0103 
0104 extern void WriteBMPheader(
0105     uint32_t *pAddressHeader,
0106     uint32_t  bmpHSize,
0107     uint32_t  bmpVSize,
0108     uint8_t nbByte_Pixels);
0109 
0110 extern void BMP_displayHeader(uint32_t *pAddressHeader);
0111 extern void RGB565toBGR555(
0112     uint8_t *fileSource,
0113     uint8_t *fileDestination,
0114     uint32_t width,
0115     uint32_t height,
0116     uint8_t bpp);
0117 
0118 #endif //#ifndef BMP_H
0119