mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 12:39:16 +08:00
use ImageData.Create method instead of BitmapSource.Create.
This commit is contained in:
parent
43b1631e67
commit
2d1f18903a
@ -141,11 +141,7 @@ namespace GameRes.Formats.AdPack
|
|||||||
using (var reader = new Reader (stream, meta))
|
using (var reader = new Reader (stream, meta))
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
byte[] pixels = reader.Data;
|
return ImageData.Create (meta, PixelFormats.Bgr24, null, reader.Data, (int)meta.Width*3);
|
||||||
var bitmap = BitmapSource.Create ((int)meta.Width, (int)meta.Height, 96, 96,
|
|
||||||
PixelFormats.Bgr24, null, pixels, (int)meta.Width*3);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, meta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,12 +317,8 @@ namespace GameRes.Formats.AdPack
|
|||||||
stream.Position = 0x1a;
|
stream.Position = 0x1a;
|
||||||
var reader = new Reader (stream, meta);
|
var reader = new Reader (stream, meta);
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
byte[] pixels = reader.Data;
|
|
||||||
var palette = new BitmapPalette (reader.Palette);
|
var palette = new BitmapPalette (reader.Palette);
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.Create (info, PixelFormats.Indexed8, palette, reader.Data, (int)info.Width);
|
||||||
PixelFormats.Indexed8, palette, pixels, (int)info.Width);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Reader : BitReader
|
internal class Reader : BitReader
|
||||||
|
@ -87,13 +87,9 @@ namespace GameRes.Formats.AliceSoft
|
|||||||
using (var reader = new Reader (stream, meta))
|
using (var reader = new Reader (stream, meta))
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
var pixels = reader.Data;
|
|
||||||
int stride = (int)info.Width * (reader.BPP / 8);
|
int stride = (int)info.Width * (reader.BPP / 8);
|
||||||
PixelFormat format = 24 == reader.BPP ? PixelFormats.Bgr24 : PixelFormats.Bgra32;
|
PixelFormat format = 24 == reader.BPP ? PixelFormats.Bgr24 : PixelFormats.Bgra32;
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.Create (info, format, null, reader.Data, stride);
|
||||||
format, null, pixels, stride);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,19 +108,10 @@ namespace GameRes.Formats.CatSystem
|
|||||||
decoder.Unpack();
|
decoder.Unpack();
|
||||||
var pixels = decoder.Data;
|
var pixels = decoder.Data;
|
||||||
int stride = (int)info.Width * 4;
|
int stride = (int)info.Width * 4;
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
|
||||||
PixelFormats.Bgra32, null, pixels, stride);
|
|
||||||
if (flipped)
|
if (flipped)
|
||||||
{
|
return ImageData.CreateFlipped (info, PixelFormats.Bgra32, null, pixels, stride);
|
||||||
var flipped_bitmap = new TransformedBitmap();
|
else
|
||||||
flipped_bitmap.BeginInit();
|
return ImageData.Create (info, PixelFormats.Bgra32, null, pixels, stride);
|
||||||
flipped_bitmap.Source = bitmap;
|
|
||||||
flipped_bitmap.Transform = new ScaleTransform { ScaleY = -1 };
|
|
||||||
flipped_bitmap.EndInit();
|
|
||||||
bitmap = flipped_bitmap;
|
|
||||||
}
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,7 @@ namespace GameRes.Formats.BlackRainbow
|
|||||||
{
|
{
|
||||||
PixelFormat format = meta.Flag != 0 ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
PixelFormat format = meta.Flag != 0 ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
byte[] pixels = reader.Data;
|
return ImageData.Create (meta, format, null, reader.Data, (int)meta.Width*4);
|
||||||
var bitmap = BitmapSource.Create ((int)meta.Width, (int)meta.Height, 96, 96,
|
|
||||||
format, null, pixels, (int)meta.Width*4);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, meta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +93,7 @@ namespace GameRes.Formats.Ikura
|
|||||||
var pixel_data = DecodeStream (file, stride*(int)info.Height);
|
var pixel_data = DecodeStream (file, stride*(int)info.Height);
|
||||||
if (null == pixel_data)
|
if (null == pixel_data)
|
||||||
throw new InvalidFormatException();
|
throw new InvalidFormatException();
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.Create (info, format, null, pixel_data, stride);
|
||||||
format, null, pixel_data, stride);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] DecodeStream (Stream input, int pixel_count)
|
byte[] DecodeStream (Stream input, int pixel_count)
|
||||||
|
@ -146,11 +146,7 @@ namespace GameRes.Formats.Ainos
|
|||||||
reader.UnpackRGB();
|
reader.UnpackRGB();
|
||||||
else
|
else
|
||||||
reader.UnpackIndexed();
|
reader.UnpackIndexed();
|
||||||
byte[] pixels = reader.Data;
|
return ImageData.Create (info, PixelFormats.Bgr24, null, reader.Data, (int)info.Width*3);
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
|
||||||
PixelFormats.Bgr24, null, pixels, (int)info.Width*3);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +92,8 @@ namespace GameRes.Formats.ISM
|
|||||||
input.Unpack21();
|
input.Unpack21();
|
||||||
else
|
else
|
||||||
input.Unpack10();
|
input.Unpack10();
|
||||||
byte[] pixels = input.Data;
|
|
||||||
var palette = new BitmapPalette (input.Palette);
|
var palette = new BitmapPalette (input.Palette);
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.CreateFlipped (info, PixelFormats.Indexed8, palette, input.Data, (int)info.Width);
|
||||||
PixelFormats.Indexed8, palette, pixels, (int)info.Width);
|
|
||||||
var flipped = new TransformedBitmap (bitmap, new ScaleTransform { ScaleY = -1 });
|
|
||||||
flipped.Freeze();
|
|
||||||
return new ImageData (flipped, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +91,7 @@ namespace GameRes.Formats.MAI
|
|||||||
|
|
||||||
var reader = new Reader (stream, meta);
|
var reader = new Reader (stream, meta);
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height,
|
return ImageData.CreateFlipped (info, reader.Format, reader.Palette, reader.Data, reader.Stride);
|
||||||
ImageData.DefaultDpiX, ImageData.DefaultDpiY,
|
|
||||||
reader.Format, reader.Palette, reader.Data, reader.Stride);
|
|
||||||
var flipped = new TransformedBitmap (bitmap, new ScaleTransform { ScaleY = -1 });
|
|
||||||
flipped.Freeze();
|
|
||||||
return new ImageData (flipped, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Reader
|
internal class Reader
|
||||||
|
@ -102,11 +102,7 @@ namespace GameRes.Formats.KAAS
|
|||||||
using (var reader = new Reader (stream, meta))
|
using (var reader = new Reader (stream, meta))
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
byte[] pixels = reader.Data;
|
return ImageData.Create (meta, PixelFormats.Bgr24, null, reader.Data, (int)meta.Width*3);
|
||||||
var bitmap = BitmapSource.Create ((int)meta.Width, (int)meta.Height, 96, 96,
|
|
||||||
PixelFormats.Bgr24, null, pixels, (int)meta.Width*3);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, meta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
{
|
{
|
||||||
int stride = width * 4;
|
int stride = width * 4;
|
||||||
PixelFormat format = 32 == info.BPP ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
PixelFormat format = 32 == info.BPP ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
||||||
var bitmap = BitmapSource.Create(width, height, 96, 96,
|
var bitmap = BitmapSource.Create(width, height, ImageData.DefaultDpiX, ImageData.DefaultDpiY,
|
||||||
format, null, (IntPtr) data, height * stride, stride);
|
format, null, (IntPtr) data, height * stride, stride);
|
||||||
bitmap.Freeze();
|
bitmap.Freeze();
|
||||||
return new ImageData(bitmap, info);
|
return new ImageData(bitmap, info);
|
||||||
@ -369,10 +369,7 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PixelFormat format = 4 == colors ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
PixelFormat format = 4 == colors ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
||||||
var bitmap = BitmapSource.Create (width, height, 96, 96,
|
return ImageData.Create (info, format, null, image_bits, stride);
|
||||||
format, null, image_bits, stride);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -611,12 +611,8 @@ namespace GameRes.Formats.Majiro
|
|||||||
using (var reader = new Reader (file, info))
|
using (var reader = new Reader (file, info))
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
byte[] pixels = reader.Data;
|
|
||||||
var palette = new BitmapPalette (reader.Palette);
|
var palette = new BitmapPalette (reader.Palette);
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.Create (info, PixelFormats.Indexed8, palette, reader.Data, (int)info.Width);
|
||||||
PixelFormats.Indexed8, palette, pixels, (int)info.Width);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,11 +81,7 @@ namespace GameRes.Formats.Marble
|
|||||||
using (var reader = new Reader (stream, meta))
|
using (var reader = new Reader (stream, meta))
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
byte[] pixels = reader.Data;
|
return ImageData.Create (meta, PixelFormats.Bgr24, null, reader.Data, (int)meta.Width*3);
|
||||||
var bitmap = BitmapSource.Create ((int)meta.Width, (int)meta.Height, 96, 96,
|
|
||||||
PixelFormats.Bgr24, null, pixels, (int)meta.Width*3);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, meta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,17 +87,12 @@ namespace GameRes.Formats.MnoViolet
|
|||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
int stride = (int)info.Width*info.BPP/8;
|
int stride = (int)info.Width*info.BPP/8;
|
||||||
var pixels = reader.Data;
|
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
if (24 == info.BPP)
|
if (24 == info.BPP)
|
||||||
format = PixelFormats.Bgr24;
|
format = PixelFormats.Bgr24;
|
||||||
else
|
else
|
||||||
format = PixelFormats.Gray8;
|
format = PixelFormats.Gray8;
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.CreateFlipped (info, format, null, reader.Data, stride);
|
||||||
format, null, pixels, stride);
|
|
||||||
var flipped = new TransformedBitmap (bitmap, new ScaleTransform { ScaleY = -1 });
|
|
||||||
flipped.Freeze();
|
|
||||||
return new ImageData (flipped, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,11 +100,7 @@ namespace GameRes.Formats.Silky
|
|||||||
format = PixelFormats.Bgra32;
|
format = PixelFormats.Bgra32;
|
||||||
else
|
else
|
||||||
format = PixelFormats.Gray8;
|
format = PixelFormats.Gray8;
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height,
|
return ImageData.CreateFlipped (info, format, null, pixels, stride);
|
||||||
ImageData.DefaultDpiX, ImageData.DefaultDpiY, format, null, pixels, stride);
|
|
||||||
var flipped = new TransformedBitmap (bitmap, new ScaleTransform { ScaleY = -1 });
|
|
||||||
flipped.Freeze();
|
|
||||||
return new ImageData (flipped, info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write (Stream file, ImageData image)
|
public override void Write (Stream file, ImageData image)
|
||||||
|
@ -107,10 +107,7 @@ namespace GameRes.Formats.Silky
|
|||||||
format = PixelFormats.Bgr24;
|
format = PixelFormats.Bgr24;
|
||||||
else
|
else
|
||||||
format = PixelFormats.Bgra32;
|
format = PixelFormats.Bgra32;
|
||||||
var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96,
|
return ImageData.Create (info, format, null, pixels, meta.Stride);
|
||||||
format, null, pixels, meta.Stride);
|
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, info);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,6 @@ namespace GameRes.Formats.Will
|
|||||||
using (var reader = new Reader (file, meta))
|
using (var reader = new Reader (file, meta))
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
BitmapSource bitmap;
|
|
||||||
if (24 == meta.BPP)
|
if (24 == meta.BPP)
|
||||||
{
|
{
|
||||||
byte[] raw = reader.Data;
|
byte[] raw = reader.Data;
|
||||||
@ -123,19 +122,16 @@ namespace GameRes.Formats.Will
|
|||||||
pixels[i*3+1] = raw[i+size];
|
pixels[i*3+1] = raw[i+size];
|
||||||
pixels[i*3+2] = raw[i+size*2];
|
pixels[i*3+2] = raw[i+size*2];
|
||||||
}
|
}
|
||||||
bitmap = BitmapSource.Create ((int)meta.Width, (int)meta.Height, 96, 96,
|
return ImageData.Create (meta, PixelFormats.Bgr24, null, pixels, (int)meta.Width*3);
|
||||||
PixelFormats.Bgr24, null, pixels, (int)meta.Width*3);
|
|
||||||
}
|
}
|
||||||
else if (8 == meta.BPP)
|
else if (8 == meta.BPP)
|
||||||
{
|
{
|
||||||
byte[] pixels = reader.Data;
|
byte[] pixels = reader.Data;
|
||||||
bitmap = BitmapSource.Create ((int)meta.Width, (int)meta.Height, 96, 96,
|
var bmp_palette = new BitmapPalette (palette);
|
||||||
PixelFormats.Indexed8, new BitmapPalette (palette), pixels, (int)meta.Width);
|
return ImageData.Create (meta, PixelFormats.Indexed8, bmp_palette, pixels, (int)meta.Width);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw new InvalidFormatException();
|
throw new InvalidFormatException();
|
||||||
bitmap.Freeze();
|
|
||||||
return new ImageData (bitmap, meta);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user