zoukankan      html  css  js  c++  java
  • [原] XAF 如何将数据库中Byte array图片显示出来

    问题比较简单,直接上代码.

    private Image _Cover; [Size(SizeAttribute.Unlimited), ValueConverter(typeof(ImageValueConverter))] public Image Cover { get { if (_Cover == null && _Photo != null && _Photo.Length > 0) { using (MemoryStream stream = new System.IO.MemoryStream(_Photo)) { System.Drawing.Image image = System.Drawing.Image.FromStream(stream); _Cover = image; return _Cover; } } return _Cover; } set { SetPropertyValue("Cover", ref _Cover, value); } } private Byte[] _Photo; //[Delayed] public Byte[] Photo { get { return _Photo; } set { //byte[] imagedata = null; //if (Cover != null) //{ // MemoryStream ms = new MemoryStream(); // Image im = new Bitmap(Cover); // im.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); // imagedata = ms.GetBuffer(); // _Photo = imagedata; //} SetPropertyValue("Photo", ref _Photo, value); } }

     XAF自带,varbinary(Max)类型图片操作方法:

       Image fPhoto;
            [ValueConverter(typeof(ImageValueConverter)), Delayed]
            public Image Photo
            {
                get { return fPhoto; }
                set { SetPropertyValue("Photo", ref fPhoto, value); }
            } 
  • 相关阅读:
    创建文件夹 文件File操作方法
    C#WinForm4张纸牌窗体设计
    b/s结构和c/s结构
    sql 中 时间只显示日期
    视图
    js获取字符串的字节数
    触发器
    将xml字符串转换成dataset
    sql 集合查询 数据更新操作语句
    带有ANY(SOME)或ALL谓词的字查询
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/3342784.html
Copyright © 2011-2022 走看看