当前位置:   article > 正文

C语言编写的数码像框所有代码(jpg.c jpeg.c makefile.sh)_c 语言图片画框

c 语言图片画框
  1. //jpg.c文件中的代码,当前目录下需要创建一个image文件夹,文件中放的都是图片,通过读这个目录(readdir),获取图片名,我发现每次读取image这个文件中的图片
  2. 都是一样的,因而我是按照它读取目录这个顺序一样给这些图片做的特效,而不是随即获取图片来制作特效,另外,这里面我自己添加了通过点击鼠标的左键或右键来切换图片,
  3. 我还想再加一个播放音频的,但是手写这个程序耗时太长,就随便调用了系统中的播放器,但是在纯命令界面是没用的(ctrl+alt+(F1~F6)进入纯命令界面,ctrl+alt+F7
  4. 退出该界面,本人制作的数码特效很简单)
  5. #include <sys/ioctl.h>
  6. #include <sys/mman.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <dirent.h>
  10. #include <unistd.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <linux/fb.h>
  14. #include <fcntl.h>
  15. #include <math.h>
  16. #include <dirent.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #ifndef u_char
  20. #define u_char unsigned char
  21. #endif
  22. struct fb_var_screeninfo fb_var;
  23. int width,height;
  24. int * fb_ptr;
  25. short pic_w,pic_h;
  26. u_char *ptr;
  27. int init_fb()
  28. {
  29. int fb,bpp;
  30. fb = open("/dev/fb0",O_RDWR);
  31. if(fb < 0)
  32. {
  33. printf("Cant open device fb0!\n");
  34. printf("Try:sudo\n");
  35. return -1;
  36. }
  37. ioctl(fb,FBIOGET_VSCREENINFO,&fb_var);
  38. width = fb_var.xres;
  39. height = fb_var.yres;
  40. bpp = fb_var.bits_per_pixel;
  41. printf("Framebuffer: %d * %d %d \n",width,height,bpp);
  42. fb_ptr = mmap(NULL,width*height*bpp/8,PROT_READ|PROT_WRITE,MAP_SHARED,fb,0);
  43. return 0;
  44. }
  45. void readfilename(char *dirname)
  46. {
  47. int i,signal,x,y;
  48. DIR *p = opendir(dirname);
  49. if(p == NULL)
  50. {
  51. printf("open dir error!\n");
  52. return ;
  53. }
  54. struct dirent * pd;
  55. for( i = 0; (pd = readdir(p)) != NULL;)
  56. {
  57. if(pd->d_name[0] == '.') continue;
  58. printf("name: %s\n",pd->d_name);
  59. char file_name[255+4] = {0};
  60. // memset(file_name,0,sizeof(file_name));
  61. strcat(file_name,dirname);
  62. if(strstr(pd->d_name,".jpeg") != NULL || strstr(pd->d_name,".jpg") != NULL)
  63. {
  64. strcat(file_name,pd->d_name);
  65. ptr = (u_char *)decode_jpeg(file_name,&pic_w,&pic_h);
  66. printf("pic_w: %d,pic_h: %d\n",pic_w,pic_h);
  67. signal = readmouse();
  68. system("clear");
  69. if(signal == 9 || signal == 10)
  70. {
  71. if(strstr(pd->d_name,"3.jpg") != NULL)
  72. pic_one();
  73. if(strstr(pd->d_name,"4.jpg") != NULL)
  74. pic_two();
  75. if(strstr(pd->d_name,"1.jpg") != NULL)
  76. pic_three();
  77. if(strstr(pd->d_name,"0.jpg") != NULL)
  78. pic_four();
  79. if(s
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/263391
推荐阅读
相关标签
  

闽ICP备14008679号