Skip to content

Commit

Permalink
v2.5 and BC7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeG621 committed Dec 18, 2023
1 parent ac11b80 commit 40db848
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 78 deletions.
14 changes: 8 additions & 6 deletions DAT_Image_File.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ etc. Portions of the format are similar or directly ripped from the .ACT format
of TIE and XvT. The images are separated into "Groups" and "Subs", with the
Group being the base image, and the Sub being variants or animation frames.

**NOTE** Addition of BC7 is WIP, not all information has been added **
=====
DAT Structure

Expand Down Expand Up @@ -62,14 +61,15 @@ struct Sub
0x00 SubHeader
0x12 ImageHeader
0x3E Colors[ImageHeader.NumberOfColors]
#if (Type!=25C)
Row[Height]
#else
#if (Type==25C)
0x3E BYTE[5] CompressionParameters
0x43 BYTE[] LzmaData
#elseif (Type==BC7)
0x3E BYTE[] EncodedBlockData
#else Row[Height]
#endif
#if (Type==7 || Type==23)
BYTE Reserved (0)
BYTE Reserved (0)
#endif
}

Expand Down Expand Up @@ -324,4 +324,6 @@ Type "BC7"; BCn compressed, requires 32-bit hook. The data length is the size
of the padded area, with padding up to multiples of 4 in both width and height.
((Width+3)/4 * 4) * ((Height+3)/4 * 4). Note that for dimensions that are
already divisible by 4, this is simply Width * Height. Pixels are run through
the compression algorithm in 4x4 blocks.
the compression algorithm in 4x4 blocks. The full details of how BCn works is
left to you if you're curious, I'm using an external source for the algorithm
instead of trying to recreate it.
26 changes: 13 additions & 13 deletions DatFile.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Idmr.ImageFormat.Dat, Allows editing capability of LA *.DAT Image files
* Copyright (C) 2009-2022 Michael Gaisser (mjgaisser@gmail.com)
* Copyright (C) 2009-2023 Michael Gaisser (mjgaisser@gmail.com)
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the Mozilla Public License; either version 2.0 of the
Expand Down Expand Up @@ -35,9 +35,9 @@
* [UPD] Group/Sub converted to class
*/

using Idmr.Common;
using System;
using System.IO;
using Idmr.Common;

namespace Idmr.ImageFormat.Dat
{
Expand Down Expand Up @@ -70,7 +70,7 @@ public DatFile(string file)
}
catch (Exception x)
{
if (fs != null) fs.Close();
fs?.Close();
throw new LoadFileException(x);
}
_filePath = file;
Expand Down Expand Up @@ -133,7 +133,7 @@ public void Save()
}
catch (Exception x)
{
if (fs != null) fs.Close();
fs?.Close();
if (File.Exists(tempFile)) File.Copy(tempFile, _filePath); // restore backup if it exists
File.Delete(tempFile); // delete backup if it exists
throw new SaveFileException(x);
Expand Down Expand Up @@ -188,21 +188,21 @@ public void DecodeFile(byte[] rawData)
}
}
#endregion public methods

#region public properties
/// <summary>Gets the file name of the Dat object</summary>
/// <remarks>Value is <see cref="FilePath"/> without the directory</remarks>
public string FileName { get { return StringFunctions.GetFileName(_filePath); } }
public string FileName => StringFunctions.GetFileName(_filePath);

/// <summary>Gets the full path of the Dat object</summary>
/// <remarks>Defaults to <b>"newfile.dat"</b></remarks>
public string FilePath { get { return _filePath; } }
public string FilePath => _filePath;

/// <summary>Gets the Collection of Groups in the archive</summary>
public GroupCollection Groups { get; internal set; }

/// <summary>Gets the number of Groups in the archive</summary>
public short NumberOfGroups { get { return (short)Groups.Count; } }
public short NumberOfGroups => (short)Groups.Count;

/// <summary>Gets the maximum height used for all images</summary>
public short UsedHeight
Expand Down Expand Up @@ -254,7 +254,7 @@ int length
return l;
}
}
int dataOffset { get { return NumberOfGroups * Group._headerLength; } }

int dataOffset => NumberOfGroups * Group._headerLength;
}
}
9 changes: 9 additions & 0 deletions ImageFormat.Dat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@
</None>
</ItemGroup>
<ItemGroup>
<None Include="JeremyAnsel.BcnSharpLib32.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="JeremyAnsel.BcnSharpLib64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="License.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="MIT License.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Readme.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
Binary file added JeremyAnsel.BcnSharpLib32.dll
Binary file not shown.
Binary file added JeremyAnsel.BcnSharpLib64.dll
Binary file not shown.
21 changes: 21 additions & 0 deletions MIT License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020-2021 Richard Geldreich, Jr, 2023 J�r�my Ansel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Imperial Department of Military Research")]
[assembly: AssemblyProduct("Idmr.ImageFormat.Dat")]
[assembly: AssemblyCopyright("Copyright © Michael Gaisser 2009-2022")]
[assembly: AssemblyCopyright("Copyright © Michael Gaisser 2009-2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Major.Minor.Build.Revision
[assembly: AssemblyVersion("2.4.*")]
[assembly: AssemblyVersion("2.5.*")]
15 changes: 11 additions & 4 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ Idmr.ImageFormat.Dat.dll
========================

Author: Michael Gaisser (mjgaisser@gmail.com)
Version: 2.4
Date: 2022.02.27
Version: 2.5
Date: 2023.12.18

Library for reading LucasArts *.DAT backdrop files

==========
Version History

- BC7 format detection, currently unsupported and returns a blank image
v2.5 - 18 Dec 2023
- Added BC7 format capability

v2.4 - 27 Feb 2022
- Added Format 25C capability
Expand Down Expand Up @@ -58,6 +59,8 @@ Additional Information
Instructions:
- Get latest version of Idmr.Common.dll (v1.1 or later)
- Add Idmr.Common.dll and Idmr.ImageFormat.Dat.dll to your references
- Add both JeremyAnsel.BcnSharpLib32.dll and ~64.dll to the build directory
for use as external references.

File format structure can be found in DAT_Image_File.txt

Expand All @@ -66,12 +69,16 @@ Programmer's reference can be found in help/Idmr.ImageFormat.Dat.chm
==========
Copyright Information

Copyright (C) Michael Gaisser, 2009-2022
Copyright (C) Michael Gaisser, 2009-2023
This library file and related files are licensed under the Mozilla Public License
v2.0 or later. See License.txt for further details.

The LZMA SDK is written and placed in the public domain by Igor Pavlov.

The BC7 library and implementation are Copyright (C) 2020-2021
Richard Geldreich, Jr and 2023 J�r�my Ansel, covered by the MIT License.
See "MIT License.txt" for full details.

"Star Wars" and related items are trademarks of LucasFilm Ltd and
LucasArts Entertainment Co.

Expand Down
Loading

0 comments on commit 40db848

Please sign in to comment.