Question

I try to scan documents with WIA lib on Windows XP and on Windows 7. Here is code:

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()));               
     }
 }

I get image successfuly, but on Windows XP it's NOT COLORFUL. When I scan same document on Windows 7, I receive COLORFUL image, as expected. May be I missed some Property? How to get colorful image on Windows XP?

NOTE: I use ShowTransfer method, to ignore all windows from scanner, with this method I see only ProgressBar.

Was it helpful?

Solution

Try adding this property setter explicitly:

Item.Properties["4104"].set_Value(24); // 24-bit color
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top