473,320 Members | 2,003 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,320 software developers and data experts.

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 11127
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Toby Mathews | last post by:
Hi, In an ASP.Net application I want to convert open create a FileStream object from a System.Drawing.Image - is this possible? I create an instance of an Image object using the FromFile method,...
3
by: anastasia | last post by:
I get an out of memory exception when attempting to excecute the following code: original = System.Drawing.Image.FromFile(file.FileName,true); I ONLY get this exception when the file is in the...
1
by: Mchuck | last post by:
I've seen several newsgroup topics everywhere concerning this, as well as a couple of articles from the MSDN website, but this error still baffles me. It has to do with using the...
2
by: andycool1 | last post by:
I get the following error in my code when I set Option Strict to On: Option Strict On disallows implicit conversions from 'System.Object' to 'System.Drawing.Image' The blue error underline...
4
by: Darrel | last post by:
I'm grabbing a file from a file upload form field. This is a 'system.web.httppostedfile' I would like to modify the image (Cropping/scaling) using system.drawing.image. Is there anyway to go...
3
by: J | last post by:
I tried to inherit 'Shot' class from 'Image' class, only to fail. It gives me the CS0122 error, which says that it can't access 'System.Drawing.Image.Image()'. What am I missing? using...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
1
by: Martijn Mulder | last post by:
At startup my application loads an image from a file from disk. If the file is not there, I still need a valid System.Drawing.Image object but I don't know how to get one. //class MyImage...
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
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...
1
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.