(ImageData.Create): new convenient static method.

This commit is contained in:
morkt 2015-04-20 14:04:46 +04:00
parent 1342736ee6
commit 0a3fe37bb0

View File

@ -24,6 +24,7 @@
//
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace GameRes
@ -66,6 +67,16 @@ namespace GameRes
OffsetX = x;
OffsetY = y;
}
public static ImageData Create (ImageMetaData info, PixelFormat format, BitmapPalette palette,
byte[] pixel_data)
{
int stride = (int)info.Width*((format.BitsPerPixel+7)/8);
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
format, palette, pixel_data, stride);
bitmap.Freeze();
return new ImageData (bitmap, info);
}
}
public abstract class ImageFormat : IResource