如何使用wpf(c#)存储图像并从ms访问中检索 [英] how to store images and retrieving from ms access using wpf(c#)
本文介绍了如何使用wpf(c#)存储图像并从ms访问中检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨...
我使用来自网络摄像头的wpf将图像存储为ms访问的ole对象类型。存储的图像如下:
Hi...
I am storing images as ole object type in ms access using wpf from webcam. Am stored image as like:
byte[] FileBytes = null;
string imgpath = "PatientsPhotos/" + lbl_patientID.Content.ToString() + ".jpg";
FileStream fs = new FileStream(imgpath,System.IO.FileMode.Open,System.IO.FileAccess.Read);
BinaryReader BR = new BinaryReader(fs);
long allbytes = new FileInfo(imgpath).Length;
FileBytes = BR.ReadBytes((Int32)allbytes);
这里lbl_patientID.Content是图像的名称。
现在我如何才能使用wpf将图像从db显示(图像控制)到图像控件中。
帮助我,谢谢你。
Here lbl_patientID.Content is name of image.
Now how can i get(display) image from db into image control using wpf only.
help me pls, Thank u.
推荐答案
查看此处的讨论:
http://stackoverflow.com/questions/2416497/converting-an-ole-image-object-from-ms-access-for-use-in-net [< a href =http://stackoverflow.com/questions/2416497/converting-an-ole-image-object-from-ms-access-for-use-in-nettarget =_ blanktitle =新窗口> ^ ]
Check the discussion here:
http://stackoverflow.com/questions/2416497/converting-an-ole-image-object-from-ms-access-for-use-in-net[^]
嗨...
创建数据表,如:
表:
Id int,图像OLE对象
在 .cs :(用于插入)
Hi...
Create data table like:
Table:
Id int, Image OLE Object
In .cs:(for insert)
//Convert img into bytes
byte[] FileBytes = null;
string imgpath = "PatientsPhotos/" + lbl_patientID.Content.ToString() + ".jpg";
FileStream fs = new FileStream(imgpath,System.IO.FileMode.Open,System.IO.FileAccess.Read);
BinaryReader BR = new BinaryReader(fs);
long allbytes = new FileInfo(imgpath).Length;
FileBytes = BR.ReadBytes((Int32)allbytes);
patient.imagepath = FileBytes;
Then, insert 'imagepath' into table of Image place
and retrieving imagepath from table and convert into image like below:
ImageSourceConverter imgConv = new ImageSourceConverter();
string path = ("PatientsPhotos/" + this.pt_id + ".jpg");
ImageSource imageSource = (ImageSource)imgConv.ConvertFromString(path);
imgVideo.Source = imageSource;
谢谢你。
Thank u.
这篇关于如何使用wpf(c#)存储图像并从ms访问中检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文