1, 设置LCD光标,
2 ,写入LCD读写数据命令(0x22或0x32),读取返回的16位RGB值,
3,判断所读取值是RGB或BGR统一转换成RGB565,
4,24位bmp存储格式为B,G,R,(。。。)此处BGR565的数据 是高位对齐,如 原来 B=0x35 在此外则必须 B=(0X32)<<3;其他同理
5,读取的X,Y坐标应从最左下角逐行往上开始读取,举个例子:
LCD 240*320, 宽为 240,高为 320; 以宽为 x 轴,以高为y轴, 最左下角坐标为(0,320)==在计算机都是从0开始所以此处坐标为(0,319)
for(y = 319;y != 0xffff;y --)
{
for(x = 0;x < 240;x ++)
{
RGB= LCD_ReadPoint(x,y);
//下面可以把RGB数据进行相应处理
}
}
此处0xffff 是因为定义的y为无符号类型,
6。54个字节的BMP结构部分定义
typedef struct tagBITMAPFILEHEADER
{
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAPFILEHEADER;
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;
SaveBmp(const char* bmpName,unsigned char *imgBuf,int width,int height,int biBitCount)
{
BITMAPFILEHEADER fileHead;
FILE *fp;
BITMAPINFOHEADER head;
int lineByte;
if(!imgBuf)//imgBuf 待存盘的位图数据
return 0;
lineByte = (width * biBitCount/8+3)/4*4;
fp = fopen(bmpName,"wb");
if(fp == 0) return 0;
fileHead.bfType= 0x4d42;
fileHead.bfSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+ lineByte *height;
fileHead.bfReserved1 = 0;
fileHead.bfReserved2 = 0;
fileHead.bfOffBits = 54;
fwrite(&fileHead,sizeof(BITMAPFILEHEADER),1,fp);
head.biBitCount = biBitCount;
head.biClrImportant = 0;
head.biClrUsed = 0;
head.biCompression = 0;
head.biHeight = height;
head.biPlanes =1;
head.biSize = 40;
head.biSizeImage = lineByte *height;
head.biWidth = width;
head.biXPelsPerMeter = 0;
head.biYPelsPerMeter = 0;
fwrite(&head,sizeof(BITMAPINFOHEADER),1,fp);
fwrite(imgBuf,height * lineByte,1,fp);
fclose(fp);
return 1;
}