【问题标题】:WIA. Scan colorful image in Windows XP c#威亚。在 Windows XP c# 中扫描彩色图像
【发布时间】:2011-12-22 15:06:11
【问题描述】:

我尝试在 Windows XP 和 Windows 7 上使用 WIA lib 扫描文档。代码如下:

Device _scannerDevice;
CommonDialog _scannDialog;

if (_scannerDevice != null)
{
    WIA.Item Item = _scannerDevice.Items[1] as WIA.Item;

    WIA.ImageFile wiaImage = null;
    //setting dpi
    Item.Properties["6147"].set_Value(dpi);
    Item.Properties["6148"].set_Value(dpi);
    //setting start coordinates
    Item.Properties["6149"].set_Value(0);
    Item.Properties["6150"].set_Value(0);
    //setting width and height
    Item.Properties["6151"].set_Value(width);
    Item.Properties["6152"].set_Value(height);
    //1 if colorful; 2 if gray
    Item.Properties["6146"].set_Value(1);

    //start scan
    wiaImage = (ImageFile)_scannDialog.ShowTransfer(Item, wiaFormatJPEG, false);
    if (wiaImage.FileData != null)
    {
       WIA.Vector vector = wiaImage.FileData;
       _image = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData()));               
     }
 }

我成功获得图像,但在 Windows XP 上它是不彩色。当我在 Windows 7 上扫描相同的文档时,我收到了 COLORFUL 图像,正如预期的那样。可能我错过了一些财产? 如何在 Windows XP 上获得彩色图像?

注意:我使用 ShowTransfer 方法忽略来自扫描仪的所有窗口,使用此方法我只能看到 ProgressBar。

【问题讨论】:

    标签: c# .net scanning wia


    【解决方案1】:

    尝试显式添加此属性设置器:

    Item.Properties["4104"].set_Value(24); // 24-bit color
    

    【讨论】:

      猜你喜欢
      • 2013-04-09
      • 2018-03-05
      • 2011-09-22
      • 1970-01-01
      • 2021-08-27
      • 1970-01-01
      • 2015-07-09
      • 2019-07-21
      • 1970-01-01
      相关资源
      最近更新 更多