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 : Friday, August 10, 2007 12:41:31 PM(UTC)

Kevin B  
Kevin B

Groups: Registered
Posts: 14


Is it true that different scanners support different bit depths (bpp)?

Is it possible to get the bit depths that are supported by a scanner?

I noticed that there is a capability TwainCapabilityType.ImageBitDepth.  This sounds promising but I can't get it to work...  Its returning an EnumerationCapability.  I'm attempting to make sense of the values in the EnumerationCapability but I haven't had any luck yet.  Here's some sample code that I pulled out of the LeadTools documentation for version 15.

TwainCapability twnCap = session.GetCapability( TwainCapabilityType.ImageBitDepth, TwainGetCapabilityMode.GetValues );
for ( int i = 0; i < twnCap.EnumerationCapability.Count; i++ )
{
  TwainCapabilityValue capVal = (TwainCapabilityValue)twnCap.EnumerationCapability.GetValue( i );
  string msg = String.Format( "Capability Value({0}) = {1}", i, capVal );
  MessageBox.Show( msg );
}

This code blows up at the converstion of GetValue() to (TwainCapabilityValue)...  Again, I copied that line of code directly from the documentation.  Am I missing something?

Is this even the right way to go about finding the supported bpp of the scanner?

Note:
It is returning an EnumerationCapability.
Any typos up there weren't in my actual code file.  I had to retype it because I couldn't copy and paste into this web-editor.

Thanks,
Kevin Berridge
 

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 : Monday, August 13, 2007 7:50:49 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Hello,

The cast is not quite right because multiple members of the TwainCapabilityValue enumeration have similar values. This means simply check the returned value without casting, or cast it to the (short) type to get the numbers that correspond to the supported bits per pixel.
+----+
for (int i = 0; i < twnCap.EnumerationCapability.Count; i++)
{
Object MyObj = twnCap.EnumerationCapability.GetValue(i);
short capVal = (short)MyObj;
}
+----+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, August 13, 2007 10:51:04 AM(UTC)

Kevin B  
Kevin B

Groups: Registered
Posts: 14


Thanks for your reply.

I updated my code as you suggested casting the result of GetValue(i) to a short.

However, this mechanism still doesn't seem to be doing what I'd expect.  First off, twnCap.EnumerationCapability.Count is 1, and the value of GetValue(0) is also 1.  This would suggest that the scanner only supports 1 bpp.  Of course, I know this isn't true.

Am I still missing something?  Is there somewhere I should look to find the answer to these kinds of questions?

I'm trying to create a method like this: int[] GetSupportedBpp( TwainSession session ); to return all the bpp values the scanner supports.

Thanks,
Kevin Berridge
 
#4 Posted : Tuesday, August 14, 2007 10:13:34 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Hello,

The capability TwainCapabilityType.ImageBitDepth (ICAP_BITDEPTH) depends on the selected Pixel type (TwainCapabilityType.ImagePixelType or ICAP_PIXELTYPE).
For example, if the selected pixel type it TWPT_BW (Black and white), the TwainCapabilityType.ImageBitDepth returns only 1 value, which is 1.
 
You can check the current value of the BITDEPTH of your scanner by testing the ICAP_BITDEPTH capability using the standard Twain test utility from the Twain Working Group. This program is called Twacker and you can get it from here: http://www.twain.org/devfiles/twack.zip

Also, for more information about the ICAP_BITDEPTH and ICAP_PIXELTYPE capabilities, please refer to the Twain specification (http://www.twain.org/docs/TWAIN19.pdf).
 
Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Friday, August 17, 2007 9:05:20 AM(UTC)

Kevin B  
Kevin B

Groups: Registered
Posts: 14


For anyone else trying to accomplish this, here's how you do it:

Getting a list of all the bpps supported by the scanner

Get all the PixelTypes supported by the scanner (ImagePixelType, GetValues).

for each pixel type, pt
    set the scanner's PixelType to pt
    get all BitDepths (ImageBitDepth, GetValues).
    for each bit depth, bd
       if ( bd is not already in our list )
           add bd to list of supported bitdepths

Hope this helps,
Kevin Berridge



 
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.062 seconds.