
正文
从byte数组byte[]转换为bitmapsource以及反射实现属性批量赋值
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
从byte数组byte[]转换为bitmapsource
(BitmapSource)new ImageSourceConverter().ConvertFrom(b)
名字有规律的属性代码用反射优美实现
for(int i=;i<imageList.Tables[].Rows.Count;i++)
{
if(imageList.Tables[].Rows[i]!=null)
{
System.Data.DataRow tab = imageList.Tables[].Rows[i];
BitmapSource source=(BitmapSource)new ImageSourceConverter().ConvertFrom((byte[])tab.ItemArray[]);
System.Reflection.PropertyInfo propertyInfo=this.GetType().GetProperty("Image" + (i + ));
propertyInfo.SetValue(this, source, null);
} }







