Platforms to show: All Mac Windows Linux Cross-Platform

Back to TwainMBS class.

TwainMBS.Acquire(modal as boolean = false, showUI as boolean = true) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Acquires a new picture.

Lasterror is set.
Plugin asks for asynchronously operation, so this function returns nil and success in lasterror.
If data source must be used with modal UI, this function returns with picture.

Modal can be true to ask for modal dialog. Seems to be only supported on Mac.

TwainMBS.AllDevices as TwainIdentityMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Returns array with all devices.
Example
dim twain as TwainMBS // your twain object
dim devices() as TwainIdentityMBS = twain.AllDevices
dim found as Boolean
dim NameToFind as string = "MyScanner123"

for each device as TwainIdentityMBS in devices

if device.ProductName = NameToFind then
found = true

// lets use this one
twain.SelectDS(device)

if twain.Lasterror <> 0 then
MsgBox "Failed to select "+device.ProductName
else
'MsgBox "OK"
exit
end if
end if
next

if not found then
MsgBox "No scanner found named: "+NameToFind
end if

TwainMBS.AppIdentity as TwainIdentityMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Queries app identity.

That's the identity the plugin used to register with twain library.

TwainMBS.CanBW as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Whether device supports black and white pixel type.

Lasterror is set.

TwainMBS.CanGray as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Whether device supports gray pixel type.

Lasterror is set.

TwainMBS.CanPalette as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Whether current device supports palette pixel type.

Lasterror is set.

TwainMBS.CanRGB as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Whether current device supports RGB pixel type.

Lasterror is set.

TwainMBS.CloseDS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Close data source.

Lasterror is set.

Some examples using this method:

TwainMBS.CloseDSM

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Closes the data source manager.

Lasterror is set.

