?? bmpi_rgb8_decoder.c
字號:
/*
*******************************************************************************
*
* FILE NAME:
* bmp_rgb8_decoder.c
*
* DESCRIPTION:
* source code for BMP decoder with 8-bit and no compression (RGB8)
*
* MODULE:
* BMP (BitMaP) decoder.
*
*
*******************************************************************************
*/
/*
*******************************************************************************
* Include files
*******************************************************************************
*/
/* -- Include for BMP ressources -- */
#include "bmp_decoder_api.h"
#include "bmpi_decoder.h"
/*
*******************************************************************************
*
* FUNCTION NAME:
* BMPI_DecodeRGB8()
*
* FUNCTION DESCRIPTION:
* This function decodes a BMP image with 8-bit color and no compression.
*
* INPUTS:
* pu8Bitmap : pointer to bitmap data
* psPalette : pointer to palette (structure)
* sImageInfo : image information structure
* func : pointer to callback function
*
* OUTPUTS:
* psOutputBuffer : pointer to output buffer (structure)
*
* RETURN:
* '0' if successful or '1' if failed.
*
* GLOBALS ACCESSED/MODIFIED:
* < List all global variables this function accesses and/or modifies >
*
* SPECIAL NOTES:
*
*******************************************************************************
*/
OP_UINT8 BMPI_DecodeRGB8
(
OP_UINT8 *pu8Bitmap,
PALETTE_TYPE *psPalette,
BMP_IMAGE_INFO sImageInfo,
OP_BOOLEAN func(OP_UINT16 x, OP_UINT16 y),
IMAGE_DECODER_OUTPUT_TYPE *psOutputBuffer
)
{
/*-----------------------------------------------------------------------*/
/* DECLARE LOCAL VARIABLES */
/*-----------------------------------------------------------------------*/
OP_UINT8 u8PaletteIndex; /* palette index to retrieve RGB color */
OP_UINT32 u32NumExtraByte; /* number of extra bytes append at end of a line */
OP_UINT32 u32XinvCnt; /* inverse counter on X-axis */
OP_UINT32 u32YinvCnt; /* inverse counter on Y-axis */
OP_UINT32 u32Temp; /* 32-bit temporary variable */
/*-----------------------------------------------------------------------*/
/* DECODE 8-BIT COLORS & NO COMPRESSION FORMAT */
/*-----------------------------------------------------------------------*/
/* -- Calculate number of extra bytes in a line -- */
u32Temp = sImageInfo.u32ImageWidth & 0x00000003;
if ( u32Temp != 0 )
{
u32NumExtraByte = 4 - u32Temp;
}
else
{
u32NumExtraByte = 0;
}
/* -- Extract bitmap data and store them in output buffer -- */
/* vertical loop */
u32YinvCnt = sImageInfo.u32ImageHeight;
while(u32YinvCnt--)
{
/* horizontal loop */
u32XinvCnt = sImageInfo.u32ImageWidth;
while(u32XinvCnt--) /* 'true' bytes */
{
/* retrieve color in palette */
u8PaletteIndex = *pu8Bitmap++;
psOutputBuffer->u8Blue = (psPalette+u8PaletteIndex)->u8Blue;
psOutputBuffer->u8Green = (psPalette+u8PaletteIndex)->u8Green;
psOutputBuffer->u8Red = (psPalette+u8PaletteIndex)->u8Red;
psOutputBuffer->u8Alpha = 0xff; /* set to opaque as default */
psOutputBuffer++; /* move pointer to next pixel */
}
pu8Bitmap+=u32NumExtraByte; /* dummy bytes are ignored */
}
/*-----------------------------------------------------------------------*/
/* DECODED SUCCESSFULLY */
/*-----------------------------------------------------------------------*/
return(0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -