Linux C语言实现把微信Image的dat文件转成png图片

[复制链接]
发表于 2026-1-12 03:51:52 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
  1. #include <stdio.h>
  2. #include <dirent.h>
  3. #include <errno.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7. #include <unistd.h>
  8. #include <signal.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #define BUFFER_SIZE 1024
  12. void open_and_display_file(const char *filepath, const char *dir)
  13. {
  14.     unsigned char Decode = 0;
  15.     static int image_id = 0;
  16.     unsigned char imagePath[PATH_MAX] = {0};
  17.     unsigned char buffer[BUFFER_SIZE] = {0};
  18.     FILE *imageFp = NULL;
  19.     FILE *file = NULL;
  20.     int read_len = 0;
  21.     int write_len = 0;
  22.     sprintf(imagePath, "%s/%d.png", dir, image_id);
  23.     image_id++;
  24.     file = fopen(filepath, "r");
  25.     if (file == NULL)
  26.     {
  27.         perror("无法打开文件:");
  28.         return;
  29.     }
  30.     imageFp = fopen(imagePath, "wb+");
  31.     if (imageFp == NULL)
  32.     {
  33.         perror("无法打开文件:");
  34.         return;
  35.     }
  36.     ftruncate(fileno(imageFp), 0);
  37.     fread(buffer, 1, 2, file);
  38.     i
复制代码
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表