?? bmpi_rgb4_decoder.c
字號:
/*
*******************************************************************************
*
* FILE NAME:
* bmp_rgb4_decoder.c
*
* DESCRIPTION:
* source code for BMP decoder with 4-bit and no compression (RGB4)
*
* MODULE:
* BMP (BitMaP) decoder.
*
*
*******************************************************************************
*/
/*
*******************************************************************************
* Include files
*******************************************************************************
*/
/* -- Include for BMP ressources -- */
#include "bmp_decoder_api.h"
#include "bmpi_decoder.h"
/*
*******************************************************************************
*
* FUNCTION NAME:
* BMPI_DecodeRGB4()
*
* FUNCTION DESCRIPTION:
* This function decodes a BMP image with 4-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_DecodeRGB4
(
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 u32HalfWidth; /* half image width */
OP_UINT32 u32XinvCnt; /* inverse counter on X-axis */
OP_UINT32 u32YinvCnt; /* inverse counter on Y-axis */
/*-----------------------------------------------------------------------*/
/* DECODE 4-BIT COLORS & NO COMPRESSION FORMAT */
/*-----------------------------------------------------------------------*/
/* -- Calculate number of extra of bytes in a line -- */
u32HalfWidth = sImageInfo.u32ImageWidth >> 1;
u32NumExtraByte = ((sImageInfo.u32ImageWidth+1) >> 1) & 0x00000003;
if ( u32NumExtraByte != 0 )
{
u32NumExtraByte = 4-u32NumExtraByte;
}
else
{
u32NumExtraByte = 0;
}
/* -- Extract bitmap data and store them in output buffer -- */
/* vertical loop */
u32YinvCnt = sImageInfo.u32ImageHeight;
while(u32YinvCnt--)
{
/* horizontal loop */
u32XinvCnt = u32HalfWidth;
while(u32XinvCnt--) /* 'true' bytes */
{
/* for the first pixel in byte */
u8PaletteIndex = ( (*pu8Bitmap) >> 4 ) & 0x0f;
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 */
/* for the second pixel in byte */
u8PaletteIndex = (*pu8Bitmap++) & 0x0f;
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 */
}
if( (u32HalfWidth & 0x00000001) == 1 )
{
u8PaletteIndex = ( (*pu8Bitmap++) >> 4 ) & 0x0f;
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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -