mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
(YGA): support compressed images.
This commit is contained in:
@@ -33,6 +33,7 @@ namespace GameRes.Formats.Yaneurao
|
|||||||
internal class YgaMetaData : ImageMetaData
|
internal class YgaMetaData : ImageMetaData
|
||||||
{
|
{
|
||||||
public int UnpackedSize;
|
public int UnpackedSize;
|
||||||
|
public bool IsCompressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export(typeof(ImageFormat))]
|
[Export(typeof(ImageFormat))]
|
||||||
@@ -45,13 +46,15 @@ namespace GameRes.Formats.Yaneurao
|
|||||||
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
public override ImageMetaData ReadMetaData (IBinaryStream file)
|
||||||
{
|
{
|
||||||
var header = file.ReadHeader (0x18);
|
var header = file.ReadHeader (0x18);
|
||||||
if (header.ToInt32 (0xC) != 1)
|
int compression = header.ToInt32 (0xC);
|
||||||
|
if (compression > 1)
|
||||||
return null;
|
return null;
|
||||||
return new YgaMetaData {
|
return new YgaMetaData {
|
||||||
Width = header.ToUInt32 (4),
|
Width = header.ToUInt32 (4),
|
||||||
Height = header.ToUInt32 (8),
|
Height = header.ToUInt32 (8),
|
||||||
BPP = 32,
|
BPP = 32,
|
||||||
UnpackedSize = header.ToInt32 (0x10),
|
UnpackedSize = header.ToInt32 (0x10),
|
||||||
|
IsCompressed = compression != 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,12 +62,15 @@ namespace GameRes.Formats.Yaneurao
|
|||||||
{
|
{
|
||||||
var meta = (YgaMetaData)info;
|
var meta = (YgaMetaData)info;
|
||||||
file.Position = 0x18;
|
file.Position = 0x18;
|
||||||
using (var input = new LzssStream (file.AsStream, LzssMode.Decompress, true))
|
var pixels = new byte[meta.UnpackedSize];
|
||||||
|
if (meta.IsCompressed)
|
||||||
{
|
{
|
||||||
var pixels = new byte[meta.UnpackedSize];
|
using (var input = new LzssStream (file.AsStream, LzssMode.Decompress, true))
|
||||||
input.Read (pixels, 0, meta.UnpackedSize);
|
input.Read (pixels, 0, meta.UnpackedSize);
|
||||||
return ImageData.Create (info, PixelFormats.Bgra32, null, pixels);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
file.Read (pixels, 0, meta.UnpackedSize);
|
||||||
|
return ImageData.Create (info, PixelFormats.Bgra32, null, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Write (Stream file, ImageData image)
|
public override void Write (Stream file, ImageData image)
|
||||||
|
|||||||
Reference in New Issue
Block a user