mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 13:45:34 +08:00
(ImageData.Create): new convenient static method.
This commit is contained in:
parent
1342736ee6
commit
0a3fe37bb0
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user