#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define LCD_SEZI 800*480*4
int lcd_fd=-1;
int *lcd_memary;
int open_lcd(char *lcdpath)
{
lcd_fd=open(lcdpath,O_RDWR);
if(lcd_fd==-1)
{
perror("open lcd error");
return -1;
}
}
lcd_memary = (int *)mmap(NULL,LCD_SEZI,PROT_READ|PROT_WRITE,MAP_SHARED,lcd_fd,0);
return lcd_fd;
}
int lcd_draw_bmp(char *pic_path)
{
int ret = -1;
int i = 0,j = 0;
char blue = 0;
char green = 0;
char red = 0;
int color = 0;
char bmp_info_buf[54]={0};
char bmp_data_buf[800*480*4];
char *bmp_data = bmp_data_buf;
int bmp_fd = open(pic_path,O_RDWR);
if(bmp_fd ==-1)
{
perror();
}
ret = read(bmp_fd,bmp_info_buf,54);
if(ret == -1)
{
perror();
}
int bmp_width = bmp_info_buf[18];
bmp_width | = bmp_info_buf[19]<<8;
int bmp_heigth = bmp_info_buf[22];
bmp_heigth | = bmp_info_buf[23]<<8;
int bmp_type = bmp_info_buf[28];
bmp_type | = bmp_info_buf[29]<<8;
ret = read(bmp_fd,bmp_data_buf,800*480*4);
if(ret == -1)
{
perror("read bmp data error");
return -1;
}
for(i=0;i<479;i++)
{
for(j=0;j<800;j++)
{
}
}
}
//int main()
{
int color_buf[800*480] = {0};
int i = 0;
//1、打开lcd
int lcd_fd = open("/dev/fb0", O_RDWR);
if(lcd_fd == -1)
{
perror("open lcd error");
return -1;
}
for(i = 0; i < 800*480; i++)
{
//把颜色值赋给数组中每个元素
color_buf[i] = 0x00ff0000;
}
//2、把颜色数据写到lcd中
int ret = write(lcd_fd, color_buf, 800*480*4);
//3、关闭
close(lcd_fd);
}
//
|