资源简介
基于gec6818开发板的jpeg,bmp图片轮播显示及jpeg图片的压缩,最好在Linux虚拟机下解压,不然软连接文件会失效,无法找到jpeg库。
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
off_t get_file_size(const char *pathname)
{
struct stat file_stat;
int retval;
retval = stat(pathname &file_stat);
if(retval == -1)
{
perror(“get file size error\n“);
return -1;
}
return file_stat.st_size;
}
int display_format_bmp(unsigned int x_s unsigned int y_s const char *pathname unsigned int *lcd_ptr unsigned int mul)
{
off_t file_size;
FILE *pic_fp;
ssize_t rd_ret;
char *pic_buf;
char file_head[54];
unsigned int bmp_width bmp_height;
unsigned int x_end y_end;
unsigned int x y;
char *draw_ptr;
unsigned int color;
file_size = get_file_size(pathname);
if(file_size == -1)
return -1;
printf(“file_size=%ld\n“ file_size);
pic_buf = malloc(file_size-54);
if(pic_buf == NULL)
{
perror(“alloc pic_buf memory error\n“);
return -1;
}
pic_fp = fopen(pathname “r“);
if(pic_fp == NULL)
{
perror(“open picture error\n“);
return -1;
}
rd_ret = fread(file_head 54 1 pic_fp);
if(ferror(pic_fp))
{
perror(“read picture head error\n“);
return -1;
}
rd_ret = fread(pic_buf file_size-54 1 pic_fp);
if(ferror(pic_fp))
{
perror(“read picture color data error\n“);
return -1;
}
fclose(pic_fp);
/* 宽度 */
bmp_width =file_head[18];
bmp_width|=file_head[19]<<8;
printf(“bmp_width=%d\r\n“bmp_width);
/* 高度 */
bmp_height =file_head[22];
bmp_height|=file_head[23]<<8;
printf(“bmp_height=%d\r\n“bmp_height);
x_end = x_s + bmp_width/mul;
y_end = y_s + bmp_height/mul;
printf(“x_end=%u y_end=%u\n“ x_end y_end);
for(y=y_s; y {
draw_ptr = pic_buf+((y-y_s)*mul*bmp_width*3);
for( x=x_s; x {
if(x<800)
{
color = (*draw_ptr) | (*(draw_ptr+1)<<8) |(*(draw_ptr+2)<<16);
lcd_draw_point(x 479-y color lcd_ptr);
}
draw_ptr += 3*mul;
}
}
free(pic_buf);
return 0;
}
- 上一篇:高等数学浙江省赛试卷及答案2010-2017
- 下一篇:lammps使用手册
相关资源
- winfrom自定义设计器源码
- js俄罗斯方块 小游戏源码
- 操作系统哲学家就餐问题(界面+源码
- 智能家居系统项目 嵌入式
- 东软实训
- VL53L0X 驱动源码
- arm的startup.s解析
- 易语言取程序运行时间模块源码
- 易语言编译原理 易语言循环首尾配对
- delphi源码-检测是否运行了多个程序
- 易语言API定时关机源码
- 易语言小轩定时关机源码
- Delphi时钟助手源码,定时关机、提醒
- delphi源码-实现软件注册机
- 易语言mp3播放器3源码易语言mp3播放器
- 易语言QEHashV3.0源码
- 易语言打开记事本并写入内容源码
- 易语言完美模块化3.0源码易语言报表
- 易语言凡哥记事本V1源码易语言凡哥记
- 易语言屏幕画笔v3源码易语言屏幕画笔
- 易语言拖盘图标操作例程源码
- 易语言动态随机文本加解密源码
- 易语言自定义加解密文本源码
- 易语言字符串加解密源码
- 易语言加解密文本模块源码
- 易语言文本加解密源码
- 易语言极速文本加密解密模块V3.1模块
- 易语言码表文本加解密模块源码
- 易语言加解密例程源码易语言生成随
- 易语言文本加解密例程源码
评论
共有 条评论