您的位置:首页 > 其它

【ARM】2440裸机系列-图片显示

2013-06-27 17:38 323 查看
功能

LCD显示字汉字,字符和图片

说明

汉字,字符和图片需要用相应的取模软件得到相应的c文件,然后包含到工程中

主要代码

1)绘制背景

void Brush_ U32  c)
{
int x,y ;
for( y = 0 ; y < LCD_HEIGHT ; y++ )
{
for( x = 0 ; x < LCD_WIDTH ; x++ )
{
LCD_BUFFER[y][x] = c ;
}
}
}


2)文字绘制

void Draw_Text16(U32 x,U32 y,U32 color,const unsigned char ch[])
{
unsigned short int i,j;
unsigned char mask,buffer;
for(i=0;i<16;i++)
{
mask=0x80;                       //掩码
buffer=ch[i*2];                  //提取一行的第一个字节
for(j=0;j<8;j++)
{
if(buffer&mask)
{
PutPixel(x+j,y+i,color); //为笔画上色
}
mask=mask>>1;
}
mask=0x80;                      //掩码
buffer=ch[i*2+1];                //提取一行的第二个字节
for(j=0;j<8;j++)
{
if(buffer&mask)
{
PutPixel(x+j+8,y+i,color); //为笔画上色
}
mask=mask>>1;
}
}
}


3)字符绘制

void Draw_ASCII(U32 x,U32 y,U32 color,const unsigned char ch[])
{
unsigned short int i,j;
unsigned char mask,buffer;
for(i=0;i<16;i++)
{
mask=0x80;
buffer=ch[i];
for(j=0;j<8;j++)
{
if(buffer&mask)
{
PutPixel(x+j,y+i,color);
}
mask=mask>>1;
}
}
}


4)图片绘制

<注意>用取模软件对图片进行取模后得到的c源文件中,需要自己进行define WIN32,否则图片颜色是反过来的

void Paint_Bmp(int x0,int y0,int h,int l,const unsigned char bmp[])
{
int x,y;
U32 c;
int p = 0;

for( y = y0 ; y < l ; y++ )
{
for( x = x0 ; x < h ; x++ )
{
c = bmp[p+1] | (bmp[p]<<8) ;
if ( ( (x0+x) < LCD_WIDTH) && ( (y0+y) < LCD_HEIGHT) )
LCD_BUFFER[y0+y][x0+x] = c ;

p = p + 2 ;
}
}
}


效果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