使用STM32的例程,可以显示图片,把图片换成其它BMP图片,修改Lcd_show_bmp(0, 0,"/tupian.bmp");,并把图片放到SD卡,液晶不能显示图片,那么图片的路径是如何设置的?
void Lcd_show_bmp(unsigned short int x, unsigned short int y,unsigned char *pic_name)
{
int i, j, k;
int width, height, l_width;
BYTE red,green,blue;
BITMAPFILEHEADER bitHead;
BITMAPINFOHEADER bitInfoHead;
WORD fileType;
unsigned int read_num;
unsigned char tmp_name[20];
sprintf((char*)tmp_name,"0:%s",pic_name);
f_mount(0, &bmpfs[0]);
BMP_DEBUG_PRINTF("file mount ok \r\n");
bmpres = f_open( &bmpfsrc , (char *)tmp_name, FA_OPEN_EXISTING | FA_READ);
if(bmpres == FR_OK)
{
BMP_DEBUG_PRINTF("Open file success\r\n");
f_read(&bmpfsrc,&fileType,sizeof(WORD),&read_num);
if(fileType != 0x4d42)
{
BMP_DEBUG_PRINTF("file is not .bmp file!\r\n");
return;
}
else
{
BMP_DEBUG_PRINTF("Ok this is .bmp file\r\n");
}
f_read(&bmpfsrc,&bitHead,sizeof(tagBITMAPFILEHEADER),&read_num);
showBmpHead(&bitHead);
f_read(&bmpfsrc,&bitInfoHead,sizeof(BITMAPINFOHEADER),&read_num);
showBmpInforHead(&bitInfoHead);
}
else
{
BMP_DEBUG_PRINTF("file open fail!\r\n");
return;
}
width = bitInfoHead.biWidth;
height = bitInfoHead.biHeight;
l_width = WIDTHBYTES(width* bitInfoHead.biBitCount);
if(l_width > 960)
{
BMP_DEBUG_PRINTF(&quot;\n SORRY, PIC IS TOO BIG (<=320)\n&quot;);
return;
}
Lcd_GramScan( 3 );
LCD_OpenWindow(x, y, width, height);
/* 判断是否是24bit真彩色图 */
if(bitInfoHead.biBitCount >= 24)
{
for(i=0;i< height; i++)
{
/* 读取一行bmp的数据到数组pColorData里面 */
#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++) //一行有效信息
{
k = j*3; //一行中第K个像素的起点
red = pColorData[k+2];
green = pColorData[k+1];
blue = pColorData[k];
LCD_WR_Data(RGB24TORGB16(red,green,blue)); //写入LCD-GRAM
}
}
}
else
{
BMP_DEBUG_PRINTF(&quot;SORRY, THIS PIC IS NOT A 24BITS REAL COLOR&quot;);
return ;
}
f_close(&bmpfsrc);
} |