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); }
            } 
  • 相关阅读:
    Netty 超时机制及心跳程序实现
    ZJUTACM
    寻找素数对
    HDU 1021 Fibonacci Again
    HDU 1019 Least Common Multiple
    HDU 1017 A Mathematical Curiosity
    HDU 1014 Uniform Generator
    HDU 1013 Digital Roots
    HDU 1008 Elevator
    Educational Codeforces Round 2 B. Queries about less or equal elements
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/3342784.html
Copyright © 2011-2022 走看看