twain 扫描仪参数设置
TwCapability[StructLayout(LayoutKind.Sequential, Pack=2)]
internal class TwCapability
{ // TW_CAPABILITY
public TwCapability( TwCap cap )
{
Cap = (short) cap;
ConType = -1;
}
public TwCapability( TwCap cap, short sval )
{
Cap = (short) cap;
ConType = (short) TwOn.One;
Handle = Twain.GlobalAlloc( 0x42, 6 );
IntPtr pv = Twain.GlobalLock( Handle );
Marshal.WriteInt16( pv, 0, (short) TwType.Int16 );
Marshal.WriteInt32( pv, 2, (int) sval );
Twain.GlobalUnlock( Handle );
}
~TwCapability()
{
if( Handle != IntPtr.Zero )
Twain.GlobalFree( Handle );
}
public short Cap;
public short ConType;
public IntPtr Handle;
public short BITDEPTH;
}
internal enum TwCap : short
{
XferCount = 0x0001, // CAP_XFERCOUNT
ICompression = 0x0100, // ICAP_...
IPixelType = 0x0101,
IUnits = 0x0102,
IXferMech = 0x0103
}
[DllImport("twain_32.dll", EntryPoint="#1")]
private static extern TwRC DScap( [In, Out] TwIdentity origin, [In] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TwCapability capa );
//扫描前,扫描仪设置
TwCapability cap = new TwCapability( TwCap.XferCount, 1 );
rc = DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );
我想请教下哪位熟悉twain的朋友, 扫描分辨率, 色彩等其他参数应该怎么设置? --------------------编程问答-------------------- 大神求救啊。 --------------------编程问答-------------------- 下拉框:cboResolution
判断设备是否支持分辨率这个属性:DeviceCapability.ICAP_XRESOLUTION
private void UpdateResolutionValues()
{
this.cboResolution.Items.Clear();
if (this.device.QueryCapability(DeviceCapability.ICAP_XRESOLUTION, true))
{
this.cboResolution.Enabled = true;
float defaultRes = 300;
TwainResolution[] resolutions = this.device.GetSupportedResolutions();
foreach (TwainResolution res in resolutions)
{
this.cboResolution.Items.Add(res.X.ToString());
}
TwainResolution resolution = this.device.Resolution;
this.cboResolution.SelectedIndex = 0;
}
else
this.cboResolution.Enabled = false;
}
--------------------编程问答-------------------- [StructLayout(LayoutKind.Sequential, Pack = 2)]
internal class TwImageInfo
{ // TW_IMAGEINFO
public int XResolution;
public int YResolution;
public int ImageWidth;
public int ImageLength;
public short SamplesPerPixel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public short[] BitsPerSample;
public short BitsPerPixel;
public short Planar;
public short PixelType;
public short Compression;
}
[DllImport("twain_32.dll", EntryPoint = "#1")]
private static extern TwRC DSiinf([In, Out] TwIdentity origin, [In] TwIdentity dest, TwDG dg, TwDAT dat, TwMSG msg, [In, Out] TwImageInfo imginf);
http://q.cnblogs.com/q/13964/
补充:.NET技术 , C#