469,347 Members | 20,083 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,347 developers. It's quick & easy.

WIA.ImageFile to System.Drawing.Image

I am creating an imaging service using WIA (Windows Imaging
Acquisition).

The problem is that I cannot convert a WIA.ImageFile to a
System.Drawing.Image to put a timestamp on the image without first
saving the file using the wia.imagefile.savefile then loading it again
using System.Drawing.Image.FromFile. This seems pretty ineffecient. I
have tried coverting it using ctype, but I get an invalid cast
exception. Is anyone aware of how to accomplish this without saving and
reloading the file? I appreciate your time...

Thanks,
Jeremy

Dim mydevice As WIA.Device
Dim manager As New WIA.DeviceManagerClass
Dim mydialog As New WIA.CommonDialogClass
Dim strcmdTakePicture As String =
WIA.CommandID.wiaCommandTakePicture
Dim strImageformat As String = WIA.FormatID.wiaFormatJPEG
Dim myItem As WIA.Item
Dim myImage As WIA.ImageFile
Dim strFilePath As String = Application.StartupPath &
"\Images\Dummy.jpg"

For Each info As WIA.DeviceInfo In manager.DeviceInfos
'Connect w/o dialog
If info.DeviceID =
"{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000" Then
mydevice = info.Connect
End If
Next

If IsNothing(mydevice) Then
mydevice =
mydialog.ShowSelectDevice(WIA.WiaDeviceType.VideoD eviceType, False,
True)
End If

myItem = mydevice.ExecuteCommand(strcmdTakePicture)

myImage = CType(myItem.Transfer(strImageformat), WIA.ImageFile)

'Need to covert to image here instead of SaveFile
myImage.SaveFile(strFilePath)

Jan 5 '06 #1
2 10672
Hi,

Maybe this will help

http://msdn.microsoft.com/coding4fun...e/default.aspx

Ken
--------------
"Jeremy" <sl********@hotmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I am creating an imaging service using WIA (Windows Imaging
Acquisition).

The problem is that I cannot convert a WIA.ImageFile to a
System.Drawing.Image to put a timestamp on the image without first
saving the file using the wia.imagefile.savefile then loading it again
using System.Drawing.Image.FromFile. This seems pretty ineffecient. I
have tried coverting it using ctype, but I get an invalid cast
exception. Is anyone aware of how to accomplish this without saving and
reloading the file? I appreciate your time...

Thanks,
Jeremy

Dim mydevice As WIA.Device
Dim manager As New WIA.DeviceManagerClass
Dim mydialog As New WIA.CommonDialogClass
Dim strcmdTakePicture As String =
WIA.CommandID.wiaCommandTakePicture
Dim strImageformat As String = WIA.FormatID.wiaFormatJPEG
Dim myItem As WIA.Item
Dim myImage As WIA.ImageFile
Dim strFilePath As String = Application.StartupPath &
"\Images\Dummy.jpg"

For Each info As WIA.DeviceInfo In manager.DeviceInfos
'Connect w/o dialog
If info.DeviceID =
"{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}\0000" Then
mydevice = info.Connect
End If
Next

If IsNothing(mydevice) Then
mydevice =
mydialog.ShowSelectDevice(WIA.WiaDeviceType.VideoD eviceType, False,
True)
End If

myItem = mydevice.ExecuteCommand(strcmdTakePicture)

myImage = CType(myItem.Transfer(strImageformat), WIA.ImageFile)

'Need to covert to image here instead of SaveFile
myImage.SaveFile(strFilePath)

Jan 5 '06 #2
Thanks for your reply Ken. Actually this is one resource I used to
learn WIA. In the example however, he simply saves the file. I want to
convert it to a System.Drawing.Image first so I can alter the image
(add a time stamp). You can not programatically alter a wia.imagefile.
I was hoping someone could assist me in coverting a wia.imagefile to a
drawing.image without saving and reloading the file. Dim bmap as Image
= ctype(MyWiaImage,Image) causes an invalid cast exception.

Jan 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Toby Mathews | last post: by
1 post views Thread by Martijn Mulder | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.