大学生
最后登录1970-1-1
在线时间 小时
注册时间2015-7-30
|
我把SD卡里的BMP图片数据读出来,存放在外部的FLASH里,然后从外部FLASH里读出显示,显示不出来,用串口打印出数据是正确的喔,这是为什么呢?
void Lcd_show_bmp(unsigned short int x, unsigned short int y,unsigned char *pic_name)
{
int i, j, k=0;
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");
/* ¶áè¡Îļtí·DÅÏ¢ ὸö×Ö½ú*/
//f_read(&bmpfsrc,&fileType,sizeof(WORD),&read_num);
SPI_FLASH_BufferRead((u8*)&fileType, 0, sizeof(WORD)); /* ÅD¶ÏêÇ2»êÇbmpÎļt "BM"*/
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);
SPI_FLASH_BufferRead((u8*)&bitHead, sizeof(WORD), sizeof(tagBITMAPFILEHEADER));
showBmpHead(&bitHead);
//f_read(&bmpfsrc,&bitInfoHead,sizeof(BITMAPINFOHEADER),&read_num);
// showBmpInforHead(&bitInfoHead);
SPI_FLASH_BufferRead((u8*)&bitInfoHead, sizeof(WORD)+sizeof(tagBITMAPFILEHEADER), sizeof(BITMAPINFOHEADER));
showBmpInforHead(&bitInfoHead);
//}
//else
//{
//BMP_DEBUG_PRINTF("file open fail!\r\n");
// return;
//}
/*-------------------------------------------------------------------------------------------------------*/
//SPI_FLASH_BufferRead((u8*)&bitInfoHead, sizeof(tagBITMAPFILEHEADER)+sizeof(WORD), sizeof(BITMAPINFOHEADER));
width = bitInfoHead.biWidth;
height = bitInfoHead.biHeight;
l_width = WIDTHBYTES(width* bitInfoHead.biBitCount);
//if(l_width > 960)
//{
BMP_DEBUG_PRINTF("\n SORRY, PIC IS TOO BIG (<=320)%d\n",l_width);
//return;
//}
Lcd_GramScan( 3 );
LCD_OpenWindow(x, y, width, height);
//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
SPI_FLASH_BufferRead(pColorData, (sizeof(WORD)+sizeof(tagBITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+l_width*i), l_width);
for(j=0;j<l_width;j++)
printf("%c",pColorData[j]);
//BMP_DEBUG_PRINTF("\n SORRY, PIC IS TOO BIG (<=320)%d\n",l_width);
//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
//{
//BMP_DEBUG_PRINTF("SORRY, THIS PIC IS NOT A 24BITS REAL COLOR");
// return ;
//}
//f_close(&bmpfsrc);
}
|
-
|