WIA: no compression when saving files

筅森魡賤 提交于 2019-12-07 00:08:22

Basically you should add a compression filter before you save your image, in this url you can find a sample of tiff/jpg compression:

http://www.debugging.com/bug/18157

After you have gotten your WIA Image (shown here as the 'image' variable), you apply a filter to adjust quality, before saving, like so:

WIA.ImageProcess myip = new WIA.ImageProcess();  // use to compress jpeg.
myip.Filters.Add(myip.FilterInfos["Convert"].FilterID);
myip.Filters[1].Properties["FormatID"].set_Value(WIA.FormatID.wiaFormatJPEG);
myip.Filters[1].Properties["Quality"].set_Value(jpgQuality);

image = myip.Apply(image);  // apply the filters
image.SaveFile(outputFilename);

In this example, jpgQuality is an int value between 1 and 100. 1 = low quality, 100 = best.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!