在 tiny210 下显示 字母 ,汉字,方框, 宋体,图片。

在开发板上显示字母,汉字,方框,宋体等。 我这里大部分都是参考韦东山老师讲的。

这里只是为了测试lcd驱动并且从新总结下。

英文字母和汉字: 利用点阵画点。

画线和画框: 调用画线函数

宋体: 利用freetype 库

图片: 利用libjpeg 压缩jpeg 图片显示。

 

代码如下:

// lcd_test.c 
// 显示 横线 竖线 框 字符 汉字 字体 图像等
#include <sys/mman.h>
#include <stdio.h>
#include "ascii 8_16.h"
#include <linux/fb.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <wchar.h>
#include <string.h>

#include <ft2build.h>
#include FT_FREETYPE_H


#include "jpeglib.h"
#include <setjmp.h>


int fb_fd;
int hzk_fd;
struct stat hzk_stat;
unsigned char *hzk_mem;

unsigned char *fb_mem;
struct fb_var_screeninfo var;	/* Current var */
struct fb_fix_screeninfo fix;	/* Current fix */

int x_res, y_res;
int line_length;
int screen_size;
int pixel_length;


// freetype relattived parameters
FT_Library    library;
FT_Face       face;
FT_GlyphSlot  slot;
FT_Matrix     matrix;                 /* transformation matrix */
FT_Vector     pen;                    /* untransformed origin  */
FT_Error      error;

wchar_t *wtext = L"中国neo";
unsigned int           n ;
 


/* 显示 jpeg 图片相关参数*/
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
FILE * infile;		/* source file */
unsigned char *buffer;		/* Output row buffer */
int row_stride;		/* physical row width in output buffer */
struct my_error_mgr {
  struct jpeg_error_mgr pub;	/* "public" fields */
};



void lcd_clear_display(unsigned int c)
{
	memset(fb_mem , 0 , screen_size);
}
void show_put_pixel(int x ,int y , unsigned int color)
{
	unsigned int *pen_32 = (unsigned int *)(fb_mem + y*line_length + x*pixel_length);
	if(var.bits_per_pixel != 32)
	{
		printf(" sorry ! only support 32 bit\n");
		return ;
	}
	*pen_32 = color ;
}

void lcd_put_line(int x1, int y1 , int x2, int y2 , unsigned int color)
{
	int dx,dy,e;
	dx=x2-x1; 
	dy=y2-y1;
    
	if(dx>=0)
	{
		if(dy >= 0) // dy>&
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值