图片播放器(四):图片显示的核心函数

display###############
    fb.c                                         //fb文件
    Makefile

include###############
    fb.h


start.c                                                //最开始的文件

Makefile                                         //主Makefile
Makefile.build

 

重要的结构体数组:

每张图片的数据:

typedef struct _HEADCOLOR
{
   unsigned char scan;
   unsigned char gray;
   unsigned short w;
   unsigned short h;
   unsigned char is565;
   unsigned char rgb;
   const unsigned char *gImage_picture;
}HEADCOLOR; 

scan: 扫描模式 

Bit7: 0:自左至右扫描,1:自右至左扫描。 
Bit6: 0:自顶至底扫描,1:自底至顶扫描。 
Bit5: 0:字节内象素数据从高位到低位排列,1:字节内象素数据从低位到高位排列。 
Bit4: 0:WORD类型高低位字节顺序与PC相同,1:WORD类型高低位字节顺序与PC相反。 
Bit3~2: 保留。 
Bit1~0: [00]水平扫描,[01]垂直扫描,[10]数据水平,字节垂直,[11]数据垂直,字节水平。 


gray: 灰度值 
   灰度值,1:单色,2:四灰,4:十六灰,8:256色,12:4096色,16:16位彩色,24:24位彩色,32:32位彩色。


w: 图像的宽度。

h: 图像的高度。

is565: 在4096色模式下为0表示使用[16bits(WORD)]格式,此时图像数据中每个WORD表示一个象素;为1表示使用[12bits(连续字节流)]格式,此时连续排列的每12Bits代表一个象素。
在16位彩色模式下为0表示R G B颜色分量所占用的位数都为5Bits,为1表示R G B颜色分量所占用的位数分别为5Bits,6Bits,5Bits。
在18位彩色模式下为0表示"6Bits in Low Byte",为1表示"6Bits in High Byte"。
在24位彩色和32位彩色模式下is565无效。

rgb: 描述R G B颜色分量的排列顺序,rgb中每2Bits表示一种颜色分量,[00]表示空白,[01]表示Red,[10]表示Green,[11]表示Blue。

 

需要怎样播放图片:

struct show_picture_set          /*上层要怎样显示图片,和显示哪张图片*/
{
	unsigned int w;  /* 偏移宽 */
	unsigned int h;  /* 偏移高 */
	const char *path;  /* 图片文件名*/
	unsigned char         rotate;  /* 怎样旋转 (绝对不是相对)*/
};

 

每种格式的处理函数集合:

struct format_hand_set  /* 每种格式的处理函数集合 */
{
	char name[8];  /* 图片格式名 */
	void (*fb_show) (struct show_picture_set *set);                         /* 当前图片的显示函数 */
	char (*fb_is) (const char *path);                              /* 判断是否为当前格式的图片 */
	int (*fb_file_to_data) (const        char *path, void *st_pi);	/* 从文件中读取有用数据 */
};

重要宏定义:

#define FORMAT_MAX  1        /* 当前播放器所支持格式的数量 */

/* struct bmp_head_data 的 data_size 的值
 *图片显示 (不是当前图片旋转 180,是绝对而不是相对)
 */
#define ROTATE_FRONT              ('1') /* 正常 */
#define ROTATE_180                ('2') /* 旋转180 */
#define ROTATE_MIRROR_180         ('3') /* 镜像 + 180 旋转*/
#define ROTATE_MIRROR             ('4') /* 镜像 + 180 旋转*/

 

图片处理函数:

总的图片显示函数(fb.c):

/* 总的显示函数 */
char _fb_show(struct show_picture_set *pi_set)
{
	char ret;
	int i;

	for(i = 0; i < FORMAT_MAX; i++)
	{
		ret = format_array[i].fb_is(pi_set->path);
		switch (ret) {
		case 'Y':
			format_array[i].fb_show(pi_set);
			return 0;
		case 'N':
			DERROR("(%s)It's not a [%s] file\n", pi_set->path, format_array[i].name);
			break;
		case 'R':
			DERROR("[%s]: read (%s) fail\n", format_array[i].name, pi_set->path);
			return -2;
		case 'O':
			DERROR("[%s]: open (%s) fail\n", format_array[i].name, pi_set->path);
			return -3;
		}
	}

	DERROR("This file format is not supported");
	return -1;
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值