473,242 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

Anybody know anything about WIA (Windows Image Acqusition?)

I'm using wia in a vb.net project to capture images from a scanner.. This
works fine.

However, I want to control the way that images are scanned - ie B+W,
Greyscale and resolution etc, but can't work out how to. My code for
scanning is below (sorry it's a bit messy - it's been chopped and changed
around a lot)... There seems to be very little documentation on WIA, can
anybody help me with this ???

Code is :

Private Sub Getscanner()

' Setup Scanning and get scanner

txtStatus.Text = "Connecting to Scanner/Camera"

Try

wiadev = wia.ShowSelectDevice()

Catch ex As Exception

txtStatus.Text = "Could not connect to scanner/camera"

Exit Sub

End Try

Dim str As WIA.Property

For Each str In wiadev.Properties

Try

Debug.WriteLine("Property : " & str.Name & " = " & CStr(str.Value))

Catch

End Try

Next

txtStatus.Text = "Connected to Scanner/camera"

End Sub



Private Sub CaptureImages()

Dim FileName As String

Dim count As Int32

Dim tmp As Object

Dim image As Image

Dim gr As System.Drawing.Graphics

Dim prop As System.Drawing.Imaging.PropertyItem

Dim scale As Decimal

Dim tmpfilename As String

Dim Cb As System.Drawing.Image.GetThumbnailImageAbort = New
System.Drawing.Image.GetThumbnailImageAbort(Addres sOf AbortImage)

Dim ImageCount As Int32

Getscanner()

txtStatus.Text = "Getting Images.."

'Try

' wiaPics = wiaRoot.Children. 'GetItemsFromUI(WIALib.WiaFlag.UseCommonUI,
WIALib.WiaIntent.ImageTypeColor)

'Catch ex As Exception

' MsgBox(ex.Message)

' Exit Sub

' End Try

Dim WiaPics As WIA.ItemClass

Dim WiaItem1 As WIA.ItemsClass

Dim wiaitem As WIA.ItemClass

Dim WiaImage As WIA.ImageFileClass

WiaItem1 = wiadev.Items

ImageCount = WiaItem1.Count

Dim offset As Int32 = 0

' Try

For count = 1 To WiaItem1.Count

wiaitem = WiaItem1.Item(count)

'wiaItem = System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(tmp,
GetType(WIALib.ItemClass))

Do

FileName = DirName & "\img" & Format(count + offset, "0000") & ".jpg"

If System.IO.File.Exists(FileName) Then offset = offset + 1

Loop Until System.IO.File.Exists(FileName) = False

txtStatus.Text = "Getting Image - " & count & " of " & ImageCount

Application.DoEvents()

tmpfilename = System.IO.Path.GetTempFileName

System.IO.File.Delete(tmpfilename)

Try

tmp = wiaitem.Transfer()

tmp.SaveFile(tmpfilename)

' tmp.Transfer(tmpfilename, False)

'System.Runtime.InteropServices.Marshal.ReleaseCom Object(wiaItem)

image = System.Drawing.Bitmap.FromFile(tmpfilename)

Try

System.IO.File.Delete(DirName & "\tmppic" & count & ".jpg")

Catch ex As Exception

'txtstatus.Text = "Error deleting file : " & Err.Description

' Application.DoEvents()

End Try

' If image.Width > 500 Then

'scale = 500 / image.Width

'image = image.GetThumbnailImage(500, Int(image.Height * scale), Cb,
IntPtr.Zero)

'End If

PictureBox1.Image = image

image.Save(FileName)

image = Nothing

RaiseEvent ImageLoaded()

Catch ex As Exception

'MsgBox(ex.Message)

End Try

' Catch

' 'txtstatus.Text = "Failed..."

' End Try

Next

Me.Close()

End Sub

----

Many thanks in advance

Simon
Nov 20 '05 #1
4 7952
Simon,

* "Simon Verona" <ne**@aphroditeuk.com> scripsit:
I'm using wia in a vb.net project to capture images from a scanner.. This
works fine.

