高级会员
- 积分
- 769
- 金钱
- 769
- 注册时间
- 2016-3-17
- 在线时间
- 178 小时
|
3金钱
#if SYSTEM_SUPPORT_UCOS
#include "includes.h" //ucos 使用
#endif
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
static char bmpBuffer[BMPPERLINESIZE];
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 0, 0, 0, 0x0, 0 },
};
static int BmpGetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
static int readaddress=0;
FIL * phFile;
UINT NumBytesRead;
#if SYSTEM_SUPPORT_UCOS
OS_CPU_SR cpu_sr;
#endif
phFile = (FIL *)p;
if (NumBytesReq > sizeof(bmpBuffer))
{
NumBytesReq = sizeof(bmpBuffer);
}
//移动指针到应该读取的位置
if(Off == 1) readaddress = 0;
else readaddress=Off;
#if SYSTEM_SUPPORT_UCOS
OS_ENTER_CRITICAL(); //临界区
#endif
f_lseek(phFile,readaddress);
//读取数据到缓冲区中
f_read(phFile,bmpBuffer,NumBytesReq,&NumBytesRead);
#if SYSTEM_SUPPORT_UCOS
OS_EXIT_CRITICAL(); //退出临界区
#endif
*ppData = (U8 *)bmpBuffer;
return NumBytesRead;//返回读取到的字节数
}
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
static FIL BMPFile;
u8 *BMPFileName="0:/PICTURE/ji.bmp";
switch (pMsg->MsgId) {
case WM_PAINT:
f_open(&BMPFile,(const TCHAR*)BMPFileName,FA_READ); //打开文件
GUI_BMP_DrawEx(BmpGetData,&BMPFile,1,1);
f_close(&BMPFile); //关闭BMPFile文件
break;
case WM_NOTIFY_PARENT:
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
WM_HWIN CreateFramewin(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
在WM_PAINT中刷新背景图片不显示,不知是什么原因?(照着BMP例程显示改的,BMP例程可以正常显示)
|
|