初级会员

- 积分
- 113
- 金钱
- 113
- 注册时间
- 2018-3-5
- 在线时间
- 4 小时
|
5金钱
战舰V3开发板 STemwin 希望在Framewin中显示PNG图片,失败,显示黑色,死机,求大神指点!!!
http://www.openedv.com/forum.php ... 8&fromuid=99694
(出处: OpenEdv-开源电子网)
1.PNG库添加成功,因为main函数直接显示PNG是可以的,我测试过2.希望在Framewin或者Window中显示,通过回调函数里面的WM_PAINT就是显示不了,显示出黑色。
同样的位置,同样的方法显示BMP图片,就是可以的。
3.一开始PNG其实也有显示一部分的,好像后来被Framewin覆盖了
求大神指点!!!
程序:
//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;
}
|
|