大学生
最后登录1970-1-1
在线时间 小时
注册时间2015-3-15
|
大神们,帮我看看这程序,我一直显示不出图片,我检查了几遍都没发现问题
程序为:bsp_bm.c和bsp_bm.h
bsp_bm.c为
#include "bsp_bmp.h"
#include "bsp_ili9341.h"
#include "ff.h"
//#include "bsp_usart1.h"
FATFS bmpfs[2];
FIL bmpfsrc,bmpfdst;
BYTE pColorData[960];
FRESULT bmpres;
#define RGB24TORGB16(R,G,B) ((unsigned short int)((((R)>>3)<<11) | (((G)>>2)<<5) | ((B)>>3)))
void LCD_Show_Bmp(unsigned short int x,unsigned short int y,unsigned char *pic_name)
{
int height,width,l_width;
int i,j,k;
unsigned int read_num;
unsigned char temp_name[20];
BITMAPFILEHEADER bitheader;
BITMAPINFOHEADER bitinfoheader;
BYTE red,green,blue;
WORD filetype;
sprintf((char*)temp_name,"0:%s",pic_name);
f_mount(0,&bmpfs[0]);
bmpres=f_open(&bmpfsrc,(char *)temp_name,FA_OPEN_EXISTING|FA_READ);
if(bmpres ==FR_OK)
{
printf("\r\ngood");
f_read(&bmpfsrc,&filetype,sizeof(WORD),&read_num);
f_read(&bmpfsrc,&bitheader,sizeof(tagBITMAPFILEHEADER),&read_num);
f_read(&bmpfsrc,&bitinfoheader,sizeof(BITMAPINFOHEADER),&read_num);
}
else
{
return;
}
height=bitinfoheader.biHeight;
width =bitinfoheader.biWidth;
l_width=WIDTHBYTES(width*(bitinfoheader.biBitCount));
if(l_width>960)
{
return;
}
LCD_GramScan(3);
LCD_OpenWindows(x,y,width,height);
if(bitinfoheader.biBitCount >=24)
{
printf("\r\ngood1");
for(i=0;i<height;i++)
{
// f_read(&bmpfsrc,pColorData,l_width/2,&read_num);
// f_read(&bmpfsrc,pColorData+l_width/2,l_width/2,&read_num);
f_read(&bmpfsrc,pColorData,l_width,&read_num);
for(j=0;j<width;j++)
{
k=j*3;
red =pColorData[k+2];
green =pColorData[k+1];
blue =pColorData[k];
// printf("0x%x0x%x0x%x",pColorData[k],pColorData[k+1],pColorData[k+2]);
LCD_WR_Data(RGB24TORGB16(red,green,blue));
}
}
}
f_close(&bmpfsrc);
}
bsp_bm.h为
#ifndef __BSP_BMP_H
#define __BSP_BMP_H
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;
#define WIDTHBYTES(bits) (((bits)+31)/32*4)
typedef struct tagBITMAPFILEHEADER
{
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
}BITMAPFILEHEADER,tagBITMAPFILEHEADER;
typedef struct tagBITMAPINFOHEADER
{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
}BITMAPINFOHEADER,tagBITMAPINFOHEADER;
void LCD_Show_Bmp(unsigned short int x,unsigned short int y,unsigned char *pic_name);
#endif
|
-
|