赞
踩
- //jpg.c文件中的代码,当前目录下需要创建一个image文件夹,文件中放的都是图片,通过读这个目录(readdir),获取图片名,我发现每次读取image这个文件中的图片
- 都是一样的,因而我是按照它读取目录这个顺序一样给这些图片做的特效,而不是随即获取图片来制作特效,另外,这里面我自己添加了通过点击鼠标的左键或右键来切换图片,
- 我还想再加一个播放音频的,但是手写这个程序耗时太长,就随便调用了系统中的播放器,但是在纯命令界面是没用的(ctrl+alt+(F1~F6)进入纯命令界面,ctrl+alt+F7
- 退出该界面,本人制作的数码特效很简单)
- #include <sys/ioctl.h>
- #include <sys/mman.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <dirent.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <linux/fb.h>
- #include <fcntl.h>
- #include <math.h>
- #include <dirent.h>
- #include <stdlib.h>
- #include <string.h>
-
- #ifndef u_char
- #define u_char unsigned char
- #endif
-
- struct fb_var_screeninfo fb_var;
- int width,height;
- int * fb_ptr;
- short pic_w,pic_h;
- u_char *ptr;
-
- int init_fb()
- {
- int fb,bpp;
-
- fb = open("/dev/fb0",O_RDWR);
- if(fb < 0)
- {
- printf("Cant open device fb0!\n");
- printf("Try:sudo\n");
- return -1;
- }
- ioctl(fb,FBIOGET_VSCREENINFO,&fb_var);
- width = fb_var.xres;
- height = fb_var.yres;
- bpp = fb_var.bits_per_pixel;
-
- printf("Framebuffer: %d * %d %d \n",width,height,bpp);
- fb_ptr = mmap(NULL,width*height*bpp/8,PROT_READ|PROT_WRITE,MAP_SHARED,fb,0);
-
- return 0;
- }
-
- void readfilename(char *dirname)
- {
- int i,signal,x,y;
-
- DIR *p = opendir(dirname);
- if(p == NULL)
- {
- printf("open dir error!\n");
- return ;
- }
-
- struct dirent * pd;
-
- for( i = 0; (pd = readdir(p)) != NULL;)
- {
- if(pd->d_name[0] == '.') continue;
- printf("name: %s\n",pd->d_name);
- char file_name[255+4] = {0};
-
- // memset(file_name,0,sizeof(file_name));
- strcat(file_name,dirname);
-
- if(strstr(pd->d_name,".jpeg") != NULL || strstr(pd->d_name,".jpg") != NULL)
- {
- strcat(file_name,pd->d_name);
- ptr = (u_char *)decode_jpeg(file_name,&pic_w,&pic_h);
- printf("pic_w: %d,pic_h: %d\n",pic_w,pic_h);
-
- signal = readmouse();
- system("clear");
- if(signal == 9 || signal == 10)
- {
- if(strstr(pd->d_name,"3.jpg") != NULL)
- pic_one();
- if(strstr(pd->d_name,"4.jpg") != NULL)
- pic_two();
- if(strstr(pd->d_name,"1.jpg") != NULL)
- pic_three();
- if(strstr(pd->d_name,"0.jpg") != NULL)
- pic_four();
- if(s

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。