32 lines
904 B
C#
32 lines
904 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace RoleEditor
|
|
{
|
|
public static class Util
|
|
{
|
|
public static BitmapImage? LoadImage (byte[] imageData)
|
|
{
|
|
if (imageData == null || imageData.Length == 0) return null;
|
|
var image = new BitmapImage();
|
|
using (var mem = new MemoryStream(imageData))
|
|
{
|
|
mem.Position = 0;
|
|
image.BeginInit();
|
|
image.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
|
|
image.CacheOption = BitmapCacheOption.OnLoad;
|
|
image.UriSource = null;
|
|
image.StreamSource = mem;
|
|
image.EndInit();
|
|
}
|
|
image.Freeze();
|
|
return image;
|
|
}
|
|
}
|
|
}
|