初级会员
- 积分
- 63
- 金钱
- 63
- 注册时间
- 2015-11-7
- 在线时间
- 5 小时
|
1金钱
本帖最后由 SXP_F4 于 2016-6-25 10:40 编辑
如题,最近用原子开发板跑emwin 5.26库,显示SD卡上的BMP图片时,出现图中屏幕下面重复显示问题,并且当图片大于650*390时,就显示不出来,百思不得其解?
无桌面图标
有桌面图标
无背景
GUI内存从800K改为500K
应该是与emwin内存分配有关,内存是使用外部SRAM,内存分配越小,重复越多
/*
创建一个基于emwin的桌面
*/
#include "GUI.h"
#include "WM.h"
#include "ImageSrc.h"
#include "ICONVIEW.h"
#include "ff.h"
#include "stdio.h"
#include "includes.h"
/*********************************************************************
*
* Types
*
**********************************************************************
*/
typedef struct {
const GUI_BITMAP * pBitmap;
const char * pText;
const char * pExplanation;
} BITMAP_ITEM;
/*********************************************************************
*
* _aBitmapItem
*/
const BITMAP_ITEM _aBitmapItem[] = {
{ IDC_computer, "computer", "computer" },
// { IDC_internet, "Internet", "internet" },
// { IDC_set ,"setting,","device set"},
// { IDC_rubbish, "rubbish", "rubbish" },
// { IDC_calculate,"calculate","calculater"},
// { IDC_music, "music", "music player" },
{ IDC_clock,"clock","clock"},
// { IDC_map,"map","map"},
// { IDC_message,"message","message"},
// { IDC_movie,"movie","movie"},
// { IDC_phone,"phone","phone"},
};
static U8 *_acBuff;
static int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off) {
UINT NumBytesRead=0;
OS_CPU_SR cpu_sr=0;
// U8 * pData;
// phFile = (HANDLE *)p;
//
// Set file pointer to the required position
//
// SetFilePointer(*phFile, Off, 0, FILE_BEGIN);
//
// Read data into buffer
//
// ReadFile(*phFile, pData, NumBytesReq, &NumBytesRead, NULL);
if(NumBytesReq >2000)
{
NumBytesReq = 2000;
}
OS_ENTER_CRITICAL();
printf("移动读取指针%d\r\n",f_lseek((FIL*)p,Off));
printf("读取数据%d\r\n",f_read((FIL*)p,_acBuff,NumBytesReq,&NumBytesRead));
OS_EXIT_CRITICAL();
printf("NumBytesRead=%d\r\n",NumBytesRead);
//
// Return number of available bytes
//
*ppData= _acBuff;
return NumBytesRead;
}
/*********************************************************************
*
* _DrawPNG_file
*
* Function description
* Draws a PNG file from a file system
*/
static void _DrawBMP_file(const char * sFilename,int x0,int y0) {
FIL file;
FRESULT res;
GUI_HMEM hmem;
// int xSize;
// int ySize;
// int w;
// int h;
// int xPos;
// int yPos;
printf("打开文件\n");
res = f_open(&file,sFilename,FA_READ|FA_OPEN_EXISTING);
printf("已打开文件:%d\n",res);
if(res == FR_OK)
{
hmem = GUI_ALLOC_AllocNoInit(4000);
_acBuff = GUI_ALLOC_h2p(hmem);
puts("打开文件成功");
GUI_DispDecMin(res);
puts("开始绘制");
GUI_BMP_DrawEx(_GetData, &file, x0, y0);
puts("绘制完成");
f_close(&file);
GUI_ALLOC_Free(hmem);
}
}
static void _cbDeskTopCallBack(WM_MESSAGE * pMsg)
{
// USER START (Optionally insert additional variables)
// USER END
int Id;
int NCode;
int Sel;
// int textmodeold;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Window'
//
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); // Id of widget
NCode = pMsg->Data.v;
// textmodeold=GUI_SetTextMode(GUI_TEXTMODE_TRANS);
switch (Id)
{
case GUI_ID_ICONVIEW0:
switch (NCode)
{
case WM_NOTIFICATION_SEL_CHANGED:
Sel = ICONVIEW_GetSel(pMsg->hWinSrc);
GUI_DispStringAt(_aBitmapItem[Sel].pExplanation,200,200);
break;
case WM_NOTIFICATION_CLICKED:
Sel = ICONVIEW_GetSel(pMsg->hWinSrc);
GUI_DispStringAt("YOU clicked icon :",200,250);
GUI_DispDecMin(Sel);
break;
case WM_NOTIFICATION_RELEASED:
Sel = ICONVIEW_GetSel(pMsg->hWinSrc);
GUI_DispStringAt("YOU released icon :", 200, 280);
GUI_DispDecMin(Sel);
break;
case WM_NOTIFICATION_MOVED_OUT:
Sel = ICONVIEW_GetSel(pMsg->hWinSrc);
GUI_DispStringAt("YOU moveout icon :", 200, 300);
GUI_DispDecMin(Sel);
break;
default:
break;
}
default:
break;
}
// GUI_SetTextMode(textmodeold);
break;
case WM_PAINT:
// GUI_DrawBitmap(IDC_BKimage,0,0);
_DrawBMP_file("0:/girl.bmp",0,0);
break;
// USER START (Optionally insert additional message handling)
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
WM_HWIN ShowDeskTop(void)
{
WM_HWIN hWin;
int i;
WM_SetDesktopColor(GUI_BLACK);
WM_SetCallback(WM_HBKWIN, _cbDeskTopCallBack);
hWin = ICONVIEW_CreateEx(0, 0, 800, 480,
WM_HBKWIN, WM_CF_SHOW | WM_CF_HASTRANS,
0, GUI_ID_ICONVIEW0, 85, 85);
ICONVIEW_SetFont(hWin,&GUI_Font16_1);
for (i = 0; i < GUI_COUNTOF(_aBitmapItem); i++) {
/*
* Add icons to the widget
*/
ICONVIEW_AddBitmapItem(hWin, _aBitmapItem.pBitmap, _aBitmapItem.pText);
}
return WM_HBKWIN;
}
|
最佳答案
查看完整内容[请看2#楼]
背景窗口并不一定是WM_HBKWIN啊,我指的是你的对话框的父窗口,这个在你创建对话框时已经确定了,我前段时间也碰到过你这问题,后来被朋友指点了才知道是这样解决,我截个图你看下呗。
|