zoukankan      html  css  js  c++  java
  • 【ARM】2440裸机系列-图片显示

    功能

       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 ;
            }
        }
    }

    效果

  • 相关阅读:
    APK Multi-Tool强大的APK反编译工具终极教程
    Android中Intent组件详解 .
    Android游戏开发之旅 View类详解
    深入理解Android中View
    SQLite学习手册(数据表和视图)
    转)sqlite 数据类型
    (转)SQLite内置函数
    Android权限Uri.parse的几种用法(转载)
    android中与SQLite数据库相关的类
    JDK核心包学习
  • 原文地址:https://www.cnblogs.com/lcw/p/3159410.html
Copyright © 2011-2022 走看看