set area to scan

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Moderator: Alex

Post Reply
quicoli
Posts: 5
Joined: Thu Nov 24, 2011 3:46 pm

set area to scan

Post by quicoli » Sat May 05, 2012 6:41 am

Hi friends!

I'm trying to set area size for scanning, just like demos does, but I'm getting a full page scan. What can be wrong?

Code: Select all

 _device.PixelType = PixelType.BW;
 _device.BitDepth = 1;
 _device.Resolution = new Resolution(200, 200, UnitOfMeasure.Pixels);
 _device.ShowIndicators = false;
 var l1 = _device.ImageLayout.Get();
 _device.ImageLayout.Set(0, 0, l1.Width, l1.Height/2);
And here is my scanner properties
Fabricante: Hewlett-Packard
Família de produto: All-in-One
Nome do produto: HP Photosmart C4700 TWAIN
Versão do drive TWAIN: 1.9
Compatível com TWAIN 2.0: False
Mesa de alimentação presente: True
Alimentador automático presente: False

Recurso: Id=1, Name=XferCount
Modo: Get, Set, GetDefault, Reset
Valor atual: -1

Recurso: Id=256, Name=ICompression
Modo: Get, GetDefault
Valor atual: None
Valores suportados: None Jpeg Lzw

Recurso: Id=257, Name=IPixelType
Modo: Get, Set, GetDefault, Reset
Valor atual: RGB
Valores suportados: BW Gray RGB Palette

Recurso: Id=258, Name=IUnits
Modo: Get, Set, GetDefault, Reset
Valor atual: Inches
Valores suportados: Inches Centimeters Points Pixels

Recurso: Id=259, Name=IXferMech
Modo: Get, Set, GetDefault, Reset
Valor atual: Memory
Valores suportados: Native Memory File

Recurso: Id=4098, Name=FeederEnabled
Modo: Get, Set, GetDefault, Reset
Valor atual: False

Recurso: Id=4101, Name=SupportedCaps
Modo: Get
Valores suportados: SupportedCaps UIControllable XferCount IBitDepth IBitOrder ICompression IImageFileFormat IPhysicalWidth IPhysicalHeight IPixelFlavor IPixelType IPlanarChunky IUnits IXferMech IXResolution IYResolution IXScaling IYScaling DeviceOnline Indicators EnableDsUiOnly IThreshold AutoFeed FeederEnabled FeederLoaded IGamma Duplex DuplexEnabled IBrightness IContrast PaperDetectable IAutoBright IBitDepthReduction

Recurso: Id=4103, Name=AutoFeed
Modo: Get
Valor atual: True

Recurso: Id=4107, Name=Indicators
Modo: Get, Set, GetDefault, Reset
Valor atual: True

Recurso: Id=4109, Name=PaperDetectable
Modo: Get, GetDefault
Valor atual: True

Recurso: Id=4110, Name=UIControllable
Modo: Get
Valor atual: True

Recurso: Id=4111, Name=DeviceOnline
Modo: Get
Valor atual: True

Recurso: Id=4115, Name=DuplexEnabled
Modo: Get, Set, GetDefault, Reset
Valor atual: False

Recurso: Id=4116, Name=EnableDsUiOnly
Modo: Get, GetDefault
Valor atual: False

Recurso: Id=4352, Name=IAutoBright
Modo: Get, Set, GetDefault, Reset
Valor atual: False

Recurso: Id=4353, Name=IBrightness
Modo: Get, Set, GetDefault, Reset
Valor atual: 0
Valor padrão: 0

Recurso: Id=4355, Name=IContrast
Modo: Get, Set, GetDefault, Reset
Valor atual: 0
Valor padrão: 0

Recurso: Id=4360, Name=IGamma
Modo: Get, Set, GetDefault, Reset
Valor atual: 2,199997

Recurso: Id=4364, Name=IImageFileFormat
Modo: Get, Set, GetDefault, Reset
Valor atual: Bmp
Valores suportados: Tiff Bmp Jpeg

Recurso: Id=4369, Name=IPhysicalWidth
Modo: Get
Valor atual: 8,5

Recurso: Id=4370, Name=IPhysicalHeight
Modo: Get
Valor atual: 11,68999

Recurso: Id=4376, Name=IXResolution
Modo: Get, Set, GetDefault, Reset
Valor atual: 200
Valor padrão: 200