TwainMBS.Constructor(Country as Integer, Language as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Initializes Twain engine with given localization.

Lasterror is set.

TwainMBS.DefaultDevice as TwainIdentityMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
The default device.

(Read and Write computed property)

Some examples using this property:

TwainMBS.DisableDS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Diables data source.

Lasterror is set.

Some examples using this method:

TwainMBS.DontUnload

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.5 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Informs the plugin to not unload the twain library.

This avoids a crash for some people.

TwainMBS.DSIdentity as TwainIdentityMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Queries the details on the data source.

Lasterror is set.

Some examples using this method:

TwainMBS.GetEnumerationCapability(ID as Integer, byref ItemType as Integer, byref Count as Integer, byref CurrentIndex as Integer, byref DefaultIndex as Integer) as Integer()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Queries an enum capability.
Example
dim t as TwainMBS // your twain object

// check supported sizes

const ICAP_SUPPORTEDSIZES = &h1122
dim type5 as Integer
dim EnumCount as Integer = 0
dim EnumItemType as Integer = 0
dim EnumCurrentIndex as Integer = 0
dim EnumDefaultIndex as Integer = 0
dim EnumValues() as Integer = t.GetEnumerationCapability(ICAP_SUPPORTEDSIZES, EnumItemType, EnumCount, EnumCurrentIndex, EnumDefaultIndex)
dim e5 as Integer = t.Lasterror
dim c5 as Integer = t.ConditionCode

Please review Twain Documentation for details.
Please open data source before via OpenDS method.
This should work fine for all integer enum types like boolean, 8, 16 or 32 bit integers.
Sets lasterror and condition code.
(if lasterror is 1 and condition code is 13, the capability is not supported)

TwainMBS.GetIntegerCapability(ID as Integer, byref Type as Integer) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Queries an integer capability.
Example
dim t as TwainMBS // your twain object

t.OpenDS

if t.Lasterror <> 0 then
MsgBox "Failed to open device: "+str(t.Lasterror)
Return
end if

const CAP_FEEDERENABLED = &h1002
const CAP_FEEDERLOADED = &h1003
const TWRC_FAILURE = 1
const TWCC_CAPUNSUPPORTED = 13

// query before
dim type1 as Integer
dim n1 as Integer = t.GetIntegerCapability(CAP_FEEDERENABLED, type1)
dim e1 as Integer = t.Lasterror
dim c1 as Integer = t.ConditionCode

// set on
t.SetBoolCapability CAP_FEEDERENABLED, true
dim e2 as Integer = t.Lasterror
dim c2 as Integer = t.ConditionCode

// query after
dim type3 as Integer
dim n3 as Integer = t.GetIntegerCapability(CAP_FEEDERENABLED, type3)
dim e3 as Integer = t.Lasterror
dim c3 as Integer = t.ConditionCode

// now query loaded?
dim type4 as Integer
dim n4 as Integer = t.GetIntegerCapability(CAP_FEEDERLOADED, type4)
dim e4 as Integer = t.Lasterror
dim c4 as Integer = t.ConditionCode

if e4 = TWRC_FAILURE AND c4 = TWCC_CAPUNSUPPORTED then
// not supported!
Break
end if

Please review Twain Documentation for details.
Please open data source before via OpenDS method.
This should work fine for all integer types like boolean, 8, 16 or 32 bit integers.
Sets lasterror and condition code.
(if lasterror is 1 and condition code is 13, the capability is not supported)

TwainMBS.ImageInfo as TwainImageInfoMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Queries information about current image.

Lasterror is set.

TwainMBS.Imagelayout as TwainImageLayoutMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Get/Set the image layout.

Lasterror is set. DataSource must be open.
(Read and Write computed property)

TwainMBS.IsDSEnabled as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Whether data source is enabled.

TwainMBS.OpenDS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Opens the data source.

TwainMBS.OpenDSM

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Opens Data source Manager.

Lasterror is set.

TwainMBS.ProcessEvents

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.5 ❌ No ✅ Yes ❌ No ❌ No Desktop only
Process events in plugin.

Only for Windows needed for some Twain drivers. You call it after you run Acquire to let the plugin wait for the events to start the transfer.
When transfer is ready or dialog is cancelled, this method ends.
On Mac OS X or Linux this method does nothing so it's no problem calling it.

Some examples using this method:

TwainMBS.SelectDS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Queries dialog to ask the user to select a data source.

Lasterror is set.

See also:

Some examples using this method:

TwainMBS.SelectDS(device as TwainIdentityMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Selects the given device without dialog.
Example
dim twain as TwainMBS // your twain object
dim devices() as TwainIdentityMBS = twain.AllDevices
dim found as Boolean
dim NameToFind as string = "MyScanner123"

for each device as TwainIdentityMBS in devices

if device.ProductName = NameToFind then
found = true

// lets use this one
twain.SelectDS(device)

if twain.Lasterror <> 0 then
MsgBox "Failed to select "+device.ProductName
else
'MsgBox "OK"
exit
end if
end if
next

if not found then
MsgBox "No scanner found named: "+NameToFind
end if

Lasterror is set.

See also:

TwainMBS.SetBoolCapability(ID as Integer, Value as Boolean)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Sets a capability with boolean.
Example
dim t as TwainMBS // your twain object

t.OpenDS

if t.Lasterror <> 0 then
MsgBox "Failed to open device: "+str(t.Lasterror)
Return
end if

const CAP_FEEDERENABLED = &h1002
const CAP_FEEDERLOADED = &h1003
const TWRC_FAILURE = 1
const TWCC_CAPUNSUPPORTED = 13

// query before
dim type1 as Integer
dim n1 as Integer = t.GetIntegerCapability(CAP_FEEDERENABLED, type1)
dim e1 as Integer = t.Lasterror
dim c1 as Integer = t.ConditionCode

// set on
t.SetBoolCapability CAP_FEEDERENABLED, true
dim e2 as Integer = t.Lasterror
dim c2 as Integer = t.ConditionCode

// query after
dim type3 as Integer
dim n3 as Integer = t.GetIntegerCapability(CAP_FEEDERENABLED, type3)
dim e3 as Integer = t.Lasterror
dim c3 as Integer = t.ConditionCode

// now query loaded?
dim type4 as Integer
dim n4 as Integer = t.GetIntegerCapability(CAP_FEEDERLOADED, type4)
dim e4 as Integer = t.Lasterror
dim c4 as Integer = t.ConditionCode

if e4 = TWRC_FAILURE AND c4 = TWCC_CAPUNSUPPORTED then
// not supported!
Break
end if

Please review Twain Documentation for details.
Please open data source before via OpenDS method.
You may see problems if you use this method on a capability which is not a boolean.
Sets lasterror and condition code.
(if lasterror is 1 and condition code is 13, the capability is not supported)

TwainMBS.SetFloatCapability(ID as Integer, Value as Double)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Sets a capability with floating point value.

Please review Twain Documentation for details.
Please open data source before via OpenDS method.
You may see problems if you use this method on a capability which is not a floating point value (FIX32).
Sets lasterror and condition code.
(if lasterror is 1 and condition code is 13, the capability is not supported)

TwainMBS.SetInt32Capability(ID as Integer, Value as Int32)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Sets a capability with 32 bit integer.

Please review Twain Documentation for details.
Please open data source before via OpenDS method.
You may see problems if you use this method on a capability which is not a 32 bit integer.
Sets lasterror and condition code.
(if lasterror is 1 and condition code is 13, the capability is not supported)

TwainMBS.SetUInt16Capability(ID as Integer, Value as UInt16)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 15.0 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Sets a capability with 16 bit integer.

Please review Twain Documentation for details.
Please open data source before via OpenDS method.
You may see problems if you use this method on a capability which is not a 16 bit integer.
Sets lasterror and condition code.
(if lasterror is 1 and condition code is 13, the capability is not supported)

TwainMBS.SupportsMemoryTransfer as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Whether the twain data source supports memory transfers.

As our plugin uses only memory transfers, the source must support this in order to work with our plugin.

TwainMBS.TransferImage as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Twain MBS Picture Plugin 12.3 ✅ Yes ✅ Yes ❌ No ❌ No Desktop only
Transfers an image.

Lasterror is set.
Image data is converted to a normal RGB picture.
Can return nil on any error.
The events TransferStarted, TransferEnded and TransferProgress are called when a transfer is running.

Some examples using this method:

The items on this page are in the following plugins: MBS Picture Plugin.


The biggest plugin in space...