📄 mkjpghdr.c
字号:
/* * mkjpghdr.c * * jpg_hdr.dat甫 佬绢 ncplus_jpghdr.h 庆歹 颇老肺 函券茄促. */#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#define DEF_JPEG_HDR_SIZE 607#define DEF_JPEG_READ_FILE "jpg_hdr.dat"#define DEF_JPEG_WRITE_FILE "ncplus_jpghdr.h"int main(int argc, char *argv[]){ char readfile[256]; char writefile[256]; unsigned char *jpg_hdr; //char *buf; int hdr_size; /* jpeg header size */ int fd; /* file descriptor */ int i; if (argc == 1) { /* readfile = DEF_JPEG_READ_FILE; writefile = DEF_JPEG_WRITE_FILE; */ strncpy(readfile, DEF_JPEG_READ_FILE, 256); strncpy(writefile, DEF_JPEG_WRITE_FILE, 256); hdr_size = DEF_JPEG_HDR_SIZE; } else if (argc == 4) { strncpy(readfile, argv[1], 256); strncpy(writefile, argv[2], 256); hdr_size = atoi(argv[3]); } else { printf ("Usage: %s [read file] [write file] [jpeg header size]\n", argv[0]); exit(1); } printf("read file name : %s\n", readfile); printf("write file name : %s\n", writefile); printf("jpeg header size : %d\n", hdr_size); jpg_hdr = (char *)malloc(hdr_size); if (jpg_hdr == NULL) { fprintf(stderr, "malloc"); exit(1); } memset(jpg_hdr, 0, hdr_size); fd = open(readfile, O_RDONLY); if (fd < 0) { fprintf(stderr, "open"); exit(1); } read(fd, jpg_hdr, hdr_size); close(fd); printf("jpeg_hdr[%d] = {\n", hdr_size); for (i = 0; i < hdr_size; i++) { printf("0x%02x, ", jpg_hdr[i]); if ((i+1)%8 == 0) printf("\n"); } printf("\b\b"); printf("};\n"); free(jpg_hdr); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -