SAMV71 Xplained Ultra Software Package 1.4

bmp.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2011, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
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 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines