mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 13:14:17 +01:00
Fix some texture stuff.
This commit is contained in:
parent
8fdd173388
commit
c0542d0e94
4 changed files with 6 additions and 49 deletions
|
|
@ -224,30 +224,4 @@ public class DdsFile
|
|||
_ => throw new ArgumentOutOfRangeException( nameof( type ), type, null ),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class TmpTexFile
|
||||
{
|
||||
public TexFile.TexHeader Header;
|
||||
public byte[] RgbaData = Array.Empty< byte >();
|
||||
|
||||
public void Load( BinaryReader br )
|
||||
{
|
||||
Header = br.ReadStructure< TexFile.TexHeader >();
|
||||
var data = br.ReadBytes( ( int )( br.BaseStream.Length - br.BaseStream.Position ) );
|
||||
RgbaData = Header.Format switch
|
||||
{
|
||||
TexFile.TextureFormat.L8 => ImageParsing.DecodeUncompressedGreyscale( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.A8 => ImageParsing.DecodeUncompressedGreyscale( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.DXT1 => ImageParsing.DecodeDxt1( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.DXT3 => ImageParsing.DecodeDxt3( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.DXT5 => ImageParsing.DecodeDxt5( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.B8G8R8A8 => ImageParsing.DecodeUncompressedB8G8R8A8( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.B8G8R8X8 => ImageParsing.DecodeUncompressedR8G8B8A8( data, Header.Height, Header.Width ),
|
||||
//TexFile.TextureFormat.A8R8G8B82 => ImageParsing.DecodeUncompressedR8G8B8A8( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.B4G4R4A4 => ImageParsing.DecodeUncompressedR4G4B4A4( data, Header.Height, Header.Width ),
|
||||
TexFile.TextureFormat.B5G5R5A1 => ImageParsing.DecodeUncompressedR5G5B5A1( data, Header.Height, Header.Width ),
|
||||
_ => throw new ArgumentOutOfRangeException(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -12,9 +12,9 @@ public static partial class ImageParsing
|
|||
{
|
||||
var ret = new Rgba32
|
||||
{
|
||||
R = ( byte )( c & 0x1F ),
|
||||
R = ( byte )( c >> 11 ),
|
||||
G = ( byte )( ( c >> 5 ) & 0x3F ),
|
||||
B = ( byte )( c >> 11 ),
|
||||
B = ( byte )( c & 0x1F ),
|
||||
A = 0xFF,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Lumina.Data.Files;
|
||||
using OtterGui;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using Functions = Penumbra.GameData.Util.Functions;
|
||||
|
||||
namespace Penumbra.Import.Dds;
|
||||
|
||||
|
|
@ -13,7 +15,7 @@ public class TextureImporter
|
|||
using var mem = new MemoryStream( target );
|
||||
using var bw = new BinaryWriter( mem );
|
||||
bw.Write( ( uint )TexFile.Attribute.TextureType2D );
|
||||
bw.Write( ( uint )TexFile.TextureFormat.B8G8R8X8 );
|
||||
bw.Write( ( uint )TexFile.TextureFormat.B8G8R8A8 );
|
||||
bw.Write( ( ushort )width );
|
||||
bw.Write( ( ushort )height );
|
||||
bw.Write( ( ushort )1 );
|
||||
|
|
@ -71,15 +73,7 @@ public class TextureImporter
|
|||
|
||||
texData = new byte[80 + width * height * 4];
|
||||
WriteHeader( texData, width, height );
|
||||
// RGBA to BGRA.
|
||||
for( var i = 0; i < rgba.Length; i += 4 )
|
||||
{
|
||||
texData[ 80 + i + 0 ] = rgba[ i + 2 ];
|
||||
texData[ 80 + i + 1 ] = rgba[ i + 1 ];
|
||||
texData[ 80 + i + 2 ] = rgba[ i + 0 ];
|
||||
texData[ 80 + i + 3 ] = rgba[ i + 3 ];
|
||||
}
|
||||
|
||||
rgba.CopyTo( texData.AsSpan( 80 ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
|
|
@ -165,16 +164,6 @@ public partial class ModEditWindow
|
|||
{
|
||||
try
|
||||
{
|
||||
if( fromDisk )
|
||||
{
|
||||
var tmp = new TmpTexFile();
|
||||
using var stream = File.OpenRead( path );
|
||||
using var br = new BinaryReader( stream );
|
||||
tmp.Load(br);
|
||||
return (tmp.RgbaData, tmp.Header.Width, tmp.Header.Height);
|
||||
}
|
||||
|
||||
|
||||
var tex = fromDisk ? Dalamud.GameData.GameData.GetFileFromDisk< TexFile >( path ) : Dalamud.GameData.GetFile< TexFile >( path );
|
||||
if( tex == null )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue