×
单片机 > 单片机程序设计 > 详情

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

发布时间:2021-06-22 发布时间:
|

功能

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


说明

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


主要代码

1)绘制背景

1
2
3
4
5
6
7
8
9
10
11
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)文字绘制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)字符绘制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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,否则图片颜色是反过来的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 ;
        }
    }
}

效果




『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
STM32中断向量表的位置.重定向