Recurso: Id=4377, Name=IYResolution
Modo: Get, Set, GetDefault, Reset
Valor atual: 200
Valor padrão: 200
Recurso: Id=4380, Name=IBitOrder
Modo: Get, Set, GetDefault, Reset
Valor atual: 1
Valor padrão: 1
Valores suportados: 0 1

Recurso: Id=4383, Name=IPixelFlavor
Modo: Get, Set, GetDefault, Reset
Valor atual: Chocolate
Valores suportados: Chocolate Vanilla

Recurso: Id=4384, Name=IPlanarChunky
Modo: Get, GetDefault
Valor atual: 0
Valor padrão: 0
Valores suportados: 0

Recurso: Id=4387, Name=IThreshold
Modo: Get, Set, GetDefault, Reset
Valor atual: 0
Valor padrão: 0

Recurso: Id=4388, Name=IXScaling
Modo: Get, Set, GetDefault, Reset
Valor atual: 1
Valor padrão: 1
Valores suportados: 0,09999084 0,1999817 0,2999725 0,3999634 0,4999542 0,5999451 0,6999359 0,7999268 0,8999176 0,9999084 1,099899 1,19989 1,299881 1,399872 1,499863 1,599854 1,699844 1,799835 1,899826 1,999817 2,099808 2,199799 2,299789 2,39978 2,499771 2,599762 2,699753 2,799744 2,899734 2,999725 3,099716 3,199707 3,299698 3,399689 3,49968 3,59967 3,699661 3,799652 3,899643 3,999634 4,099625 4,199615 4,299606 4,399597 4,499588 4,599579 4,69957 4,799561 4,899551 4,999542 5,099533 5,199524 5,299515 5,399506 5,499496 5,599487 5,699478 5,799469 5,89946 5,999451 6

Recurso: Id=4389, Name=IYScaling
Modo: Get, Set, GetDefault, Reset
Valor atual: 1
Valor padrão: 1
Valores suportados: 0,09999084 0,1999817 0,2999725 0,3999634 0,4999542 0,5999451 0,6999359 0,7999268 0,8999176 0,9999084 1,099899 1,19989 1,299881 1,399872 1,499863 1,599854 1,699844 1,799835 1,899826 1,999817 2,099808 2,199799 2,299789 2,39978 2,499771 2,599762 2,699753 2,799744 2,899734 2,999725 3,099716 3,199707 3,299698 3,399689 3,49968 3,59967 3,699661 3,799652 3,899643 3,999634 4,099625 4,199615 4,299606 4,399597 4,499588 4,599579 4,69957 4,799561 4,899551 4,999542 5,099533 5,199524 5,299515 5,399506 5,499496 5,599487 5,699478 5,799469 5,89946 5,999451 6

Recurso: Id=4395, Name=IBitDepth
Modo: Get, Set, GetDefault, Reset
Valor atual: 8
Valor padrão: 8
Valores suportados: 1 8 16

Recurso: Id=4396, Name=IBitDepthReduction
Modo: Get, Set, GetDefault, Reset
Valor atual: Threshold
Valores suportados: Threshold Halftones

Alex
Site Admin
Posts: 1461
Joined: Thu Jul 10, 2008 2:21 pm

Re: set area to scan

Post by Alex » Sat May 05, 2012 11:50 am

Hello,

I think you set a wrong resolution value. Are you sure you need set the resolution in pixels?

Please try to use this code:

Code: Select all

_device.ShowIndicators = false;

_device.PixelType = PixelType.BW;
_device.BitDepth = 1;
_device.UnitOfMeasure = UnitOfMeasure.Inches;
_device.Resolution = new Resolution(200, 200, UnitOfMeasure.Inches);
var l1 = _device.ImageLayout.Get();
_device.ImageLayout.Set(0, 0, l1.Width, l1.Height/2);
Best regards, Alexander

quicoli
Posts: 5
Joined: Thu Nov 24, 2011 3:46 pm

Re: set area to scan

Post by quicoli » Fri May 11, 2012 5:13 am

Friend Alex,

I did as you said, but it didnt work :(

Maybe my scanner driver is not compatible?

My scanner is not only a scanner, it is a scanner + printer model.


thanks

Alex
Site Admin
Posts: 1461
Joined: Thu Jul 10, 2008 2:21 pm

Re: set area to scan

Post by Alex » Mon May 14, 2012 6:17 pm

Hello,

Unfortunately, most of TWAIN drivers for HP's multi-functional devices do not allow to set the image layout.

Try to use WIA driver of your device.

Best regards, Alexander

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests