本帖最后由 Lenka.Guo 于 2016-8-24 10:39 编辑
各位好
请教一下,在AR10里面明细数据中要显示图片,但是从DB检索出来的是需要进行转换
能不能直接赋值到setionreportmodel.picture的控件上
var image= (byte[])dt.Rows[0]["XMIMAGE"];
pic.Image = ByteToImg(image);
public Image ByteToImg(byte[] btImage)
{
var memStream = new MemoryStream();
//Stream memStream = null;
memStream.Write(btImage, 0, btImage.Length);
memStream.Position = 0;
memStream.Seek(0, SeekOrigin.Begin);
//Bitmap bmp = new Bitmap(memStream, true);
Image img;
try
{
img = Image.FromStream(memStream, true);
//memStream.Close();
//img = new Bitmap(memStream);
}
catch (Exception ex)
{
img = null;
SysRunLog.WriteTextLog("ByteToImg", ex.Message, ex.ToString(), DateTime.Now);
}
finally
{
memStream.Close();
GC.Collect();
}
|
|