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); }
}
XAF 如何将数据库中Byte array图片显示出来的更多相关文章
- [原] XAF 如何将数据库中Byte array图片显示出来
问题比较简单,直接上代码. private Image _Cover; [Size(SizeAttribute.Unlimited), ValueConverter(typeof(ImageValue ...
- C#从SQL server数据库中读取l图片和存入图片
原文:C#从SQL server数据库中读取l图片和存入图片 本实例主要介绍如何将图片存入数据库.将图片存入数据库,首先要在数据库中建立一张表,将存储图片的字段类型设为Image类型,用FileStr ...
- WPF如何将数据库中的二进制图片数据显示在Image控件上
首先在xaml文件里定义一个Image控件,取名为img MemoryStream stream = new MemoryStream(获得的数据库对象): BitMapImage bmp = new ...
- PHP上传图片,路径保存在数据库中,根据图片路径显示图片
1.创建数据表 CREATE TABLE image( id int(4) unsigned NOT NULL AUTO_INCREMENT, name varchar(100) default ...
- PHP ~ 通过程序删除图片,同时删除数据库中的图片数据 和 图片文件
删除单张图片 <?php require_once '../../conn.php'; //连接数据库 $ID = $_GET['ID' ...
- MVC下 把数据库中的byte[]值保存成图片,并显示在view页面
MVC下 把数据库中的byte[]值转成图片,并显示在view页面 controller中的action方法 //显示图片[AllowAnonymous]public ActionResult Sho ...
- 根据数据库帮助类采用事务插入图片到sql server数据库中
我们定义数据库为image类型,然后读取图片为字符流,再保存到数据库中,首先我们定义一个读取图片的公共类,此公共类以后会用到,所以可以建立相应的帮助类 public static byte[] Rea ...
- [转]asp.net mvc 从数据库中读取图片
本文转自:http://www.cnblogs.com/mayt/archive/2010/05/20/1740358.html 首先是创建一个类,继承于ActionResult,记住要引用Syste ...
- asp.net mvc 从数据库中读取图片的实现代码
首先是创建一个类,继承于ActionResult,记住要引用System.Web.Mvc命名空间,如下: public class ImageResult : ActionResult { publi ...
随机推荐
- phpexcel引入MVC框架会导致__autoload引入类文件失败的解决办法
Autoloader.php 的register和load方法 register方法 if (function_exists('__autoload')) { // Register any exis ...
- ansible-copy
ansible是执行yaml文件控制远端服务器.执行命令为 ansible-playbook my.yamlplaybook是ansible中的脚本,采用yaml语言.VM1安装ansible,ip地 ...
- alfresco category searches...
From page 475 of the Alfresco Developer Guide- Category searches use the PATH field, but you constru ...
- Android新权限机制 AppOps
http://blog.csdn.net/hyhyl1990/article/details/46842915 http://m.blog.csdn.net/article/details?id=51 ...
- maxscale
一.maxscale简介1.MaxScale是maridb开发的一个mysql数据中间件,其配置简单,能够实现读写分离,并且可以根据主从状态实现写库的自动切换.2.官网:https://mariadb ...
- Thinking in Java——笔记(17)
Containers in Depth Full container taxonomy You can usually ignore any class that begins with " ...
- 前端开发自学之JavaScript——显示当前时间
<html> <head> <title>JavaScript</title> <script language="javascript ...
- Find Missing Term in Arithmetic Progression 等差数列缺失项
查找等差数列中的缺失项. e.g.Input: arr[] = {2, 4, 8, 10, 12, 14} Output: 6 Input: arr[] = {1, 6, 11, 16, 21, 31 ...
- Windows RabbitMQ 命令
启动: 后台运行:rabbitmq-server -detached D:\Program Files\RabbitMQ Server\rabbitmq_server-3.6.6\sbin>ra ...
- ORA-03113: end-of-file on communication channel
导致的原因,可能是异常断电导致文件状态不一致. SQL> startupORACLE instance started. Total System Global Area 1653518336 ...