没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
这篇文章介绍两个知识点: 数码相册要求介绍、贴出数码相册案例代码、介绍360随身WIFI的驱动移植注
意事项。
任务1: 文件系统本地挂载
下面这是Linux下NFS文件系统服务器端共享目录配置文件的编写案例。
任务2:数码相册项目代码
数码相册功能:
【1】支持两种格式图片显示: bmp、jpg
区分两种图片格式,通过后缀名称区分。
【2】支持触摸屏、按键方式翻页(支持前后翻页)
建立双向链表,调用读取目录的函数(opendir),将目录下所有符合要求的图片加入到链表里。
【3】支持三轴加速度计,实现姿态感应。根据三轴加速度的姿态,调整图片的显示方向。
【4】支持图片的自适应: 居中显示,超大尺寸的图片需要自动缩小到屏幕能够显示的大小。
【5】居中显示。
【6】数码相册需要有状态栏: 当前系统的时间信息,当前图片的名称、数量。
倒车影像、USB摄像头网页视频控制、广告机。
案例代码:
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include "touch_input.h"
#include "key_input.h"
#include "mma7660_input.h"
#include "framebuffer.h"
#include "image_zoom.h"
#include "list.h"
#include "Imagedecoding.h"
struct PHOTOA_LBUM_INFO photo_album_info; /*重要结构*/
/*
函数功能: 处理捕获到的信号
*/
void exit_sighandler(int sig)
{
printf("捕获到信号_%d\n",sig);
exit(0); /*结束进程*/
}
/*
函数功能: 图片类型过滤
函数返回值: 0表示支持,其他值表示不支持
*/
int ImageTypeFiltering(char *name)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
{
/*1. 查找后缀*/
char *jpg_p=strstr(name,".jpg");
char *jpeg_p=strstr(name,".jpeg");
char *bmp_p=strstr(name,".bmp");
char *JPG_p=strstr(name,".JPG");
char *JPEG_p=strstr(name,".JPEG");
char *BMP_p=strstr(name,".BMP");
/*2. 过滤后缀*/
if(jpg_p==NULL&&jpeg_p==NULL&&bmp_p==NULL&&
JPG_p==NULL&&JPEG_p==NULL&&BMP_p==NULL)
{
return -1;
}
/*
123.mp4.mp3 123.c.txt p=strstr("123.c.txt",".c"); p执行
*p=.
*/
/*3. 名称比较,二次过滤*/
int jpg_p_cmp=1;
int jpeg_p_cmp=1;
int bmp_p_cmp=1;
int JPG_p_cmp=1;
int JPEG_p_cmp=1;
int BMP_p_cmp=1;
if(jpg_p)jpg_p_cmp=strcmp(jpg_p,".jpg");
if(jpeg_p)jpeg_p_cmp=strcmp(jpeg_p,".jpeg");
if(bmp_p)bmp_p_cmp=strcmp(bmp_p,".bmp");
if(JPG_p)JPG_p_cmp=strcmp(JPG_p,".JPG");
if(JPEG_p)JPEG_p_cmp=strcmp(JPEG_p,".JPEG");
if(BMP_p)BMP_p_cmp=strcmp(BMP_p,".BMP");
if(jpg_p_cmp!=0&&jpeg_p_cmp!=0&&bmp_p_cmp!=0&&
JPG_p_cmp!=0&&JPEG_p_cmp!=0&&BMP_p_cmp!=0)
{
return -2;
}
return 0;
}
/*
函数功能: 遍历指定的目录,将图片的绝对路径加入到链表
函数参数: 传入目录名称
函数返回值: 负数表示失败, 大于0表示加入到链表里节点的数量
*/
int Traverse_Directory(char *dir_name)
{
int cnt=0;
/*1. 先清空链表*/
Remove_ALL_Node();
/*2. 打开目录*/
DIR *dir=opendir(dir_name);
if(dir==NULL)
{
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
DBUG_PRINTF("%s 目录打开失败!\n",dir_name);
return -1;
}
/*3. 循环遍历目录*/
struct dirent *dir_info=NULL;
struct IMAGE_ListStruct *temp=NULL;
int len;
while(dir_info=readdir(dir))
{
/*过滤图片*/
if(ImageTypeFiltering(dir_info->d_name)!=0)
{
DBUG_PRINTF("不符合要求的文件: %s\n",dir_info->d_name);
continue;
}
cnt++;
//给新节点申请空间
temp=malloc(sizeof(struct IMAGE_ListStruct));
//计算文件名称长度(绝对路径):
len=strlen(dir_name)+strlen(dir_info->d_name)+1;
//给存放文件名称指针申请空间
temp->file_name=malloc(len);
strcpy(temp->file_name,dir_name);
strcat(temp->file_name,dir_info->d_name);
/*4. 添加链表节点*/
AddListNode(ListHead,temp);
}
return cnt;
}
/*
函数功能: 删除链表里所有的节点
*/
int Remove_ALL_Node(void)
{
struct IMAGE_ListStruct *p=ListHead; //保存头地址
struct IMAGE_ListStruct *tmp=NULL;
if(p==NULL) /*头为空就创建一个头*/
{
p=ListHead=CreateListHead(ListHead);
}
if(p->next==NULL)return 0;/*节点为空不需要删除*/
else
{
tmp=p; //保存上一个节点的地址---也就是头的地址,因为链表头不需要删除
p=p->next; /*移动到下一个数据节点*/
tmp->next=NULL; /*指定头的下一个节点为NULL*/
}
while(p!=NULL)
{
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
剩余16页未读,继续阅读
资源评论
DS小龙哥
- 粉丝: 4w+
- 资源: 523
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功