在液晶显示需要图片的点阵代码有时需要将BMP图片解码以获取点阵代码,以下为解码分析:
/* 解析
"file1.txt" a file on drive 0
"/file1.txt" (same as above)
"dir1/dir2/file1.txt" a file on drive 0
"2:dir3/file2.txt" a file on drive 2
"2:/dir5" a directory on drive 2
"" the root directory on drive 0
"/" (same as above)
"2:" the root directory on drive 2
*/
//支持24bit BMP图片显示
#include "config.h"
#include "./BMP/BMP.h"
#include "GUI_Private.h"
#include "./FATFS/src/ff.h"
static U16 _Read16(const U8 ** ppData)
{
const U8 *pData;
U16 Value;
pData = *ppData;
Value = *pData;
Value |= (U16)(*(pData + 1) << 8);
pData += 2;
*ppData = pData;
return Value;
}
static U32 _Read32(const U8 ** ppData)
{
const U8 * pData;
U32 Value;
pData = *ppData;
Value = *pData;
Value |= ( *(pData + 1) << 8);
Value |= ((U32)*(pData + 2) << 16);
Value |= ((U32)*(pData + 3) << 24);
pData += 4;
*ppData = pData;
return Value;
}
static int _GetStep(int *pYSize,int *pY)
{
if(*pYSize>0)
{
*pY=*pYSize-1 ;
return -1 ;
}
else if(*pYSize<0)
{
*pYSize=-*pYSize ;
*pY=0 ;
return 1 ;
}
else
{
return 0 ;