这个文件负责获得图标数据,把图标数据放到像获得像Framebuffer大小内存,和图标的颜色反转,把数据刷到Framebuffer。
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <render.h>
#include <file.h>
#include <fonts_manager.h>
#include <encoding_manager.h>
#include <string.h>
#include <pic_operation.h>
#include <debug_manager.h>
T_PicFileParser g_tBMPParser;
void FlushVideoMemToDev(PT_VideoMem ptVideoMem)
{
//memcpy(GetDefaultDispDev()->pucDispMem, ptVideoMem->tPixelDatas.aucPixelDatas, ptVideoMem.tPixelDatas.iHeight * ptVideoMem.tPixelDatas.iLineBytes);
if (!ptVideoMem->bDevFrameBuffer)
{
GetDefaultDispDev()->ShowPage(ptVideoMem);// GetDefaultDispDev()->ShowPage函数在fb.c中,把 把数据刷到Framebuffer
}
}
int GetPixelDatasForIcon(char *strFileName,PT_PixelDatas ptPixelDatas)//获得图标数据
{
T_FileMap tFileMap;
int iError;
int iXres,iYres,iBpp;
snprintf(tFileMap.strFileName, 128, "%s/%s", ICON_PATH, strFileName);//把图标路径名存到tFileMap.strFileName
tFileMap.strFileName[127] = '\0';
iError=MapFile(&tFileMap);//把图标映射到内存,在file.c
if(iError)
{
DBG_PRINTF("MapFile %s error!\n", strFileName);
return -1;
}
iError=g_tBMPParser.isSuport(tFileMap.pucFileMapMem);//判断是否是BMP
if (iError == 0)
{
DBG_PRINTF("%s is not bmp file\n", strFileName);
return -1;
}
GetDispResolution(&iXres, &iYres, &iBpp);//获得lcd分辨率
ptPixelDatas->iBpp = iBpp;
iError = g_tBMPParser.GetPixelDatas(tFileMap.pucFileMapMem, ptPixelDatas);//获得图标的真正RGB数据 存到ptPixelDatas
if (iError)
{
DBG_PRINTF("GetPixelDatas for %s error!\n", strFileName);
return -1;
}
return 0;
}
void FreePixelDatasForIcon(PT_PixelDatas ptPixelDatas)
{
g_tBMPParser.FreePixelDatas(ptPixelDatas);//释放图标数据内存
}
static void InvertButton(PT_Layout ptLayout)//图标颜色反转
{
int iY;
int i;
int iButtonWidthBytes;
unsigned char *pucVideoMem;
PT_DispOpr ptDispOpr = GetDefaultDispDev();
pucVideoMem = ptDispOpr->pucDispMem;//获得像Framebuffer大小内存(有时也可本来就是Framebuffer)
pucVideoMem += ptLayout->iTopLeftY * ptDispOpr->iLineWidth + ptLayout->iTopLeftX * ptDispOpr->iBpp / 8; /* 图标在类似Framebuffer中的地址 */
iButtonWidthBytes = (ptLayout->iBotRightX - ptLayout->iTopLeftX) * ptDispOpr->iBpp / 8;//图标一行的宽度
for (iY = ptLayout->iTopLeftY; iY <= ptLayout->iBotRightY; iY++)
{
for (i = 0; i < iButtonWidthBytes; i++)
{
pucVideoMem[i] = ~pucVideoMem[i]; /* 取反 */
}
pucVideoMem += ptDispOpr->iLineWidth;//图标在类似Framebuffer中的地址增加一行
}
((
}
void ReleaseButton(PT_Layout ptLayout)
{
InvertButton(ptLayout);
}
void PressButton(PT_Layout ptLayout)
{
InvertButton(ptLayout);
}