我无法让我的 Canon Pixma MP150 从 c# 代码扫描彩色扫描。以下代码会生成黑白图像,或者如果我将 6146 的值更改为 2,则会创建灰度图像。我希望能够对代码进行彩色扫描。我知道扫描仪会做彩色图像,因为我可以通过“扫描仪和相机”中的 xp 向导来完成。谁能帮我弄清楚我没有为彩色扫描设置什么值。我能找到的所有文档和示例都只是说要更改 6146 的值。
感谢您抽出时间来阅读!
private void ScanAndSaveOnePage ()
{
WIA.CommonDialog Dialog1 = new WIA.CommonDialogClass();
WIA.DeviceManager DeviceManager1 = new WIA.DeviceManagerClass();
System.Object Object1 = null;
System.Object Object2 = null;
WIA.Device Scanner = null;
Scanner = Dialog1.ShowSelectDevice(WIA.WiaDeviceType.ScannerDeviceType, false, false);
WIA.Item Item1 = Scanner.Items[1];
setItem(Item1, "6146", 1);
setItem(Item1, "6147", 150);
setItem(Item1, "6148", 150);
setItem(Item1, "6151", 150 * 8.5);
setItem(Item1, "6152", 150 * 11);
WIA.ImageFile Image1 = new WIA.ImageFile();
WIA.ImageProcess ImageProcess1 = new WIA.ImageProcess();
Object1 = (Object)"Convert";
ImageProcess1.Filters.Add(ImageProcess1.FilterInfos.get_Item(ref Object1).FilterID, 0);
Object1 = (Object)"FormatID";
Object2 = (Object)WIA.FormatID.wiaFormatBMP;
ImageProcess1.Filters[1].Properties.get_Item(ref Object1).set_Value(ref Object2);
Object1 = null;
Object2 = null;
Image1 = (WIA.ImageFile)Item1.Transfer(WIA.FormatID.wiaFormatBMP);
string DestImagePath = @"C:\test.bmp";
File.Delete(DestImagePath);
Image1.SaveFile(DestImagePath);
}
private void setItem (IItem item, object property, object value)
{
WIA.Property aProperty = item.Properties.get_Item(ref property);
aProperty.set_Value(ref value);
}