初级会员
- 积分
- 98
- 金钱
- 98
- 注册时间
- 2018-11-9
- 在线时间
- 43 小时
|
40金钱
本帖最后由 ZHY98 于 2020-3-19 19:06 编辑
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;//·µ»Ø¶ÁÈ¡µ½µÄ×Ö½ÚÊý
}
int dispbmpex(u8 *BMPFileName,u8 mode,u32 x,u32 y,int member,int denom)
{
char result;
int XSize,YSize;
float Xflag,Yflag;
GUI_COLOR forecolor,bkcolor;
forecolor=GUI_GetColor(); //»ñÈ¡µ±Ç°Ç°¾°É«
bkcolor=GUI_GetBkColor(); //»ñÈ¡µ±Ç°±³¾°É«
result = f_open(&BMPFile,(const TCHAR*)BMPFileName,FA_READ); //´ò¿ªÎļþ
//Îļþ´ò¿ª´íÎó
if(result != FR_OK) return 1;
switch(mode)
{
case 0: //ÔÚÖ¸¶¨Î»ÖÃÏÔʾͼƬ
if((member == 1) && (denom == 1)) //ÎÞÐèËõ·Å£¬Ö±½Ó»æÖÆ
{
GUI_BMP_DrawEx(BmpGetData,&BMPFile,x,y);//ÔÚÖ¸¶¨Î»ÖÃÏÔʾBMPͼƬ
}else //·ñÔòͼƬÐèÒªËõ·Å
{
GUI_BMP_DrawScaledEx(BmpGetData,&BMPFile,x,y,member,denom);
}
break;
case 1: //ÔÚLCDÖмäÏÔʾͼƬ
XSize = GUI_BMP_GetXSizeEx(BmpGetData,&BMPFile); //»ñȡͼƬµÄXÖá´óС
YSize = GUI_BMP_GetYSizeEx(BmpGetData,&BMPFile); //»ñȡͼƬµÄYÖá´óС
if((member == 1) && (denom == 1)) //ÎÞÐèËõ·Å£¬Ö±½Ó»æÖÆ
{
GUI_BMP_DrawEx(BmpGetData,&BMPFile,(lcddev.width-XSize)/2-1,(lcddev.height-YSize)/2-1);
}else
{
Xflag = (float)XSize*((float)member/(float)denom);
Yflag = (float)YSize*((float)member/(float)denom);
XSize = (lcddev.width-(int)Xflag)/2-1;
YSize = (lcddev.height-(int)Yflag)/2-1;
GUI_BMP_DrawScaledEx(BmpGetData,&BMPFile,XSize,YSize,member,denom);
}
break;
}
f_close(&BMPFile); //¹Ø±ÕBMPFileÎļþ
GUI_SetColor(forecolor); //»Ö¸´Ç°¾°É«
GUI_SetBkColor(bkcolor); //»Ö¸´±³¾°É«
return 0;
}
case WM_PAINT:
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
dispbmpex("0:/Laserph.bmp",0,100, 300, 1,1);
break;
在这个方式下图片刷不出来,dispbmpex就是原子哥bmp例程里的。
但是原子哥的程序单独可以运行
void bmpdisplay_demo(void)
{
GUI_SetBkColor(GUI_BLUE);
GUI_SetColor(GUI_RED);
// GUI_SetFont(&GUI_FontHZ16);
GUI_Clear();
dispbmpex("0:/Laserph.bmp",0,0, 0, 1, 1);
}
这样子可以运行
求助帮忙,谢谢了
|
|