开发者

Load a picturebox from a WIA ImageFile?

I've taken over a poorly designed project from a co-worker and am looking to load a picture box directly from the WIA command that just completed to take a picture from an attached USB camera.

The current implementation waits until the file has been written to disk, then displays it from there probably re-reading the file from disk.

Item item = d.ExecuteCommand(WIA.CommandID.wiaCommandTakePicture);

WIA.ImageFile imagefile = item.Transfer(FormatID.wiaFormatJP开发者_开发百科EG) as WIA.ImageFile;

I tried casting an Image to the given picture box without success

picBox.Image = (Image)imageFile;


WIA.ImageFile is a COM object wrapper, not a System.Drawing.Image.

You'll have to mess with WIA.ImageFile Save method with temporary files or try in-memory solution as shown here: http://www.pcreview.co.uk/forums/wia-imagefile-system-drawing-image-t2321026.html

var imageBytes = (byte[])image.FileData.get_BinaryData(); 
var ms = new MemoryStream(imageBytes);
var img = Image.FromStream(ms);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