电子相册实现滑动解锁、JPG和BMP图片显示 用到的技巧有文件/系统IO函数,双向循环链表,目录检索和BMP,JPG图片显示的函数
源码在压缩包里
int main(int argc, char *argv[])
{
//初始化设备
Lcd_Init();
//显示锁屏界面
Show_bmp(0, 0,"lock.bmp");
usleep(1000);
//显示锁屏**
Show_bmp(100, 370,"**.bmp");
while(1)
{
//获取坐标
get_ts_xy();
Show_bmp(100,370,"frame.bmp");
usleep(10);
//触摸得到x轴变化的坐标,锁屏界面和**的图标交替刷新,达到**移动的效果
Show_bmp(a, 370,"**.bmp");
//判断滑块到达锁屏框最后,松手则跳出循环
if(ts_x2 >= 420&&ts_y2>370&&ts_y2<450)
{
break;
}
}
//在锁屏框最后显示解锁成功的**
Show_bmp(420, 370,&quot;unlock.bmp&quot;);
usleep(500000); //延时0.5秒
printf(&quot;success!!\n&quot;);
/*****************************************************************/
d_list = Create_List();
D_Node *p=NULL;
//播放音乐
system(&quot;madplay faded.mp3 &&quot;);
//检索指定目录里的所有bmp图片,并添加进链表
search_dir(&quot;./pic&quot;);
p=d_list->next;
printf(&quot;It's never too late to learn!\n&quot;);
int flag1;
while(1)
{
//显示解锁后的主页面
Show_bmp(0, 0, &quot;main.bmp&quot;);
get_x1y1();
//循环显示照片
if(x_2>55&&x_2<315&&y_2>390&&y_2<460)
{
flag1 = 0;
while(1)
{
//检测bmp图片并下拉显示bmp图片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0&&flag1 == 0)
{
Show_4_bmp(p->picname);
show_buf1();
printf(&quot;This is bmp\n&quot;);
flag1 = 1;
}
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0)
{
p=p->next;
usleep(1000000);
}
//跳出循环
if(strcmp(&quot;00.bmp&quot;, p->picname+strlen(p->picname)-6) == 0)
{
break;
}
//检测bmp图片并上拉显示bmp图片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0&&flag1 == 1)
{
Show_4_bmp(p->picname);
show_buf2();
printf(&quot;This is bmp\n&quot;);
flag1 = 0;
}
//检测jpg图片并显示jpg图片
if( strcmp(&quot;.jpg&quot;, p->picname + strlen(p->picname)-4) == 0)
{
show_jpg(p->picname);
printf(&quot;This is jpg\n&quot;);
}
usleep(1000000); //延时1秒
p=p->next;
//跳出循环
if(strcmp(&quot;00.bmp&quot;, p->picname+strlen(p->picname)-6) == 0)
{
break;
}
}
}
//滑动显示照片
if(x_2>490&&x_2<750&&y_2>390&&y_2<460)
{
flag1 = 0;
p=d_list->next;
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0)
{
Show_4_bmp(p->picname);
show_buf1();
printf(&quot;This is bmp\n&quot;);
}
if( strcmp(&quot;.jpg&quot;, p->picname + strlen(p->picname)-4) == 0)
{
show_jpg(p->picname);
printf(&quot;This is jpg\n&quot;);
}
while(1)
{
get_x1y1();
get_flag();
//向右滑
if(i == 1)
{
p = p->next;
//向右慢慢显示bmp照片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0)
{
Show_4_bmp(p->picname);
show_buf5();
printf(&quot;This is bmp\n&quot;);
}
//显示jpg图片
if( strcmp(&quot;.jpg&quot;, p->picname + strlen(p->picname)-4) == 0)
{
show_jpg(p->picname);
printf(&quot;This is jpg\n&quot;);
}
if(p == d_list)
{
p = p->next;
}
}
//向左滑
if(i == 2)
{
p = p->prev;
//向左慢慢显示bmp照片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0)
{
Show_4_bmp(p->picname);
show_buf6();
printf(&quot;This is bmp\n&quot;);
}
if( strcmp(&quot;.jpg&quot;, p->picname + strlen(p->picname)-4) == 0)
{
show_jpg(p->picname);
printf(&quot;This is jpg\n&quot;);
}
if(p == d_list)
{
p = p->prev;
}
}
//向上滑
if(i == 3)
{
break;
}
//向下滑
if(i == 4)
{
p=d_list->next;
while(1)
{
//横向百叶窗显示bmp图片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0&&flag1 == 0)
{
Show_4_bmp(p->picname);
show_buf3();
printf(&quot;This is bmp\n&quot;);
flag1 = 1;
}
if(strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0)
{
p = p->next;
usleep(1000000); //延时1秒
}
if(strcmp(&quot;00.bmp&quot;, p->picname+strlen(p->picname)-6) == 0)
{
break;
}
//纵向百叶窗显示bmp图片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0&&flag1 == 1)
{
Show_4_bmp(p->picname);
show_buf4();
printf(&quot;This is bmp\n&quot;);
flag1 = 0;
}
//显示jpg图片
if( strcmp(&quot;.jpg&quot;, p->picname + strlen(p->picname)-4) == 0)
{
show_jpg(p->picname);
printf(&quot;This is jpg\n&quot;);
}
usleep(1000000); //延时1秒
p=p->next;
if(strcmp(&quot;00.bmp&quot;, p->picname+strlen(p->picname)-6) == 0)
{
break;
}
}
}
}
}
if(i == 3)
{
break;
}
/* //判断向上划退出
if(((x_2-x_1)<(y_1-y_2))&&(x_2>x_1)&&(y_2<y_1)) //第一象限
{
printf(&quot;sa yo la la!\n&quot;);
break;
}
if(((x_1-x_2)<(y_1-y_2))&&(x_2<x_1)&&(y_2<y_1)) //第二象限
{
printf(&quot;sa yo la la!\n&quot;);
break;
}*/
}
//音乐停止
printf(&quot;stop!\n&quot;);
system(&quot;killall -9 madplay&quot;);
//居中显示
show_middle_bmp(&quot;05.bmp&quot;);
usleep(300000);
//小惊喜
printf(&quot;suprise!!!!!!!!!!!!!\n&quot;);
p=d_list->prev;
flag1 = 0;
while(1)
{
//显示bmp图片
if( strcmp(&quot;.bmp&quot;, p->picname + strlen(p->picname)-4) == 0)
{
Show_4_bmp(p->picname);
show_buf0();
printf(&quot;This is bmp\n&quot;);
}
usleep(30000);
p = p->prev;
if(p == d_list)
{
flag1++;
p=d_list->prev;
}
if(flag1 == 2)
{
break;
}
}
show_middle_bmp(&quot;bye.bmp&quot;);
//关闭设备
Lcd_Uninit(); |