初级会员
- 积分
- 113
- 金钱
- 113
- 注册时间
- 2018-3-5
- 在线时间
- 4 小时
|
5金钱
//Framewin 调用的对话框
static void _dialog1cbk(WM_MESSAGE * pMsg)
{
WM_HWIN hWin,hWindow;
int NCode;
char BUF[20];
hWin = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_TIMER:
hWin = pMsg->hWin;
WM_RestartTimer(pMsg->Data.v,100);
break;
case WM_PAINT:
displaypngex("0:/1.png",0,0,0);//显示PNG图片 失败 出现黑色 死机现象
hWin = pMsg->hWin;
break;
case WM_INIT_DIALOG:
break;
case WM_NOTIFY_PARENT:
break;
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
//PNG显示(PNG库添加成功了,在不适用控件时可以显示PNG)
static int PngGetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
static int readaddress=0;
FIL * phFile;
U8 *pData;
UINT NumBytesRead;
#if SYSTEM_SUPPORT_UCOS
OS_CPU_SR cpu_sr;
#endif
pData = (U8*)*ppData;
phFile = (FIL *)p;
if(Off == 1) readaddress = 0;
else readaddress=Off;
#if SYSTEM_SUPPORT_UCOS
OS_ENTER_CRITICAL();
#endif
f_lseek(phFile,readaddress);
f_read(phFile,pData,NumBytesReq,&NumBytesRead);
#if SYSTEM_SUPPORT_UCOS
OS_EXIT_CRITICAL();
#endif
return NumBytesRead;
}
int displaypngex(char *PNGFileName,u8 mode,u32 x,u32 y)
{
char result;
int XSize,YSize;
result = f_open(&PNGFile,(const TCHAR*)PNGFileName,FA_READ);
if(result != FR_OK) return 1;
GUI_PNG_DrawEx(PngGetData,&PNGFile,x,y);
f_close(&PNGFile);
return 0;
}
|
|