However, I want to control the way that images are scanned - ie B+W,
Greyscale and resolution etc, but can't work out how to. My code for
scanning is below (sorry it's a bit messy - it's been chopped and changed
around a lot)... There seems to be very little documentation on WIA, can
anybody help me with this ???


Are you sure there is little documentation?

<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wia/wia/overviews/usingthewiascriptingmodel.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Thanks Herfried,

I've seen this documentation, but it doesn't appear to have too many useful
examples of using and setting properties which is where I think I need to be
playing... I was hoping somebody else had got a working example that would
save me working it out by trial and error..

Regards
Simon
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl...
Simon,

* "Simon Verona" <ne**@aphroditeuk.com> scripsit:
I'm using wia in a vb.net project to capture images from a scanner.. This works fine.

However, I want to control the way that images are scanned - ie B+W,
Greyscale and resolution etc, but can't work out how to. My code for
scanning is below (sorry it's a bit messy - it's been chopped and changed around a lot)... There seems to be very little documentation on WIA, can anybody help me with this ???
Are you sure there is little documentation?

<http://msdn.microsoft.com/library/de...-us/wia/wia/ov
erviews/usingthewiascriptingmodel.asp>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
Hi,

http://www.codeproject.com/dotnet/wi...asp?target=wia

Ken
------------------
"Simon Verona" <ne**@aphroditeuk.com> wrote in message
news:er**************@TK2MSFTNGP09.phx.gbl...
I'm using wia in a vb.net project to capture images from a scanner.. This
works fine.

However, I want to control the way that images are scanned - ie B+W,
Greyscale and resolution etc, but can't work out how to. My code for
scanning is below (sorry it's a bit messy - it's been chopped and changed
around a lot)... There seems to be very little documentation on WIA, can
anybody help me with this ???

Code is :

Private Sub Getscanner()

' Setup Scanning and get scanner

txtStatus.Text = "Connecting to Scanner/Camera"

Try

wiadev = wia.ShowSelectDevice()

Catch ex As Exception

txtStatus.Text = "Could not connect to scanner/camera"

Exit Sub

End Try

Dim str As WIA.Property

For Each str In wiadev.Properties

Try

Debug.WriteLine("Property : " & str.Name & " = " & CStr(str.Value))

Catch

End Try

Next

txtStatus.Text = "Connected to Scanner/camera"

End Sub



Private Sub CaptureImages()

Dim FileName As String

Dim count As Int32

Dim tmp As Object

Dim image As Image

Dim gr As System.Drawing.Graphics

Dim prop As System.Drawing.Imaging.PropertyItem

Dim scale As Decimal

Dim tmpfilename As String

Dim Cb As System.Drawing.Image.GetThumbnailImageAbort = New
System.Drawing.Image.GetThumbnailImageAbort(Addres sOf AbortImage)

Dim ImageCount As Int32

Getscanner()

txtStatus.Text = "Getting Images.."

'Try

' wiaPics = wiaRoot.Children. 'GetItemsFromUI(WIALib.WiaFlag.UseCommonUI,
WIALib.WiaIntent.ImageTypeColor)

'Catch ex As Exception

' MsgBox(ex.Message)

' Exit Sub

' End Try

Dim WiaPics As WIA.ItemClass

Dim WiaItem1 As WIA.ItemsClass

Dim wiaitem As WIA.ItemClass

Dim WiaImage As WIA.ImageFileClass

WiaItem1 = wiadev.Items

ImageCount = WiaItem1.Count

Dim offset As Int32 = 0

' Try

For count = 1 To WiaItem1.Count

wiaitem = WiaItem1.Item(count)

'wiaItem = System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(tmp,
GetType(WIALib.ItemClass))

Do

FileName = DirName & "\img" & Format(count + offset, "0000") & ".jpg"

If System.IO.File.Exists(FileName) Then offset = offset + 1

Loop Until System.IO.File.Exists(FileName) = False

txtStatus.Text = "Getting Image - " & count & " of " & ImageCount

