高级会员
- 积分
- 771
- 金钱
- 771
- 注册时间
- 2016-3-17
- 在线时间
- 179 小时
|
发表于 2016-10-10 17:18:34
|
显示全部楼层
#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, 240, 320, 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;
static FIL BMPFile;
u8 *BMPFileName="0:/PICTURE/ji.bmp";
switch (pMsg->MsgId) {
case WM_PAINT:
WM_SelectWindow(pMsg->hWin);
f_open(&BMPFile,(const TCHAR*)BMPFileName,FA_READ); //打开文件
GUI_BMP_DrawEx(BmpGetData,&BMPFile,1,20);
f_close(&BMPFile); //关闭BMPFile文件
break;
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetTitleVis(hItem, 0);
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里面使用GUI_BMP_DrawEx不成功,不知道为什么?,能帮忙看一下吗? 谢谢 |
|