mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-05 03:15:36 +08:00
(MG2): could contain JPEG images.
This commit is contained in:
parent
8c06c4356d
commit
1edd79c74d
@ -36,6 +36,7 @@ namespace GameRes.Formats.Valkyria
|
|||||||
public int ImageLength;
|
public int ImageLength;
|
||||||
public int AlphaLength;
|
public int AlphaLength;
|
||||||
public IMg2Scheme Scheme;
|
public IMg2Scheme Scheme;
|
||||||
|
public ImageFormat Format;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal interface IMg2Scheme
|
internal interface IMg2Scheme
|
||||||
@ -62,9 +63,16 @@ namespace GameRes.Formats.Valkyria
|
|||||||
foreach (var scheme in KnownSchemes)
|
foreach (var scheme in KnownSchemes)
|
||||||
{
|
{
|
||||||
using (var input = scheme.CreateStream (file.AsStream, 0x10, length))
|
using (var input = scheme.CreateStream (file.AsStream, 0x10, length))
|
||||||
using (var png = new BinaryStream (input, file.Name))
|
using (var img = new BinaryStream (input, file.Name))
|
||||||
{
|
{
|
||||||
var info = Png.ReadMetaData (png);
|
ImageFormat format;
|
||||||
|
if (Png.Signature == img.Signature)
|
||||||
|
format = Png;
|
||||||
|
else if (0xE0FFD8FF == img.Signature)
|
||||||
|
format = Jpeg;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
var info = format.ReadMetaData (img);
|
||||||
if (null == info)
|
if (null == info)
|
||||||
continue;
|
continue;
|
||||||
return new Mg2MetaData
|
return new Mg2MetaData
|
||||||
@ -77,6 +85,7 @@ namespace GameRes.Formats.Valkyria
|
|||||||
ImageLength = length,
|
ImageLength = length,
|
||||||
AlphaLength = header.ToInt32 (12),
|
AlphaLength = header.ToInt32 (12),
|
||||||
Scheme = scheme,
|
Scheme = scheme,
|
||||||
|
Format = format,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,9 +103,10 @@ namespace GameRes.Formats.Valkyria
|
|||||||
{
|
{
|
||||||
BitmapSource frame;
|
BitmapSource frame;
|
||||||
using (var input = meta.Scheme.CreateStream (file, 0x10, meta.ImageLength))
|
using (var input = meta.Scheme.CreateStream (file, 0x10, meta.ImageLength))
|
||||||
|
using (var img = new BinaryStream (input, meta.FileName))
|
||||||
{
|
{
|
||||||
var decoder = new PngBitmapDecoder (input, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
var image = meta.Format.Read (img, meta);
|
||||||
frame = decoder.Frames[0];
|
frame = image.Bitmap;
|
||||||
if (0 == meta.AlphaLength)
|
if (0 == meta.AlphaLength)
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user