Skip to content

Commit 1043225

Browse files
committed
WIA Typescript definitions
Windows Image Acquisitions
1 parent 3bbe35a commit 1043225

3 files changed

Lines changed: 459 additions & 0 deletions

File tree

‎activex/jscript-extensions.d.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
interface VarDate { }
2+
3+
interface DateConstructor {
4+
new (vd: VarDate): Date;
5+
getVarDate: () => VarDate;
6+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/// <reference path="microsoft-windows-image-acquisition.d.ts" />
2+
3+
//source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
4+
5+
6+
//Convert a file
7+
var commonDialog = new ActiveXObject('WIA.CommonDialog');
8+
var img = commonDialog.ShowAcquireImage();
9+
if (img.FormatID != WIA.FormatID.wiaFormatJPEG) {
10+
var ip = new ActiveXObject('WIA.ImageProcess');
11+
ip.Filters.Add(ip.FilterInfos.Item('Convert').FilterID);
12+
ip.Filters.Item(1).Properties.Item("FormatID").Value = WIA.FormatID.wiaFormatJPEG;
13+
img = ip.Apply(img);
14+
}
15+
16+
17+
//Take a picture
18+
var dev = commonDialog.ShowSelectDevice();
19+
if (dev.Type == WIA.WiaDeviceType.CameraDeviceType) {
20+
var itm = dev.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);
21+
}
22+
23+
24+
//Display detailed property information
25+
dev = commonDialog.ShowSelectDevice();
26+
var e = new Enumerator<WIA.Property>(dev.Properties); //no foreach over ActiveX collections
27+
e.moveFirst();
28+
while (!e.atEnd()) {
29+
var p = e.item();
30+
var s = p.Name + ' (' + p.PropertyID + ') = ';
31+
if (p.IsVector) {
32+
s += '[vector of data]';
33+
} else {
34+
s += p.Value;
35+
if (p.SubType != WIA.WiaSubType.UnspecifiedSubType) {
36+
if (p.Value != p.SubTypeDefault) {
37+
s += ' (Default = ' + p.SubTypeDefault + ')';
38+
}
39+
}
40+
}
41+
42+
if (p.IsReadOnly) {
43+
s += ' [READ ONLY]';
44+
} else {
45+
switch (p.SubType) {
46+
case WIA.WiaSubType.FlagSubType:
47+
case WIA.WiaSubType.ListSubType:
48+
if (p.SubType == WIA.WiaSubType.FlagSubType) {
49+
s += ' [valid flags include: ';
50+
} else {
51+
s += ' [valid values include: ';
52+
}
53+
var count = p.SubTypeValues.Count;
54+
for (var i = 1; i <= count; i++) {
55+
s += p.SubTypeValues.Item(i);
56+
if (i < count) {
57+
s += ', ';
58+
}
59+
}
60+
s += ']';
61+
break;
62+
case WIA.WiaSubType.RangeSubType:
63+
s += ' [valid values in the range from ' + p.SubTypeMin + ' to ' + p.SubTypeMax + ' in increments of ' + p.SubTypeStep + ']';
64+
break;
65+
}
66+
}
67+
68+
if (WScript) {
69+
WScript.Echo(s);
70+
} else if (window) {
71+
window.alert(s);
72+
}
73+
}

0 commit comments

Comments
 (0)