读取图像文件,进行压缩 所以我正在尝试C++,我将从一些事情开始,我想,简单地压缩图像应该相当简单。
我的代码是:读取图像文件,进行压缩 所以我正在尝试C++,我将从一些事情开始,我想,简单地压缩图像应该相当简单。,c++,libjpeg,C++,Libjpeg,我的代码是: void main(){ struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); FILE* outfile = fopen("/tmp/test.jpeg", "wb"); jpeg_stdio_dest(&ci
void main(){
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
FILE* outfile = fopen("/tmp/test.jpeg", "wb");
jpeg_stdio_dest(&cinfo, outfile);
//cinfo.image_width = xinfo.width;
//cinfo.image_height = xinfo.height;
//cinfo.input_components = 3;
//cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
/*set the quality [0..100] */
jpeg_set_quality (&cinfo, 75, true);
jpeg_start_compress(&cinfo, true);
jpeg_finish_compress(&cinfo);
}
我在另一个网站上做了一些改动
虽然正如你所看到的,Xinfo并不存在,在那个例子中,我发现它是一个屏幕截图库或其他东西
所以我只想给它一个我在硬盘上得到的图像,然后压缩它。我不想让事情变得太难
实际上,图像压缩是一个比较复杂的C++起点。你发现的代码是C小点,但是我看不到代码中的任何C++……好于没有。关于C++,这是新的,所以也许这只是C或什么?任何你可以把链接发送到“其他站点”的例子——也许它会做一些解释,比如说它是什么。您的代码中似乎也有一些重复…添加了它。是的,我注意到我有点失败了,我会解决的。