forked from Windower/ResourceExtractor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageHeader.cs
More file actions
executable file
·54 lines (49 loc) · 1.53 KB
/
ImageHeader.cs
File metadata and controls
executable file
·54 lines (49 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace ResourceExtractor;
public enum ImageType {
Unknown,
Bitmap,
DXT1,
DXT2,
DXT3,
DXT4,
DXT5,
}
[SuppressMessage("Style", "IDE0032:Use auto property", Justification = "Messes up struct layout")]
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 8)]
public readonly struct ImageHeader {
private readonly uint structLength;
private readonly int width;
private readonly int height;
private readonly ushort planes;
private readonly ushort bitCount;
private readonly uint compression;
private readonly uint imageSize;
private readonly uint horizontalResolution;
private readonly uint verticalResolution;
private readonly uint usedColors;
private readonly uint importantColors;
private readonly uint type;
public uint StructLength => structLength;
public int Width => width;
public int Height => height;
public ushort Planes => planes;
public ushort BitCount => bitCount;
public uint Compression => compression;
public uint ImageSize => imageSize;
public uint HorizontalResolution => horizontalResolution;
public uint VerticalResolution => verticalResolution;
public uint UsedColors => usedColors;
public uint ImportantColors => importantColors;
public ImageType Type =>
type switch {
0x44585430 + 1 => ImageType.DXT1,
0x44585430 + 2 => ImageType.DXT2,
0x44585430 + 3 => ImageType.DXT3,
0x44585430 + 4 => ImageType.DXT4,
0x44585430 + 5 => ImageType.DXT5,
0x0000000A => ImageType.Bitmap,
_ => ImageType.Unknown,
};
}