大学生
最后登录1970-1-1
在线时间 小时
注册时间2015-3-15
|
#include "bsp_bmp.h"
#include "bsp_ili9341.h"
FATFS bmpfs[2];
FIL bmpfsrc ,bmpfdst;
FRESULT bmpres;
UINT read_num;
void LCD_Show_Bmp(unsigned short int x, unsigned short int y,unsigned char *file_name)
{
int i, j, k;
int width, height, l_width;
BYTE red,green,blue;
BITMAPFILEHEADER bitfilehead;
BITMAPINFOHEADER bitinfohead;
WORD fileType;
unsigned char temp_name[20];
BYTE pColorData[960];
sprintf((char*)temp_name,"0:%s",file_name);
f_mount(0, &bmpfs[0]);
bmpres = f_open( &bmpfsrc , (char *)temp_name, FA_OPEN_EXISTING | FA_READ);
//-------------------------------------------------------------------------------------------------------
if(bmpres == FR_OK)
{
f_read(&bmpfsrc,&fileType,sizeof(WORD),&read_num);
f_read(&bmpfsrc,&bitfilehead,sizeof(bitfilehead),&read_num);
f_read(&bmpfsrc,&bitinfohead,sizeof(bitinfohead),&read_num);
}
//-------------------------------------------------------------------------------------------------------
width = bitinfohead.biWidth;
height = bitinfohead.biHeight;
// ¼ÆËãλí¼μÄêμ¼ê¿í¶è2¢è·±£ËüÎa32μı¶êy
l_width =Standard_width(width* bitinfohead.biBitCount);
if(l_width > 960)
{
return;
}
//éèÖÃLcd Gram é¨Ãè·½ÏòÎa: óòϽÇ->×óéϽÇ
LCD_GramScan( 3 );
//¿aò»¸öí¼Æ¬′óD¡μÄ′°¿ú
LCD_OpenWindows(x, y, width, height);
//ÅD¶ÏêÇ·ñêÇ24bitÕæ2êé«í¼
if(bitinfohead.biBitCount >= 24)
{
for(i=0;i< height; i++)
{
// #if 0
// for(j=0; j< l_width; j++)
// {
// f_read(&bmpfsrc,pColorData+j,1,&read_num);
// }
// #elif 1
f_read(&bmpfsrc,pColorData,l_width/2,&read_num);
f_read(&bmpfsrc,pColorData+l_width/2,l_width/2,&read_num);
// #else
// f_read(&bmpfsrc,pColorData,l_width,&read_num);
// #endif
for(j=0; j<width; j++) //ò»DDóDD§DÅÏ¢
{
k = j*3; //ò»DDÖDμúK¸öÏñËØμÄÆeμã
red = pColorData[k+2];
green = pColorData[k+1];
blue = pColorData[k];
LCD_WR_Data(RGB24TORGB16(red,green,blue)); //D′èëLCD-GRAM
}
}
}
else
return ;
f_close(&bmpfsrc);
}
为什么把FIL bmpfsrc ,bmpfdst中的bmpfdst注释了就不能显示图片
|
|