Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, October 8, 2009 3:51:20 AM(UTC)
a.bologni

Groups: Registered
Posts: 17


I have a Kodak scanner i1320 and i use this portion of code to scan image:

            _twain = new TwainSession();
            _twain.Startup(_viewer, "", "", "", "", TwainStartupFlags.None);
            _twain.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(_Twain_AcquirePage);

            TwainCapability twnCap = new TwainCapability();
            twnCap.Information.Type = TwainCapabilityType.ImagePixelType;
            twnCap.Information.ContainerType = TwainContainerType.OneValue;
            twnCap.OneValueCapability.ItemType = TwainItemType.Uni512;
            twnCap.OneValueCapability.Value = Leadtools.Twain.TwainCapabilityValue.PixelTypeRgb;
            _twainSession.SetCapability(twnCap, TwainSetCapabilityMode.Set);

The image that is scanned is in a grey scale and not with color.
My scanner have the ADF, and have 2 sources: the bottom source is "KODAK Scanner: i1310/i1320", the top source is "WIA-KODAK i1320 Scanner".

What can i do for scan a color image?

Thanks

A.
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, October 11, 2009 12:49:57 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

In your code, you are Acquiring the page before setting the capability. That could be the reason you are not scanning in color.
So please try to use your code as follows:
twain = new TwainSession();
_twain.Startup(_viewer, "", "", "", "", TwainStartupFlags.None);

TwainCapability twnCap = new TwainCapability();
twnCap.Information.Type = TwainCapabilityType.ImagePixelType;
twnCap.Information.ContainerType = TwainContainerType.OneValue;
twnCap.OneValueCapability.ItemType = TwainItemType.Int16;
twnCap.OneValueCapability.Value = Leadtools.Twain.TwainCapabilityValue.PixelTypeRgb;
_twainSession.SetCapability(twnCap, TwainSetCapabilityMode.Set);

_twain.AcquirePage += new EventHandler(_Twain_AcquirePage);

Edited by moderator Wednesday, April 13, 2022 8:02:52 AM(UTC)  | Reason: Not specified

 
#3 Posted : Tuesday, October 13, 2009 6:38:57 AM(UTC)
a.bologni

Groups: Registered
Posts: 17


I had hoped in your solution but is not the problem.
This is my complete acquire code:

            RasterCodecs.Startup();

            _codecs = new RasterCodecs();

            _viewer = new RasterImageViewer();

            _twain = new TwainSession();
            _twain.Startup(_viewer, "", "", "", "", TwainStartupFlags.None);

            TwainCapability twnCap = new TwainCapability();
            twnCap.Information.Type = TwainCapabilityType.ImagePixelType;
            twnCap.Information.ContainerType = TwainContainerType.OneValue;
            twnCap.OneValueCapability.ItemType = TwainItemType.Uni512;
            twnCap.OneValueCapability.Value = Leadtools.Twain.TwainCapabilityValue.PixelTypeRgb;
            _twain.SetCapability(twnCap, TwainSetCapabilityMode.Set);

            _twain.AcquirePage += new EventHandler<TwainAcquirePageEventArgs>(_Twain_AcquirePage);

            _twainSource = "WIA-KODAK i1320 Scanner";
            _twain.SelectSource(_twainSource);

            _twain.ShowProgressIndicator(false);

            string imageName = DateTime.Now.ToString("yyyyMMddhhmmss");

            _Ext_ = _Ext_Tif_;

            imageName += _Ext_Tif_;

            _imageLocalPath = Path.Combine(_workDir, imageName);

            _frameCount = 0;

            if (_Ext_ == _Ext_Tif_)
                _imageStream = new FileStream(_imageLocalPath, FileMode.Create);

            _twain.Acquire(TwainUserInterfaceFlags.None);
           
            _imageStream.Close();

            ImageScannerShutdown();


The result is a BW image and not a color image.
What can i do?

Thanks.

A.
 
#4 Posted : Wednesday, October 14, 2009 6:23:19 AM(UTC)

Basel  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

There are at least 2 errors you your code:
1. Your order of execution is still wrong. You are doing this:
- Set pixel type
- Select source
- Acquire
The correct order is:
- Select source first, so that the pixel type will affect that source
- Set pixel type
- Acquire

2. You are using an incorrect constant for the OneValueCapability.ItemType. Instead of TwainItemType.Uni512, it should be TwainItemType.Int16
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.082 seconds.