📄 sma_bmp.h
字号:
/**********************************************************************
* $Workfile: SMA_bmp.h $
* $Revision: 1.1 $
* $Author: WellsK $
* $Date: Aug 30 2002 13:18:46 $
*
* Project: BMP file structures
*
* Description:
* This package contains the structure of the BMP file format.
*
* Notes:
* Data in the BMP header (as read from a file) is not stored word
* aligned after the identifier. If the structure is read from a
* file, the header information may need to be realigned to the
* structure alignment.
*
* It is the intention of this package to support the most common
* BMP image formats in use. Not all BMP formats are supported.
*
* Unsupported BMP formats:
* RLE compression is not supported
* 16-bit and 32-bit color images are not supported
* Masks stored in the color table are not supported
*
* Revision History:
* $Log: //smaicnt2/pvcs/VM/CHIPS/archives/SOC/Source/Graphics/Utilities/BMP conversion/SMA_bmp.h-arc $
*
* Rev 1.1 Aug 30 2002 13:18:46 WellsK
* Corrected C/C++ wrapper.
*
* Rev 1.0 Aug 27 2002 08:37:34 WellsK
* Initial revision.
*
*
* SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
* OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
* AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
* SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
*
* SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
* FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
* SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
* FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
*
* COPYRIGHT (C) 2002 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
* CAMAS, WA
*********************************************************************/
#ifndef BMP_H
#define BMP_H
#ifdef __cplusplus
#if __cplusplus
extern "C"
{
#endif // __cplusplus
#endif // __cplusplus
#include "SMA_types.h"
#include "SMA_colors.h"
//**********************************************************************
// BMP structure defines
//**********************************************************************
#define BMP_ID0 'B' // BMP file identifier character 1
#define BMP_ID1 'M' // BMP file identifier character 2
#define BI_RGB 0x00000000 // Uncompressed image identifier
#define BI_RGBA 0x32424752 // Uncompressed image identifier alias for
// BI_RGB
// The following defines are provided, but are not supported in this
// package
#define BI_RLE4 0x00000002 // 4-bit RLE compression
#define BI_RLE8 0x00000001 // 8-bit RLE compression
#define BI_RLE8A 0x38454C52 // 8-bit RLE compression alias for BI_RLE8
#define BI_BITFIELDS 0x00000003 // Ucompressed RGB with sample packing
#define RGBA 0x41424752 // Raw RGB with alpha
#define RGBT 0x54424752 // Raw RGB with a transparency field
//**********************************************************************
// BMP structures
//**********************************************************************
// Supported BMP file formats (no compressed or masked color modes are
// supported)
typedef enum {
INVALID_BMP = -1,
BPP1 = 0, // 1 bit per pixel with color table
BPP4, // 4 bits per pixel with color table
BPP8, // 8 bits per pixel with color table
BPP24 // 24 bits per pixel
} bmp_storage_type;
// Color table entry format (used with BPP1, BPP4, and BPP8)
typedef struct
{
UNS_8 blue;
UNS_8 green;
UNS_8 red;
UNS_8 unused;
} bmp_color_table_type;
// Color table entry format used with BPP24
typedef struct
{
UNS_8 blue;
UNS_8 green;
UNS_8 red;
} bmp24_color_table_type;
// BMP header structure, not used with files
typedef struct
{
CHAR bftype [2]; // Always ("BM") for BMP files
UNS_32 bfsize; // Size of file in bytes
UNS_32 rsv1; // Reserved
UNS_32 dataoffset; // Offset from file to start to data
UNS_32 bisize; // Size of this structure
UNS_32 biwidth; // Pixel width image size
UNS_32 biheight; // Pixel height image size
UNS_16 biplanes; // color planes
UNS_16 bibitcount; // Bits per pixel
UNS_32 bicompressn; // Compression type, 0 = BMP
UNS_32 bisizeimage; // Size of image in bytes
UNS_32 rsv3; // Normally used for metrics
UNS_32 rsv4; // Normally used for metrics
UNS_32 buclrused; // Colors used in the bitmap,
UNS_32 biclrimp; // Number of important colors
INT_32 ct_data; // Start of color table or data
} bmp_type;
//**********************************************************************
// BMP processing and color support functions
//**********************************************************************
// Determine if the structure is a BMP structure
bmp_storage_type bmp_is_header_valid (bmp_type *bmp_data);
// Returns a pointer to the color table (or NULL if it doesn't exist)
bmp_color_table_type *bmp_get_color_table (bmp_type *bmp_data);
// Returns a pointer to the BMP image data
void *bmp_get_image_data (bmp_type *bmp_data);
// Converts a BMP color table entry to a color_type color
color_type bmp_convert_color (bmp_color_table_type *color_entry);
// Convert a BMP image to a color_type image
bmp_storage_type bmp_convert_image (bmp_type *bmp_data, INT_16 *xsize,
INT_16 *ysize, color_type *bufout);
// Allocates storage for a new BMP file
bmp_type *bmp_allocate_structure (INT_32 xsize, INT_32 ysize,
bmp_storage_type bits_per_pixel);
#ifdef __cplusplus
}
#endif
#endif // BMP_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -