您好,我在将数据写入 jpeg 时遇到了一点问题:
这是代码片段:
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
/* More stuff */
FILE * outfile; /* target file */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
if ((outfile = fopen(filename, "wb+")) == NULL) {
fprintf(stderr, "can't open %s\n", filename);
exit(1);
}
else
printf("File successfully opened\n");
jpeg_stdio_dest(&cinfo, outfile);
cinfo.image_width = img_w;
cinfo.image_height = img_h;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
它在 jpeg_stdio_dest、gdb 输出上给了我一个段错误:
#0 0x00007ffff7855735 in malloc_consolidate () from /usr/lib/libc.so.6
#1 0x00007ffff7856a08 in _int_malloc () from /usr/lib/libc.so.6
#2 0x00007ffff7858cc0 in malloc () from /usr/lib/libc.so.6
#3 0x00007ffff7bb4b17 在?? () 来自 /usr/lib/libjpeg.so.8
#4 0x00007ffff7b9f225 in jpeg_stdio_dest () from /usr/lib/libjpeg.so.8
#5 0x0000000000400f2e in write_jpeg_file (image_buffer=0x608070 "\002\002\002\002\002\002\366\366\366\365\365\365\001\001\001\003\003\003\371\371 \371\367\367\367\362\362\362\361\361\361\002\002\002\003\003\003\373\373\373\373\373\373\001\001\001 \002\002\002",img_h=4,img_w=4,文件名=0x7ffffffffe6d1"lol.jpg",质量=100) 在 jpegapi.c:39
#6 0x0000000000400e1f 在 main (argc=5, argv=0x7ffffffffe2e8) 在 main.c:28
我不知道在哪里搜索,任何帮助表示赞赏