forked from WerWolv/ImHex-Patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pif.hexpat
78 lines (68 loc) · 1.71 KB
/
pif.hexpat
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma description PIF Image Format
/* PIF - Portable Image Format
*
* Basic decoder for the PIF file structure
* https://github.com/gfcwfzkm/PIF-Image-Format
*/
#pragma MIME image/pif
#pragma endian little
enum imageType_t : u16 {
RGB888 = 0x433C,
RGB565 = 0xE5C5,
RGB332 = 0x1E53,
RGB16C = 0xB895,
BLWH = 0x7DAA,
IND24 = 0x4952,
IND16 = 0x4947,
IND8 = 0x4942
};
enum compression_t : u16 {
NO_COMPRESSION = 0,
RLE_COMPRESSION = 0x7DDE
};
struct PIFFileHeader {
char Signature[4];
u32 FileSize;
u32 ImageOffset;
};
struct PIFInfoHeader {
imageType_t ImageType;
u16 BitsPerPixel;
u16 ImageWidth;
u16 ImageHeight;
u32 ImageSize;
u16 ColorTableSize;
compression_t Compression;
};
struct PIF {
PIFFileHeader PIF_FileHeader;
PIFInfoHeader PIF_ImageHeader;
if (PIF_ImageHeader.ImageType == imageType_t::IND24)
{
u24 ColorTable[PIF_ImageHeader.ColorTableSize/3];
}
else if (PIF_ImageHeader.ImageType == imageType_t::IND16)
{
u16 ColorTable[PIF_ImageHeader.ColorTableSize/2];
}
else if (PIF_ImageHeader.ImageType == imageType_t::IND8)
{
u8 ColorTable[PIF_ImageHeader.ColorTableSize];
}
if ((PIF_ImageHeader.ImageType == imageType_t::RGB888) ||
(PIF_ImageHeader.ImageType == imageType_t::IND24))
{
u24 ImageData[(PIF_FileHeader.FileSize - PIF_FileHeader.ImageOffset)/3];
}
else if ((PIF_ImageHeader.ImageType == imageType_t::RGB565) ||
(PIF_ImageHeader.ImageType == imageType_t::IND16))
{
u16 ImageData[(PIF_FileHeader.FileSize - PIF_FileHeader.ImageOffset)/2];
}
else if ((PIF_ImageHeader.ImageType == imageType_t::RGB332) ||
(PIF_ImageHeader.ImageType == imageType_t::IND8))
{
u8 ImageData[(PIF_FileHeader.FileSize - PIF_FileHeader.ImageOffset)/1];
}
};
PIF pif @ 0x00;