mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-25 12:24:12 +08:00
another variation of kaguya 'parts' images.
This commit is contained in:
parent
61def57667
commit
0a2b1f1583
@ -77,6 +77,12 @@ namespace GameRes.Formats.Kaguya
|
|||||||
uint data_size = reader.ReadUInt32();
|
uint data_size = reader.ReadUInt32();
|
||||||
if (data_size > stream.Length-stream.Position)
|
if (data_size > stream.Length-stream.Position)
|
||||||
return null;
|
return null;
|
||||||
|
return ReadCompressionMetaData (reader, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ApsMetaData ReadCompressionMetaData (BinaryReader reader, Rectangle rect)
|
||||||
|
{
|
||||||
int compression = reader.ReadInt16();
|
int compression = reader.ReadInt16();
|
||||||
var info = new ApsMetaData
|
var info = new ApsMetaData
|
||||||
{
|
{
|
||||||
@ -96,10 +102,9 @@ namespace GameRes.Formats.Kaguya
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
info.DataOffset = (uint)stream.Position;
|
info.DataOffset = (uint)reader.BaseStream.Position;
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||||
{
|
{
|
||||||
@ -133,4 +138,58 @@ namespace GameRes.Formats.Kaguya
|
|||||||
throw new System.NotImplementedException ("Aps3Format.Write not implemented");
|
throw new System.NotImplementedException ("Aps3Format.Write not implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Export(typeof(ImageFormat))]
|
||||||
|
public class ApsFormat : Aps3Format
|
||||||
|
{
|
||||||
|
public override string Tag { get { return "APS"; } }
|
||||||
|
public override string Description { get { return "KaGuYa tiled image format"; } }
|
||||||
|
public override uint Signature { get { return 0; } }
|
||||||
|
|
||||||
|
public ApsFormat ()
|
||||||
|
{
|
||||||
|
Extensions = new string[] { "aps", "parts" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ImageMetaData ReadMetaData (Stream stream)
|
||||||
|
{
|
||||||
|
using (var reader = new ArcView.Reader (stream))
|
||||||
|
{
|
||||||
|
int name_count = reader.ReadInt16();
|
||||||
|
if (name_count <= 0 || name_count > 1000)
|
||||||
|
return null;
|
||||||
|
for (int i = 0; i < name_count; ++i)
|
||||||
|
{
|
||||||
|
int name_length = reader.ReadInt32();
|
||||||
|
if (name_length <= 0 || name_length > 260)
|
||||||
|
return null;
|
||||||
|
stream.Seek (name_length, SeekOrigin.Current);
|
||||||
|
}
|
||||||
|
int tile_count = reader.ReadInt16();
|
||||||
|
if (tile_count <= 0 || tile_count > 1000)
|
||||||
|
return null;
|
||||||
|
var rect = new Rectangle (0, 0, 0, 0);
|
||||||
|
for (int i = 0; i < tile_count; ++i)
|
||||||
|
{
|
||||||
|
int name_length = reader.ReadInt32();
|
||||||
|
if (name_length <= 0 || name_length > 260)
|
||||||
|
return null;
|
||||||
|
stream.Seek (name_length+0xC, SeekOrigin.Current);
|
||||||
|
int x = reader.ReadInt32();
|
||||||
|
int y = reader.ReadInt32();
|
||||||
|
int w = reader.ReadInt32() - x;
|
||||||
|
int h = reader.ReadInt32() - y;
|
||||||
|
var part_rect = new Rectangle (x, y, w, h);
|
||||||
|
rect = Rectangle.Union (rect, part_rect);
|
||||||
|
stream.Seek (0x28, SeekOrigin.Current);
|
||||||
|
}
|
||||||
|
return ReadCompressionMetaData (reader, rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write (Stream file, ImageData image)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException ("ApsFormat.Write not implemented");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user