需要准备:
1.MCU利用LTDC或FMC,驱动RGB屏或MCU屏。
2.Image2Lcd PC软件 百度网盘1iax
3.已经测试过的画点函数,参数为坐标与颜色(即LCD_Fast_DrawPoint)
图片制作:
画点函数是与取模参数对应的,除最大宽高,其他参数需要与下方的配置完全一致。
绘图函数:
说明一下函数的参数,若软件输出图片分辨率为:(x,y),当需要在屏幕的(xstr,ystr)处显示图片,那么xend = xstr+x,yend = ystr + y。这个函数是用来显示一些纯色图片的,前景和背景色写死了。
/****************************************************************************
* 名 称:void LCD_DrawPicture(u16 StartX,u16 StartY,u16 EndX,u16 EndY,u16 *pic)
* 功 能:在指定位置显示一幅单色图
* 入口参数:StartX 行起始座标
* StartY 列起始座标
* EndX 行结束座标
* EndY 列结束座标
pic 图片头指针
* 出口参数:无
* 说 明:
* 调用方法:LCD_DrawPicture(0,0,100,100,(u16*)demo);
****************************************************************************/
void LCD_Draw_Picture(u16 xstr,u16 ystr,u16 xend,u16 yend,u8 *pic) //画图
{
u8 temp,t1;
u16 x_t=xstr,y_t=ystr;//,x=xstr,y=ystr;
u8 *pusMsk = pic;//480000 65536
for(y_t=ystr;y_t<yend;)
{
temp = *pusMsk;
for(t1=0;t1<8;t1++)
{
if(temp&0x80)LCD_Fast_DrawPoint(x_t,y_t,POINT_COLOR);//画实心点
else LCD_Fast_DrawPoint(x_t,y_t,BACK_COLOR); //画空白点(使用背景色)
temp<<=1;
x_t++;
if(x_t>=xend)
{
x_t=xstr;
y_t++;
break;
}
}
pusMsk++;
}
}
示例:
遇到显示乱码不要慌,如果你的画点函数没问题,那一定是取模参数不对,或者画图函数参数不对。
const unsigned char gImage_4[600] = { /* 0X10,0X01,0X00,0X50,0X00,0X3C, */
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0XFF,0XE0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,
0XFF,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0XFE,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X3F,0XFF,0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X7F,0X80,0X3F,
0X80,0X00,0X00,0X00,0X00,0X00,0X00,0XFE,0X00,0X0F,0XE0,0X00,0X00,0X00,0X00,0X00,
0X00,0XF8,0X00,0X03,0XFF,0X80,0X00,0X00,0X00,0X00,0X01,0XF0,0X00,0X01,0XFF,0XE0,
0X00,0X00,0X00,0X00,0X03,0XE0,0X00,0X00,0XFF,0XF8,0X00,0X00,0X00,0X00,0X03,0XC0,
0X00,0X00,0X7F,0XFC,0X00,0X00,0X00,0X00,0X07,0XC0,0X00,0X00,0X00,0XFF,0X00,0X00,
0X00,0X00,0X07,0X80,0X00,0X00,0X00,0X1F,0X00,0X00,0X00,0X00,0X0F,0X80,0X00,0X00,
0X00,0X0F,0X80,0X00,0X00,0X00,0X3F,0X80,0X00,0X00,0X00,0X07,0XC0,0X00,0X00,0X00,
0XFF,0X80,0X00,0X00,0X00,0X03,0XC0,0X00,0X00,0X03,0XFF,0X00,0X00,0X00,0X00,0X03,
0XC0,0X00,0X00,0X07,0XFE,0X00,0X00,0X00,0X00,0X01,0XE0,0X00,0X00,0X0F,0XE0,0X00,
0X00,0X00,0X00,0X01,0XE0,0X00,0X00,0X0F,0X80,0X00,0X00,0X00,0X00,0X01,0XE0,0X00,
0X00,0X1F,0X00,0X00,0X00,0X00,0X00,0X01,0XE0,0X00,0X00,0X1E,0X00,0X00,0X00,0X00,
0X00,0X01,0XE0,0X00,0X00,0X1E,0X00,0X00,0X00,0X00,0X00,0X01,0XE0,0X00,0X00,0X1C,
0X00,0X00,0X00,0X00,0X00,0X01,0XE0,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X00,0X01,
0XE0,0X00,0X00,0X1E,0X00,0X00,0X00,0X00,0X00,0X03,0XC0,0X00,0X00,0X1E,0X00,0X00,
0X00,0X00,0X00,0X03,0XC0,0X00,0X00,0X1F,0X00,0X00,0X00,0X00,0X00,0X07,0XC0,0X00,
0X00,0X0F,0X00,0X00,0X00,0X00,0X00,0X1F,0X80,0X00,0X00,0X0F,0XC0,0X00,0X17,0X80,
0X00,0X3F,0X00,0X00,0X00,0X07,0XF8,0X00,0X7F,0X80,0X00,0XFE,0X00,0X00,0X00,0X03,
0XFF,0X00,0XFF,0X00,0X00,0XFC,0X00,0X00,0X00,0X01,0XFF,0X00,0XFE,0X00,0X00,0XF8,
0X00,0X00,0X00,0X00,0X7E,0X01,0XFC,0X00,0X80,0XE0,0X00,0X00,0X00,0X00,0X00,0X03,
0XF8,0X01,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XF0,0X01,0XC0,0X00,0X00,0X00,
0X00,0X00,0X00,0X07,0XF0,0X03,0XC0,0X00,0X00,0X00,0X00,0X00,0X00,0X07,0XF3,0X03,
0XE0,0X00,0X00,0X00,0X00,0X00,0X00,0X0F,0XFF,0X07,0XE0,0X00,0X00,0X00,0X00,0X00,
0X00,0X01,0XFE,0X07,0XF0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X7C,0X07,0XF0,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X78,0X0F,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0XF0,0X0F,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0XC0,0X0F,0XF8,0X00,0X00,0X00,
0X00,0X00,0X00,0X01,0X80,0X0F,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X00,0X0F,
0XF0,0X00,0X00,0X00,0X00,0X00,0X00,0X06,0X00,0X07,0XF0,0X00,0X00,0X00,0X00,0X00,
0X00,0X04,0X00,0X03,0XC0,0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,};
int main(void)
{
LED_Init(); //LED端口初始化
LCD_Init();
POINT_COLOR=RED;
LCD_Draw_Picture(0,60,80,120,(u8 *)gImage_4);
while(1);
}