⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmpi_rgb24_decoder.c

📁 bmp图像文件解码器的arm版本的源代码
💻 C
字号:
/*

*******************************************************************************
*
* FILE NAME:            
*   bmp_rgb24_decoder.c
*
* DESCRIPTION:
*   source code for BMP decoder with 24-bit and no compression (RGB24)
*
* MODULE: 
*   BMP (BitMaP) decoder.
* 
*  
*******************************************************************************
*/

/*
*******************************************************************************
* Include files
*******************************************************************************
*/

/* -- Include for BMP ressources -- */
#include "bmp_decoder_api.h"
#include "bmpi_decoder.h"



/*
*******************************************************************************
* 
* FUNCTION NAME:
*   BMPI_DecodeRGB24()
*
* FUNCTION DESCRIPTION:
*   This function decodes a BMP image with 24-bit color and no compression.
*
* INPUTS:
*   pu8InputBuffer  : pointer to input buffer
*   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_DecodeRGB24
(
    OP_UINT8                    *pu8InputBuffer,
    BMP_IMAGE_INFO              sImageInfo,
    OP_BOOLEAN                  func(OP_UINT16 x, OP_UINT16 y),
    IMAGE_DECODER_OUTPUT_TYPE   *psOutputBuffer
)
{


    /*-----------------------------------------------------------------------*/
    /* DECLARE LOCAL VARIABLES                                                 */
    /*-----------------------------------------------------------------------*/

    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 24-BIT COLORS & NO COMPRESSION FORMAT                           */
    /*-----------------------------------------------------------------------*/

    /* -- Calculate number of extra of bytes in a line -- */
    u32Temp = ( 3 * 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 */
        {
            psOutputBuffer->u8Blue  = *pu8InputBuffer++;
            psOutputBuffer->u8Green = *pu8InputBuffer++;
            psOutputBuffer->u8Red   = *pu8InputBuffer++;
            psOutputBuffer->u8Alpha = 0xff;      /* set to opaque as default */
            psOutputBuffer++;                  /* move pointer to next pixel */
        }
        pu8InputBuffer+=u32NumExtraByte;          /* dummy bytes are ignored */

    }


    /*-----------------------------------------------------------------------*/
    /* DECODED SUCCESSFULLY                                                  */
    /*-----------------------------------------------------------------------*/

    return(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -