D
Dave T
In .net web app, Using Windows Image Acquisition (WIA), I'm trying to invoke
a scanner and put the resulting image in a database. I'm trying to pass the
image in as a string argument to a webservice that does that since VBS
(client-side) doesn't really let you work with byte arrays. Once it gets to
the web service I transform the string into a byte array. It all sounds good
on paper but I get junk as an image in the database (the field is *image*
type). Any ideas?
<code>
<script type = "text/vbscript" language="vbscript">
Const ScannerDeviceType = 1
Const GrayscaleIntent = 2
Const UnspecifiedIntent = 0
Const MinimizeSize = 65536
Const wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
Sub DoVBScan()
Dim ScanningDialog
set ScanningDialog=createobject("wia.commondialog")
Dim Img 'As ImageFile
'Get Image
Set Img =
ScanningDialog.ShowAcquireImage(ScannerDeviceType,GrayscaleIntent,MinimizeSize,wiaFormatJPEG,false,true, false)
'Convert To Jpeg as required
If Img.FormatID <> wiaFormatJPEG Then
Dim IP 'As New ImageProcess
Set IP = CreateObject( "Wia.ImageProcess" )
IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
Set Img = IP.Apply(Img)
End If
'Create vector
dim v 'as vector
set v = createobject("wia.vector")
set v = img.filedata
'Convert image to string
dim strImage 'as string
strImage = v.String
set xmlhttp = createobject("msxml2.XMLHTTP")
'POST to web service as string parameter
xmlhttp.open "POST",
"http://localhost/SafeAtHome.DataAccess/Correspondence.asmx/InsertMail",false
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xmlhttp.send "EntityID=537&Image=" & strImage
end sub
</script>
</code>
a scanner and put the resulting image in a database. I'm trying to pass the
image in as a string argument to a webservice that does that since VBS
(client-side) doesn't really let you work with byte arrays. Once it gets to
the web service I transform the string into a byte array. It all sounds good
on paper but I get junk as an image in the database (the field is *image*
type). Any ideas?
<code>
<script type = "text/vbscript" language="vbscript">
Const ScannerDeviceType = 1
Const GrayscaleIntent = 2
Const UnspecifiedIntent = 0
Const MinimizeSize = 65536
Const wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"
Sub DoVBScan()
Dim ScanningDialog
set ScanningDialog=createobject("wia.commondialog")
Dim Img 'As ImageFile
'Get Image
Set Img =
ScanningDialog.ShowAcquireImage(ScannerDeviceType,GrayscaleIntent,MinimizeSize,wiaFormatJPEG,false,true, false)
'Convert To Jpeg as required
If Img.FormatID <> wiaFormatJPEG Then
Dim IP 'As New ImageProcess
Set IP = CreateObject( "Wia.ImageProcess" )
IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(1).Properties("FormatID").Value = wiaFormatJPEG
Set Img = IP.Apply(Img)
End If
'Create vector
dim v 'as vector
set v = createobject("wia.vector")
set v = img.filedata
'Convert image to string
dim strImage 'as string
strImage = v.String
set xmlhttp = createobject("msxml2.XMLHTTP")
'POST to web service as string parameter
xmlhttp.open "POST",
"http://localhost/SafeAtHome.DataAccess/Correspondence.asmx/InsertMail",false
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xmlhttp.send "EntityID=537&Image=" & strImage
end sub
</script>
</code>