0
我想在C#中使用WIA(Windows图像采集库v2.0)扫描文档/照片,但是当我增加分辨率时,它不会增加分辨率,而是增加图像的宽度和高度,但是分辨率保持不变。 (扫描仪的默认dpi为75 dpi) ImageFile变量始终为96 dpi。C#WIA设置分辨率不会提高分辨率,反而会增加图像的宽度和高度。在C#
例如。 如果在默认情况下为dpi 75,图像的宽度和高度为100,则 如果我将dpi设置为150,则图像的宽度和高度为200. 但生成的ImageFile总是具有96 dpi,无论我设置了什么dpi。
WIA.ImageFile img = null;
WIA.Item Item = WiaDev.Items[1] as WIA.Item;
try
{
Item.Properties.get_Item("4104").set_Value(24);
Item.Properties.get_Item("6146").set_Value(1);
double OrigResolution = Convert.ToDouble(Item.Properties["6147"].get_Value().ToString());
double ResDiff = 0.0;
int width = 0, height = 0;
if (OrigResolution < dpi)
{
ResDiff = 150/OrigResolution;
width = (int)Math.Floor((Convert.ToDouble(Item.Properties["6151"].get_Value().ToString()) * ResDiff));
height = (int)Math.Floor((Convert.ToDouble(Item.Properties["6152"].get_Value().ToString()) * ResDiff));
Item.Properties["6149"].set_Value(0);
Item.Properties["6150"].set_Value(0);
Item.Properties.get_Item("6147").set_Value(dpi.ToString("0.0"));
Item.Properties.get_Item("6148").set_Value(dpi.ToString("0.0"));
Item.Properties["6151"].set_Value(width);
Item.Properties["6152"].set_Value(height);
}
img = (ImageFile)WiaCommonDialog.ShowTransfer(Item, WIA.FormatID.wiaFormatJPEG, false);
img.SaveFile("D:\\Test.jpg");
感谢您的回复,但不工作,结果相同 这里是图片[链接](https://i.imgsafe.org/a1d5b4b4cf.jpg)。 –