Skip to content

Commit

Permalink
fix parisng atf format version < 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Gl0 committed Jul 6, 2018
1 parent 7113652 commit 5975850
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions ATF/Atf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class ATFReader {
uint length = 0;
if (b[3] != 0xff) {
_version = 0;
length = (uint)b[0] << 16 + b[1] << 8 + b[2];
length = ((uint)b[0] << 16) + ((uint)b[1] << 8) + b[2];
reader.BaseStream.Position = reader.BaseStream.Position - 1;
}
else {
_version = reader.ReadByte();
Expand All @@ -60,7 +61,8 @@ public class ATFReader {
_height = 1 << reader.ReadByte();
_mipCount = reader.ReadByte();
//currently we are interested only in highest quality texture and don't bother about cubemaps, so extract only first one.
length = BitConverter.IsLittleEndian ? BitConverter.ToUInt32(reader.ReadBytes(4).Reverse().ToArray(), 0) : reader.ReadUInt32();
if (_version == 0) { b = reader.ReadBytes(3); length = ((uint)b[0] << 16) + ((uint)b[1] << 8) + b[2]; }
else length = BitConverter.IsLittleEndian ? BitConverter.ToUInt32(reader.ReadBytes(4).Reverse().ToArray(), 0) : reader.ReadUInt32();
byte[] image;
if (_atfFormat == ATFFormat.ATFRAWCOMPRESSED) { image = DxtUtil.DecompressDxt1(reader.ReadBytes((int) length), _width, _height); }
else if (_atfFormat == ATFFormat.ATFRAWCOMPRESSEDALPHA) { image = DxtUtil.DecompressDxt5(reader.ReadBytes((int)length), _width, _height); }
Expand Down
4 changes: 2 additions & 2 deletions ATF/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
4 changes: 2 additions & 2 deletions atf2png/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

0 comments on commit 5975850

Please sign in to comment.