我无法通过c#代码从我的佳能Pixma MP150扫描彩色图像。以下代码会导致黑白图像,如果我将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);
}