Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
using System;
using System.IO;
using BCnEncoder.Decoder;
using BCnEncoder.Shared;
using Lumina.Data.Files;

namespace Lumina.Data.Parsing.Tex.Buffers
Expand Down Expand Up @@ -53,19 +56,27 @@ protected override void ConvertToB8G8R8A8( byte[] buffer, int destOffset, int so
var cbPlane = CalculateNumBytesPerPlane( width, height );
for( var i = 0; i < depth; i++ )
{
var dec = Squish.DecompressImage( RawData, sourceOffset + cbPlane * i, width, height, _version switch
var decoder = new BcDecoder();
var stream = new MemoryStream( RawData, sourceOffset + cbPlane * i, cbPlane );
var rgbaData = decoder.DecodeRaw( stream, width, height, _version switch
{
1 => SquishOptions.DXT1,
2 => SquishOptions.DXT3,
3 => SquishOptions.DXT5,
_ => throw new NotSupportedException( "Decoding BC5/BC7 data is currently not supported." ),
} );
Array.Copy(
dec,
0,
buffer,
destOffset + width * height * 4 * i,
dec.Length );
1 => CompressionFormat.Bc1,
2 => CompressionFormat.Bc2,
3 => CompressionFormat.Bc3,
5 => CompressionFormat.Bc5,
7 => CompressionFormat.Bc7,
_ => throw new NotSupportedException( "Unknown block compression version." ),
} );

// Write ColorRgba32[] to output byte[]
for( var j = 0; j < rgbaData.Length; j++ )
{
var color = rgbaData[j];
buffer[destOffset + ( i * width * height * 4 ) + ( j * 4 ) + 0] = color.r;
buffer[destOffset + ( i * width * height * 4 ) + ( j * 4 ) + 1] = color.g;
buffer[destOffset + ( i * width * height * 4 ) + ( j * 4 ) + 2] = color.b;
buffer[destOffset + ( i * width * height * 4 ) + ( j * 4 ) + 3] = color.a;
}
}
}

Expand Down
134 changes: 0 additions & 134 deletions src/Lumina/Data/Parsing/Tex/Squish.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Lumina/Lumina.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCnEncoder.Net" Version="2.2.1" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="8.0.7" />
<PackageReference Include="MinVer" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
Expand Down
Loading