mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
76 lines
2.4 KiB
C#
76 lines
2.4 KiB
C#
// ---------------------------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ---------------------------------------------------------------------------------------------
|
|
|
|
namespace Core.DataReader.Dxt
|
|
{
|
|
using System.IO;
|
|
using Extensions;
|
|
|
|
public class DxtPixelFormat
|
|
{
|
|
public int Size;
|
|
public int Flags;
|
|
public string Format;
|
|
public int RGBBitCount;
|
|
public int RBitMask;
|
|
public int GBitMask;
|
|
public int BBitMask;
|
|
public int ABitMask;
|
|
|
|
public static DxtPixelFormat ReadFormat(BinaryReader reader)
|
|
{
|
|
return new DxtPixelFormat
|
|
{
|
|
Size = reader.ReadInt32(),
|
|
Flags = reader.ReadInt32(),
|
|
Format = reader.ReadAsciiString(4),
|
|
RGBBitCount = reader.ReadInt32(),
|
|
RBitMask = reader.ReadInt32(),
|
|
GBitMask = reader.ReadInt32(),
|
|
BBitMask = reader.ReadInt32(),
|
|
ABitMask = reader.ReadInt32()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class DxtHeader
|
|
{
|
|
public int Size;
|
|
public int Flags;
|
|
public int Height;
|
|
public int Width;
|
|
public int PitchOrLinearSize;
|
|
public int Depth;
|
|
public int MipMapCount;
|
|
public int[] ReservedBytes; // 11 ints
|
|
public DxtPixelFormat DxtPixelFormat;
|
|
public int Caps1;
|
|
public int Caps2;
|
|
public int Caps3;
|
|
public int Caps4;
|
|
public int Reserved;
|
|
|
|
public static DxtHeader ReadHeader(BinaryReader reader)
|
|
{
|
|
return new DxtHeader
|
|
{
|
|
Size = reader.ReadInt32(),
|
|
Flags = reader.ReadInt32(),
|
|
Height = reader.ReadInt32(),
|
|
Width = reader.ReadInt32(),
|
|
PitchOrLinearSize = reader.ReadInt32(),
|
|
Depth = reader.ReadInt32(),
|
|
MipMapCount = reader.ReadInt32(),
|
|
ReservedBytes = reader.ReadInt32Array(11),
|
|
DxtPixelFormat = DxtPixelFormat.ReadFormat(reader),
|
|
Caps1 = reader.ReadInt32(),
|
|
Caps2 = reader.ReadInt32(),
|
|
Caps3 = reader.ReadInt32(),
|
|
Caps4 = reader.ReadInt32(),
|
|
Reserved = reader.ReadInt32(),
|
|
};
|
|
}
|
|
}
|
|
} |