Application.DoEvents()

tmpfilename = System.IO.Path.GetTempFileName

System.IO.File.Delete(tmpfilename)

Try

tmp = wiaitem.Transfer()

tmp.SaveFile(tmpfilename)

' tmp.Transfer(tmpfilename, False)

'System.Runtime.InteropServices.Marshal.ReleaseCom Object(wiaItem)

image = System.Drawing.Bitmap.FromFile(tmpfilename)

Try

System.IO.File.Delete(DirName & "\tmppic" & count & ".jpg")

Catch ex As Exception

'txtstatus.Text = "Error deleting file : " & Err.Description

' Application.DoEvents()

End Try

' If image.Width > 500 Then

'scale = 500 / image.Width

'image = image.GetThumbnailImage(500, Int(image.Height * scale), Cb,
IntPtr.Zero)

'End If

PictureBox1.Image = image

image.Save(FileName)

image = Nothing

RaiseEvent ImageLoaded()

Catch ex As Exception

'MsgBox(ex.Message)

End Try

' Catch

' 'txtstatus.Text = "Failed..."

' End Try

Next

Me.Close()

End Sub

----

Many thanks in advance

Simon

Nov 20 '05 #4
On Mon, 2 Feb 2004 14:40:56 -0000, "Simon Verona"
<ne**@aphroditeuk.com> wrote:
I'm using wia in a vb.net project to capture images from a scanner.. This
works fine.

However, I want to control the way that images are scanned - ie B+W,
Greyscale and resolution etc, but can't work out how to. My code for
scanning is below (sorry it's a bit messy - it's been chopped and changed
around a lot)... There seems to be very little documentation on WIA, can
anybody help me with this ???

[snip]

Well, I don't have any suggestions for you, Simon, but that's exactly
the same problem I'm running up against. I don't want to have to
abandon the scripting model and do lower-level wia coding if I don't
have to, but it seems like the only solution I can find. MSDN lists
it as one of the technical limitations of the scripting model, that
you cannot set properties.

Did you have any success with this, and if so, how?

Thanks,

Tim McGarvey
Back East Consulting

r e m o v e junk f r o m e m a i l t o r e p l y
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Patrick | last post by:
Hi, I was wondering if anybody here has any feedback on the windows version of PostgreSQL from DBExperts. Stability Speed Support Anything else I should know.
14
by: J. Makela | last post by:
Hallo. This should be a pretty entertaining question for you *real* javascript writers.. I, being the lowly photoshop guy at an ad agency made the mistake of actually saying "HTML" in a...
2
by: rafeekb | last post by:
Hello All, Can anybody help me with a copy of DB2 6.1 SDK for Windows? I know its ancient but any help is appreciated. Regards, Raf
1
by: Miguel Dias Moura | last post by:
Hi Cor and everybody else, i created a page with 5 panels and 5 buttons which control them acording to Cor's help. After this i used 5 image buttons instead of standard buttons. When i run...
5
by: Geoff Jones | last post by:
Hi Does anybody use the Visual Basic Resource Kit? I have a question about it and I've either discovered a bug in it or have a problem with my installation. Geoff
8
by: Xero | last post by:
Hello. Could anybody suggest a way to create a timer? I want to timer to be displayed to the user, telling he or she how much time has passed. Thanks. -- Xero
12
by: Terry Olsen | last post by:
VB.NET doesn't seem to go over very well with the recreational users out in inet land. I've got a few "free" programs that I put out for people to use, and I get emails like "it'd be a nice...
42
by: (PeteCresswell) | last post by:
I skimmed the MS spiel at http://msdn.microsoft.com/sql/express, and noted the part about "all inside the Visual Studio 2005 environment". Do the older SQL server tools for security and stored...
5
by: =?Utf-8?B?Sm9obiBLb3R1Ynk=?= | last post by:
Hi all, We lease a non-managed Web Server running AV software but no IDS. It is Windows 2003 STD which receives automatic nightly Windows Security patches at 3AM. When I logged into the RDP...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.