-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathTwainDefs.cs
3517 lines (3108 loc) · 99.3 KB
/
TwainDefs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Этот файл является частью библиотеки Saraff.Twain.DS
* © SARAFF SOFTWARE (Кирножицкий Андрей), 2015.
* Saraff.Twain.DS - свободная программа: вы можете перераспространять ее и/или
* изменять ее на условиях Меньшей Стандартной общественной лицензии GNU в том виде,
* в каком она была опубликована Фондом свободного программного обеспечения;
* либо версии 3 лицензии, либо (по вашему выбору) любой более поздней
* версии.
* Saraff.Twain.DS распространяется в надежде, что она будет полезной,
* но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
* или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Меньшей Стандартной
* общественной лицензии GNU.
* Вы должны были получить копию Меньшей Стандартной общественной лицензии GNU
* вместе с этой программой. Если это не так, см.
* <http://www.gnu.org/licenses/>.)
*
* This file is part of Saraff.Twain.DS.
* © SARAFF SOFTWARE (Kirnazhytski Andrei), 2015.
* Saraff.Twain.DS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Saraff.Twain.DS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with Saraff.Twain.DS. If not, see <http://www.gnu.org/licenses/>.
*
* PLEASE SEND EMAIL TO: twain@saraff.ru.
*/
/* Этот файл является частью библиотеки Saraff.Twain.NET
* © SARAFF SOFTWARE (Кирножицкий Андрей), 2011.
* Saraff.Twain.NET - свободная программа: вы можете перераспространять ее и/или
* изменять ее на условиях Меньшей Стандартной общественной лицензии GNU в том виде,
* в каком она была опубликована Фондом свободного программного обеспечения;
* либо версии 3 лицензии, либо (по вашему выбору) любой более поздней
* версии.
* Saraff.Twain.NET распространяется в надежде, что она будет полезной,
* но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
* или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЕННЫХ ЦЕЛЕЙ. Подробнее см. в Меньшей Стандартной
* общественной лицензии GNU.
* Вы должны были получить копию Меньшей Стандартной общественной лицензии GNU
* вместе с этой программой. Если это не так, см.
* <http://www.gnu.org/licenses/>.)
*
* This file is part of Saraff.Twain.NET.
* © SARAFF SOFTWARE (Kirnazhytski Andrei), 2011.
* Saraff.Twain.NET is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Saraff.Twain.NET is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with Saraff.Twain.NET. If not, see <http://www.gnu.org/licenses/>.
*
* PLEASE SEND EMAIL TO: twain@saraff.ru.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Drawing;
namespace Saraff.Twain.DS {
#region Generic Constants
/// <summary>
/// Data Groups.
/// </summary>
[Flags]
public enum TwDG:uint { // DG_.....
/// <summary>
/// Data pertaining to control.
/// </summary>
Control=0x0001,
/// <summary>
/// Data pertaining to raster images.
/// </summary>
Image=0x0002,
/// <summary>
/// Data pertaining to audio.
/// </summary>
Audio=0x0004,
/// <summary>
/// added to the identity by the DSM.
/// </summary>
DSM2=0x10000000,
/// <summary>
/// Set by the App to indicate it would prefer to use DSM2.
/// </summary>
APP2=0x20000000,
/// <summary>
/// Set by the DS to indicate it would prefer to use DSM2.
/// </summary>
DS2=0x40000000
}
/// <summary>
/// Data codes.
/// </summary>
public enum TwDAT:ushort { // DAT_....
#region Data Argument Types for the DG_CONTROL Data Group.
Null=0x0000,
Capability=0x0001,
Event=0x0002,
Identity=0x0003,
Parent=0x0004,
PendingXfers=0x0005,
SetupMemXfer=0x0006,
SetupFileXfer=0x0007,
Status=0x0008,
UserInterface=0x0009,
XferGroup=0x000a,
TwunkIdentity=0x000b,
CustomDSData=0x000c,
DeviceEvent=0x000d,
FileSystem=0x000e,
PassThru=0x000f,
Callback=0x0010, /* TW_CALLBACK Added 2.0 */
StatusUtf8=0x0011, /* TW_STATUSUTF8 Added 2.1 */
Callback2=0x0012,
#endregion
#region Data Argument Types for the DG_IMAGE Data Group.
ImageInfo=0x0101,
ImageLayout=0x0102,
ImageMemXfer=0x0103,
ImageNativeXfer=0x0104,
ImageFileXfer=0x0105,
CieColor=0x0106,
GrayResponse=0x0107,
RGBResponse=0x0108,
JpegCompression=0x0109,
Palette8=0x010a,
ExtImageInfo=0x010b,
#endregion
#region misplaced
IccProfile=0x0401, /* TW_MEMORY Added 1.91 This Data Argument is misplaced but belongs to the DG_IMAGE Data Group */
ImageMemFileXfer=0x0402, /* TW_IMAGEMEMXFER Added 1.91 This Data Argument is misplaced but belongs to the DG_IMAGE Data Group */
EntryPoint=0x0403, /* TW_ENTRYPOINT Added 2.0 This Data Argument is misplaced but belongs to the DG_CONTROL Data Group */
#endregion
}
/// <summary>
/// Messages.
/// </summary>
public enum TwMSG:ushort { // MSG_.....
#region Generic messages may be used with any of several DATs.
/// <summary>
/// Used in TW_EVENT structure.
/// </summary>
Null=0x0000,
/// <summary>
/// Get one or more values.
/// </summary>
Get=0x0001,
/// <summary>
/// Get current value.
/// </summary>
GetCurrent=0x0002,
/// <summary>
/// Get default (e.g. power up) value.
/// </summary>
GetDefault=0x0003,
/// <summary>
/// Get first of a series of items, e.g. DSs.
/// </summary>
GetFirst=0x0004,
/// <summary>
/// Iterate through a series of items.
/// </summary>
GetNext=0x0005,
/// <summary>
/// Set one or more values.
/// </summary>
Set=0x0006,
/// <summary>
/// Set current value to default value.
/// </summary>
Reset=0x0007,
/// <summary>
/// Get supported operations on the cap.
/// </summary>
QuerySupport=0x0008,
#endregion
#region Messages used with DAT_NULL
XFerReady=0x0101,
CloseDSReq=0x0102,
CloseDSOK=0x0103,
DeviceEvent=0x0104,
#endregion
#region Messages used with a pointer to a DAT_STATUS structure
/// <summary>
/// Get status information
/// </summary>
CheckStatus=0x0201,
#endregion
#region Messages used with a pointer to DAT_PARENT entry
/// <summary>
/// Open the DSM
/// </summary>
OpenDSM=0x0301,
/// <summary>
/// Close the DSM
/// </summary>
CloseDSM=0x0302,
#endregion
#region Messages used with a pointer to a DAT_IDENTITY structure
/// <summary>
/// Open a entry source
/// </summary>
OpenDS=0x0401,
/// <summary>
/// Close a entry source
/// </summary>
CloseDS=0x0402,
/// <summary>
/// Put up a dialog of all DS
/// </summary>
UserSelect=0x0403,
#endregion
#region Messages used with a pointer to a DAT_USERINTERFACE structure
/// <summary>
/// Disable entry transfer in the DS
/// </summary>
DisableDS=0x0501,
/// <summary>
/// Enabled entry transfer in the DS
/// </summary>
EnableDS=0x0502,
/// <summary>
/// Enabled for saving DS state only.
/// </summary>
EnableDSUIOnly=0x0503,
#endregion
#region Messages used with a pointer to a DAT_EVENT structure
ProcessEvent=0x0601,
#endregion
#region Messages used with a pointer to a DAT_PENDINGXFERS structure
EndXfer=0x0701,
StopFeeder=0x0702,
#endregion
#region Messages used with a pointer to a DAT_FILESYSTEM structure
ChangeDirectory=0x0801,
CreateDirectory=0x0802,
Delete=0x0803,
FormatMedia=0x0804,
GetClose=0x0805,
GetFirstFile=0x0806,
GetInfo=0x0807,
GetNextFile=0x0808,
Rename=0x0809,
Copy=0x080A,
AutoCaptureDir=0x080B,
#endregion
#region Messages used with a pointer to a DAT_PASSTHRU structure
PassThru=0x0901,
#endregion
#region used with DAT_CALLBACK
RegisterCallback=0x0902,
#endregion
#region used with DAT_CAPABILITY
ResetAll=0x0A01
#endregion
}
/// <summary>
/// Return Codes
/// </summary>
public enum TwRC:ushort { // TWRC_....
Success=0x0000,
Failure=0x0001,
CheckStatus=0x0002,
Cancel=0x0003,
DSEvent=0x0004,
NotDSEvent=0x0005,
XferDone=0x0006,
EndOfList=0x0007,
InfoNotSupported=0x0008,
DataNotAvailable=0x0009,
Busy=10,
ScannerLocked=11
}
/// <summary>
/// Condition Codes
/// </summary>
public enum TwCC:ushort { // TWCC_....
Success=0x0000,
Bummer=0x0001,
LowMemory=0x0002,
NoDS=0x0003,
MaxConnections=0x0004,
OperationError=0x0005,
BadCap=0x0006,
BadProtocol=0x0009,
BadValue=0x000a,
SeqError=0x000b,
BadDest=0x000c,
CapUnsupported=0x000d,
CapBadOperation=0x000e,
CapSeqError=0x000f,
Denied=0x0010,
FileExists=0x0011,
FileNotFound=0x0012,
NotEmpty=0x0013,
PaperJam=0x0014,
PaperDoubleFeed=0x0015,
FileWriteError=0x0016,
CheckDeviceOnline=0x0017,
InterLock=24,
DamagedCorner=25,
FocusError=26,
DocTooLight=27,
DocTooDark=28,
NoMedia=29,
}
/// <summary>
/// Generic Constants
/// </summary>
public enum TwOn:ushort { // TWON_....
/// <summary>
/// Indicates TW_ARRAY container
/// </summary>
Array=0x0003,
/// <summary>
/// Indicates TW_ENUMERATION container
/// </summary>
Enum=0x0004,
/// <summary>
/// Indicates TW_ONEVALUE container
/// </summary>
One=0x0005,
/// <summary>
/// Indicates TW_RANGE container
/// </summary>
Range=0x0006,
DontCare=0xffff
}
/// <summary>
/// Data Types
/// </summary>
public enum TwType:ushort { // TWTY_....
Int8=0x0000,
Int16=0x0001,
Int32=0x0002,
UInt8=0x0003,
UInt16=0x0004,
UInt32=0x0005,
Bool=0x0006,
Fix32=0x0007,
Frame=0x0008,
Str32=0x0009,
Str64=0x000a,
Str128=0x000b,
Str255=0x000c,
Str1024=0x000d,
Uni512=0x000e,
Handle=0x000f
}
/// <summary>
/// Вспомогательный класс для типов twain.
/// </summary>
internal sealed class TwTypeHelper {
private static Dictionary<TwType, Type> _typeof=new Dictionary<TwType, Type> {
{TwType.Int8,typeof(sbyte)},
{TwType.Int16,typeof(short)},
{TwType.Int32,typeof(int)},
{TwType.UInt8,typeof(byte)},
{TwType.UInt16,typeof(ushort)},
{TwType.UInt32,typeof(uint)},
{TwType.Bool,typeof(TwBool)},
{TwType.Fix32,typeof(TwFix32)},
{TwType.Frame,typeof(TwFrame)},
{TwType.Str32,typeof(TwStr32)},
{TwType.Str64,typeof(TwStr64)},
{TwType.Str128,typeof(TwStr128)},
{TwType.Str255,typeof(TwStr255)},
{TwType.Str1024,typeof(TwStr1024)},
{TwType.Uni512,typeof(TwUni512)},
{TwType.Handle,typeof(IntPtr)}
};
private static Dictionary<int, TwType> _typeofAux=new Dictionary<int, TwType> {
{32,TwType.Str32},
{64,TwType.Str64},
{128,TwType.Str128},
{255,TwType.Str255},
{1024,TwType.Str1024},
{512,TwType.Uni512}
};
/// <summary>
/// Возвращает соответствующий twain-типу управляемый тип.
/// </summary>
/// <param name="type">Код типа данный twain.</param>
/// <returns>Управляемый тип.</returns>
internal static Type TypeOf(TwType type) {
return TwTypeHelper._typeof[type];
}
/// <summary>
/// Возвращает соответствующий управляемому типу twain-тип.
/// </summary>
/// <param name="type">Управляемый тип.</param>
/// <returns>Код типа данный twain.</returns>
internal static TwType TypeOf(Type type) {
Type _type=type.IsEnum?Enum.GetUnderlyingType(type):type;
foreach(var _item in TwTypeHelper._typeof) {
if(_item.Value==_type) {
return _item.Key;
}
}
if(type==typeof(bool)) {
return TwType.Bool;
}
if(type==typeof(float)) {
return TwType.Fix32;
}
if(type==typeof(RectangleF)) {
return TwType.Frame;
}
throw new KeyNotFoundException();
}
/// <summary>
/// Возвращает соответствующий объекту twain-тип.
/// </summary>
/// <param name="obj">Объект.</param>
/// <returns>Код типа данный twain.</returns>
internal static TwType TypeOf(object obj) {
if(obj is string) {
return TwTypeHelper._typeofAux[((string)obj).Length];
}
return TwTypeHelper.TypeOf(obj.GetType());
}
/// <summary>
/// Возвращает размер twain-типа в неуправляемом блоке памяти.
/// </summary>
/// <param name="type">Код типа данный twain.</param>
/// <returns>Размер в байтах.</returns>
internal static int SizeOf(TwType type) {
return Marshal.SizeOf(TwTypeHelper._typeof[type]);
}
/// <summary>
/// Приводит внутренние типы компонента к общим типам среды.
/// </summary>
/// <param name="type">Код twain-типа.</param>
/// <param name="value">Экземпляр объекта.</param>
/// <returns>Экземпляр объекта.</returns>
internal static object CastToCommon(TwType type, object value) {
switch(type) {
case TwType.Bool:
return (bool)(TwBool)value;
case TwType.Fix32:
return (float)(TwFix32)value;
case TwType.Frame:
return (RectangleF)(TwFrame)value;
case TwType.Str128:
case TwType.Str255:
case TwType.Str32:
case TwType.Str64:
case TwType.Uni512:
case TwType.Str1024:
return value.ToString();
}
return value;
}
/// <summary>
/// Приводит общие типы среды к внутренним типам компонента.
/// </summary>
/// <param name="type">Код twain-типа.</param>
/// <param name="value">Экземпляр объекта.</param>
/// <returns>Экземпляр объекта.</returns>
internal static object CastToTw(TwType type, object value) {
switch(type) {
case TwType.Bool:
return (TwBool)(bool)value;
case TwType.Fix32:
return (TwFix32)(float)value;
case TwType.Frame:
return (TwFrame)(RectangleF)value;
case TwType.Str32:
return (TwStr32)value.ToString();
case TwType.Str64:
return (TwStr64)value.ToString();
case TwType.Str128:
return (TwStr128)value.ToString();
case TwType.Str255:
return (TwStr255)value.ToString();
case TwType.Uni512:
return (TwUni512)value.ToString();
case TwType.Str1024:
return (TwStr1024)value.ToString();
}
Type _type=value.GetType();
if(_type.IsEnum&&Enum.GetUnderlyingType(_type)==TwTypeHelper.TypeOf(type)) {
return Convert.ChangeType(value, Enum.GetUnderlyingType(_type));
}
return value;
}
/// <summary>
/// Выполняет преобразование значения в экземпляр внутреннего типа компонента.
/// </summary>
/// <typeparam name="T">Тип значения.</typeparam>
/// <param name="type">Код twain-типа.</param>
/// <param name="value">Значение.</param>
/// <returns>Экземпляр объекта.</returns>
internal static object ValueToTw<T>(TwType type, T value) {
int _size=Marshal.SizeOf(typeof(T));
IntPtr _mem=Marshal.AllocHGlobal(_size);
DataSourceServices.Memory.ZeroMemory(_mem, (IntPtr)_size);
try {
Marshal.StructureToPtr(value, _mem, true);
return Marshal.PtrToStructure(_mem, TwTypeHelper.TypeOf(type));
} finally {
Marshal.FreeHGlobal(_mem);
}
}
/// <summary>
/// Выполняет преобразование экземпляра внутреннего типа компонента в значение.
/// </summary>
/// <typeparam name="T">Тип значения.</typeparam>
/// <param name="value">Экземпляр объекта.</param>
/// <returns>Значение.</returns>
internal static T ValueFromTw<T>(object value) {
int _size=Math.Max(Marshal.SizeOf(typeof(T)), Marshal.SizeOf(value));
IntPtr _mem=Marshal.AllocHGlobal(_size);
DataSourceServices.Memory.ZeroMemory(_mem, (IntPtr)_size);
try {
Marshal.StructureToPtr(value, _mem, true);
return (T)Marshal.PtrToStructure(_mem, typeof(T));
} finally {
Marshal.FreeHGlobal(_mem);
}
}
}
/// <summary>
/// Capability Constants
/// </summary>
public enum TwCap:ushort {
/* image entry sources MAY support these caps */
XferCount=0x0001, // all entry sources are REQUIRED to support these caps
ICompression=0x0100, // ICAP_...
IPixelType=0x0101,
IUnits=0x0102, //default is TWUN_INCHES
IXferMech=0x0103,
AutoBright=0x1100,
Brightness=0x1101,
Contrast=0x1103,
CustHalfTone=0x1104,
ExposureTime=0x1105,
Filter=0x1106,
Flashused=0x1107,
Gamma=0x1108,
HalfTones=0x1109,
Highlight=0x110a,
ImageFileFormat=0x110c,
LampState=0x110d,
LightSource=0x110e,
Orientation=0x1110,
PhysicalWidth=0x1111,
PhysicalHeight=0x1112,
Shadow=0x1113,
Frames=0x1114,
XNativeResolution=0x1116,
YNativeResolution=0x1117,
XResolution=0x1118,
YResolution=0x1119,
MaxFrames=0x111a,
Tiles=0x111b,
BitOrder=0x111c,
CCITTKFactor=0x111d,
LightPath=0x111e,
PixelFlavor=0x111f,
PlanarChunky=0x1120,
Rotation=0x1121,
SupportedSizes=0x1122,
Threshold=0x1123,
XScaling=0x1124,
YScaling=0x1125,
BitOrderCodes=0x1126,
PixelFlavorCodes=0x1127,
JpegPixelType=0x1128,
TimeFill=0x112a,
BitDepth=0x112b,
BitDepthReduction=0x112c, /* Added 1.5 */
UndefinedImageSize=0x112d, /* Added 1.6 */
ImageDataSet=0x112e, /* Added 1.7 */
ExtImageInfo=0x112f, /* Added 1.7 */
MinimumHeight=0x1130, /* Added 1.7 */
MinimumWidth=0x1131, /* Added 1.7 */
AutoDiscardBlankPages=0x1134, /* Added 2.0 */
FlipRotation=0x1136, /* Added 1.8 */
BarCodeDetectionEnabled=0x1137, /* Added 1.8 */
SupportedBarCodeTypes=0x1138, /* Added 1.8 */
BarCodeMaxSearchPriorities=0x1139, /* Added 1.8 */
BarCodeSearchPriorities=0x113a, /* Added 1.8 */
BarCodeSearchMode=0x113b, /* Added 1.8 */
BarCodeMaxRetries=0x113c, /* Added 1.8 */
BarCodeTimeout=0x113d, /* Added 1.8 */
ZoomFactor=0x113e, /* Added 1.8 */
PatchCodeDetectionEnabled=0x113f, /* Added 1.8 */
SupportedPatchCodeTypes=0x1140, /* Added 1.8 */
PatchCodeMaxSearchPriorities=0x1141, /* Added 1.8 */
PatchCodeSearchPriorities=0x1142, /* Added 1.8 */
PatchCodeSearchMode=0x1143, /* Added 1.8 */
PatchCodeMaxRetries=0x1144, /* Added 1.8 */
PatchCodeTimeout=0x1145, /* Added 1.8 */
FlashUsed2=0x1146, /* Added 1.8 */
ImageFilter=0x1147, /* Added 1.8 */
NoiseFilter=0x1148, /* Added 1.8 */
OverScan=0x1149, /* Added 1.8 */
AutomaticBorderDetection=0x1150, /* Added 1.8 */
AutomaticDeskew=0x1151, /* Added 1.8 */
AutomaticRotate=0x1152, /* Added 1.8 */
JpegQuality=0x1153, /* Added 1.9 */
FeederType=0x1154,
IccProfile=0x1155,
AutoSize=0x1156,
AutomaticCropUsesFrame=0x1157,
AutomaticLengthDetection=0x1158,
AutomaticColorEnabled=0x1159,
AutomaticColorNonColorPixelType=0x115a,
ColorManagementEnabled=0x115b,
ImageMerge=0x115c,
ImageMergeHeightThreshold=0x115d,
SupportedExtimageInfo=0x115e,
FilmType=0x115f,
Mirror=0x1160,
JpegSubSampling=0x1161,
/* all entry sources MAY support these caps */
Author=0x1000,
Caption=0x1001,
FeederEnabled=0x1002,
FeederLoaded=0x1003,
TimeDate=0x1004,
SupportedCaps=0x1005,
ExtendedCaps=0x1006,
AutoFeed=0x1007,
ClearPage=0x1008,
FeedPage=0x1009,
RewindPage=0x100a,
Indicators=0x100b, /* Added 1.1 */
SupportedCapsExt=0x100c, /* Added 1.6 */
PaperDetectable=0x100d, /* Added 1.6 */
UIControllable=0x100e, /* Added 1.6 */
DeviceOnline=0x100f, /* Added 1.6 */
AutoScan=0x1010, /* Added 1.6 */
ThumbnailsEnabled=0x1011, /* Added 1.7 */
Duplex=0x1012, /* Added 1.7 */
DuplexEnabled=0x1013, /* Added 1.7 */
EnableDSUIOnly=0x1014, /* Added 1.7 */
CustomDSData=0x1015, /* Added 1.7 */
Endorser=0x1016, /* Added 1.7 */
JobControl=0x1017, /* Added 1.7 */
Alarms=0x1018, /* Added 1.8 */
AlarmVolume=0x1019, /* Added 1.8 */
AutomaticCapture=0x101a, /* Added 1.8 */
TimeBeforeFirstCapture=0x101b, /* Added 1.8 */
TimeBetweenCaptures=0x101c, /* Added 1.8 */
ClearBuffers=0x101d, /* Added 1.8 */
MaxBatchBuffers=0x101e, /* Added 1.8 */
DeviceTimeDate=0x101f, /* Added 1.8 */
PowerSupply=0x1020, /* Added 1.8 */
CameraPreviewUI=0x1021, /* Added 1.8 */
DeviceEvent=0x1022, /* Added 1.8 */
SerialNumber=0x1024, /* Added 1.8 */
Printer=0x1026, /* Added 1.8 */
PrinterEnabled=0x1027, /* Added 1.8 */
PrinterIndex=0x1028, /* Added 1.8 */
PrinterMode=0x1029, /* Added 1.8 */
PrinterString=0x102a, /* Added 1.8 */
PrinterSuffix=0x102b, /* Added 1.8 */
Language=0x102c, /* Added 1.8 */
FeederAlignment=0x102d, /* Added 1.8 */
FeederOrder=0x102e, /* Added 1.8 */
ReacquireAllowed=0x1030, /* Added 1.8 */
BatteryMinutes=0x1032, /* Added 1.8 */
BatteryPercentage=0x1033, /* Added 1.8 */
CameraSide=0x1034,
Segmented=0x1035,
CameraEnabled=0x1036,
CameraOrder=0x1037,
MicrEnabled=0x1038,
FeederPrep=0x1039,
FeederPocket=0x103a,
AutomaticSenseMedium=0x103b,
CustomInterfaceGuid=0x103c,
SupportedCapsSegmentUnique=0x103d,
SupportedDats=0x103e,
DoubleFeedDetection=0x103f,
DoubleFeedDetectionLength=0x1040,
DoubleFeedDetectionSensitivity=0x1041,
DoubleFeedDetectionResponse=0x1042,
PaperHandling=0x1043,
IndicatorsMode=0x1044,
PrinterVerticalOffset=0x1045,
PowerSaveTime=0x1046,
PrinterCharRotation=0x1047,
PrinterFontStyle=0x1048,
PrinterIndexLeadChar=0x1049,
PrinterIndexMaxValue=0x104A,
PrinterIndexNumDigits=0x104B,
PrinterIndexStep=0x104C,
PrinterIndexTrigger=0x104D,
PrinterStringPreview=0x104E
}
/// <summary>
/// Bit patterns: for query the operation that are supported by the entry source on a capability
/// </summary>
[Flags]
public enum TwQC:ushort { //TWQC_...
Get=0x0001,
Set=0x0002,
GetDefault=0x0004,
GetCurrent=0x0008,
Reset=0x0010,
SetConstraint=0x0020,
ConstrainAble=0x0040,
GetHelp=0x0100,
GetLabel=0x0200,
GetLabelEnum=0x0400
}
/// <summary>
/// Language Constants
/// </summary>
public enum TwLanguage:ushort {
DANISH=0, /* Danish */
DUTCH=1, /* Dutch */
ENGLISH=2, /* International English */
FRENCH_CANADIAN=3, /* French Canadian */
FINNISH=4, /* Finnish */
FRENCH=5, /* French */
GERMAN=6, /* German */
ICELANDIC=7, /* Icelandic */
ITALIAN=8, /* Italian */
NORWEGIAN=9, /* Norwegian */
PORTUGUESE=10, /* Portuguese */
SPANISH=11, /* Spanish */
SWEDISH=12, /* Swedish */
ENGLISH_USA=13, /* U.S. English */
AFRIKAANS=14,
ALBANIA=15,
ARABIC=16,
ARABIC_ALGERIA=17,
ARABIC_BAHRAIN=18,
ARABIC_EGYPT=19,
ARABIC_IRAQ=20,
ARABIC_JORDAN=21,
ARABIC_KUWAIT=22,
ARABIC_LEBANON=23,
ARABIC_LIBYA=24,
ARABIC_MOROCCO=25,
ARABIC_OMAN=26,
ARABIC_QATAR=27,
ARABIC_SAUDIARABIA=28,
ARABIC_SYRIA=29,
ARABIC_TUNISIA=30,
ARABIC_UAE=31, /* United Arabic Emirates */
ARABIC_YEMEN=32,
BASQUE=33,
BYELORUSSIAN=34,
BULGARIAN=35,
CATALAN=36,
CHINESE=37,
CHINESE_HONGKONG=38,
CHINESE_PRC=39, /* People's Republic of China */
CHINESE_SINGAPORE=40,
CHINESE_SIMPLIFIED=41,
CHINESE_TAIWAN=42,
CHINESE_TRADITIONAL=43,
CROATIA=44,
CZECH=45,
DUTCH_BELGIAN=46,
ENGLISH_AUSTRALIAN=47,
ENGLISH_CANADIAN=48,
ENGLISH_IRELAND=49,
ENGLISH_NEWZEALAND=50,
ENGLISH_SOUTHAFRICA=51,
ENGLISH_UK=52,
ESTONIAN=53,
FAEROESE=54,
FARSI=55,
FRENCH_BELGIAN=56,
FRENCH_LUXEMBOURG=57,
FRENCH_SWISS=58,
GERMAN_AUSTRIAN=59,
GERMAN_LUXEMBOURG=60,
GERMAN_LIECHTENSTEIN=61,
GERMAN_SWISS=62,
GREEK=63,
HEBREW=64,
HUNGARIAN=65,
INDONESIAN=66,
ITALIAN_SWISS=67,
JAPANESE=68,
KOREAN=69,
KOREAN_JOHAB=70,
LATVIAN=71,
LITHUANIAN=72,
NORWEGIAN_BOKMAL=73,
NORWEGIAN_NYNORSK=74,
POLISH=75,
PORTUGUESE_BRAZIL=76,
ROMANIAN=77,
RUSSIAN=78,
SERBIAN_LATIN=79,
SLOVAK=80,
SLOVENIAN=81,
SPANISH_MEXICAN=82,
SPANISH_MODERN=83,
THAI=84,
TURKISH=85,
UKRANIAN=86,
/* More stuff added for 1.8 */
ASSAMESE=87,
BENGALI=88,
BIHARI=89,
BODO=90,
DOGRI=91,
GUJARATI=92,
HARYANVI=93,
HINDI=94,
KANNADA=95,
KASHMIRI=96,
MALAYALAM=97,
MARATHI=98,
MARWARI=99,
MEGHALAYAN=100,
MIZO=101,
NAGA=102,
ORISSI=103,
PUNJABI=104,
PUSHTU=105,
SERBIAN_CYRILLIC=106,
SIKKIMI=107,
SWEDISH_FINLAND=108,
TAMIL=109,
TELUGU=110,
TRIPURI=111,
URDU=112,
VIETNAMESE=113
}
/// <summary>
/// Country Constantsz
/// </summary>
public enum TwCountry:ushort {
AFGHANISTAN=1001,
ALGERIA=213,
AMERICANSAMOA=684,
ANDORRA=033,
ANGOLA=1002,
ANGUILLA=8090,
ANTIGUA=8091,
ARGENTINA=54,
ARUBA=297,
ASCENSIONI=247,
AUSTRALIA=61,
AUSTRIA=43,
BAHAMAS=8092,
BAHRAIN=973,
BANGLADESH=880,
BARBADOS=8093,
BELGIUM=32,
BELIZE=501,
BENIN=229,
BERMUDA=8094,
BHUTAN=1003,
BOLIVIA=591,
BOTSWANA=267,
BRITAIN=6,
BRITVIRGINIS=8095,
BRAZIL=55,
BRUNEI=673,
BULGARIA=359,
BURKINAFASO=1004,
BURMA=1005,
BURUNDI=1006,
CAMAROON=237,
CANADA=2,
CAPEVERDEIS=238,
CAYMANIS=8096,
CENTRALAFREP=1007,
CHAD=1008,
CHILE=56,
CHINA=86,
CHRISTMASIS=1009,
COCOSIS=1009,
COLOMBIA=57,
COMOROS=1010,
CONGO=1011,
COOKIS=1012,
COSTARICA=506,
CUBA=005,
CYPRUS=357,
CZECHOSLOVAKIA=42,
DENMARK=45,
DJIBOUTI=1013,
DOMINICA=8097,
DOMINCANREP=8098,
EASTERIS=1014,
ECUADOR=593,
EGYPT=20,
ELSALVADOR=503,
EQGUINEA=1015,
ETHIOPIA=251,
FALKLANDIS=1016,
FAEROEIS=298,
FIJIISLANDS=679,
FINLAND=358,
FRANCE=33,
FRANTILLES=596,
FRGUIANA=594,