主题:jpeg压缩出错
小弟在用libjpeg.lib做图像压缩.但是在压缩的时候出现如下错误:
Unhandled exception in xxx.exe (NTDLL.DLL):0xC0000005:Access Violation
请问这个问题如何解决啊????知道的达人指教一下!小弟在此拜谢!!!!
压缩过程代码如下:
cinfo.err = jpeg_std_error(&jerr);//cinfo和jerr都已经定义申明过了.
jpeg_create_compress(&cinfo);
tempfile = fopen(tempname, "wb");//tempname为临时文件地址
jpeg_stdio_dest(&cinfo, tempfile);
cinfo.image_width = Width;//图像宽
cinfo.image_height = Height;//图像高
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_add_quant_table (&cinfo,0,qtable[0],100,FALSE);
jpeg_add_quant_table (&cinfo,1,qtable[1],100,FALSE);
jpeg_start_compress(&cinfo, TRUE);
int row_stride=linesize;//每行字节数
int dof=dataoff+row_stride*(Height-1);//dataoff为图像数据偏移量
JSAMPROW row_pointer[1];//一行位图
while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = & (ihbitmap->source[dof-(cinfo.next_scanline * row_stride)]);
jpeg_write_scanlines(&cinfo, row_pointer, 1);//这里是出错的位置!!!!!!!!!!!!!!!!!
}
jpeg_finish_compress(&cinfo);
fclose(tempfile);
jpeg_destroy_compress(&cinfo);
Unhandled exception in xxx.exe (NTDLL.DLL):0xC0000005:Access Violation
请问这个问题如何解决啊????知道的达人指教一下!小弟在此拜谢!!!!
压缩过程代码如下:
cinfo.err = jpeg_std_error(&jerr);//cinfo和jerr都已经定义申明过了.
jpeg_create_compress(&cinfo);
tempfile = fopen(tempname, "wb");//tempname为临时文件地址
jpeg_stdio_dest(&cinfo, tempfile);
cinfo.image_width = Width;//图像宽
cinfo.image_height = Height;//图像高
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_add_quant_table (&cinfo,0,qtable[0],100,FALSE);
jpeg_add_quant_table (&cinfo,1,qtable[1],100,FALSE);
jpeg_start_compress(&cinfo, TRUE);
int row_stride=linesize;//每行字节数
int dof=dataoff+row_stride*(Height-1);//dataoff为图像数据偏移量
JSAMPROW row_pointer[1];//一行位图
while (cinfo.next_scanline < cinfo.image_height)
{
row_pointer[0] = & (ihbitmap->source[dof-(cinfo.next_scanline * row_stride)]);
jpeg_write_scanlines(&cinfo, row_pointer, 1);//这里是出错的位置!!!!!!!!!!!!!!!!!
}
jpeg_finish_compress(&cinfo);
fclose(tempfile);
jpeg_destroy_compress(&cinfo);