ff7tk  1.2.0.24
Work with Final Fantasy 7 game data
TexFile.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009 - 2022 Arzel Jérôme <myst6re@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #pragma once
5 
6 #include <QImage>
7 #include <TextureFile>
8 #include <ff7tkformats_export.h>
9 
10 struct FF7TKFORMATS_EXPORT TexStruct {
11  // Header
12  quint32 version; // 1=FF7 | 2=FF8
13  quint32 unknown1; // 0
14  quint32 hasColorKey;
15  quint32 unknown2; // 0
16  quint32 unknown3; // 7
17  quint32 minBitsPerColor;
18  quint32 maxBitsPerColor;
19  quint32 minAlphaBits;
20  quint32 maxAlphaBits;
21  quint32 minBitsPerPixel;
22  quint32 maxBitsPerPixel;
23  quint32 unknown4; // 0
24  quint32 nbPalettes;
26  quint32 bitDepth;
27  quint32 imageWidth;
28  quint32 imageHeight;
29  quint32 pitch; // 0
30  quint32 unknown5; // 0
31  quint32 hasPal;
32  quint32 bitsPerIndex;
33  quint32 indexedTo8bit;
34  quint32 paletteSize;
35  quint32 nbColorsPerPalette2;// may be 0 sometimes
36  quint32 runtimeData1;
37  quint32 bitsPerPixel;
38  quint32 bytesPerPixel;
39  // Pixel format
40  quint32 nbRedBits1;
41  quint32 nbGreenBits1;
42  quint32 nbBlueBits1;
43  quint32 nbAlphaBits1;
44  quint32 redBitmask;
45  quint32 greenBitmask;
46  quint32 blueBitmask;
47  quint32 alphaBitmask;
48  quint32 redShift;
49  quint32 greenShift;
50  quint32 blueShift;
51  quint32 alphaShift;
52  quint32 nbRedBits2;// Always 8 - Unused
53  quint32 nbGreenBits2;// Always 8 - Unused
54  quint32 nbBlueBits2;// Always 8 - Unused
55  quint32 nbAlphaBits2;// Always 8 - Unused
56  quint32 redMax;
57  quint32 greenMax;
58  quint32 blueMax;
59  quint32 alphaMax;
60  // /Pixel format
62  quint32 runtimeData2;
63  quint32 referenceAlpha;
64  quint32 runtimeData3;
65  quint32 unknown6;
66  quint32 paletteIndex;
67  quint32 runtimeData4;
68  quint32 runtimeData5;
69  quint32 unknown7;
70  quint32 unknown8;
71  quint32 unknown9;
72  quint32 unknown10;
73  quint32 unknown11; // only on ff8!
74 };
75 
76 class FF7TKFORMATS_EXPORT TexFile : public TextureFile
77 {
78 public:
79  enum Version {
80  None, FF7, FF8
81  };
82 
84  explicit TexFile(const QByteArray &data);
85  TexFile(const TextureFile &textureFile, const TexStruct &header,
86  const QList<quint8> &colorKeyArray = QList<quint8>());
87  ~TexFile() {}
88  bool open(const QByteArray &data);
89  bool save(QByteArray &data);
90  TexFile scaled(const QSize &size) const;
91  void setVersion(Version version);
92  void debug();
93 private:
94  void updateHeader();
95  TexStruct header;
96  QList<quint8> colorKeyArray;
97 };
Definition: TexFile.h:77
TexFile()
Definition: TexFile.h:83
~TexFile()
Definition: TexFile.h:87
Version
Definition: TexFile.h:79
@ FF7
Definition: TexFile.h:80
Definition: TextureFile.h:10
Definition: TexFile.h:10
quint32 maxBitsPerPixel
Definition: TexFile.h:22
quint32 redMax
Definition: TexFile.h:56
quint32 unknown10
Definition: TexFile.h:72
quint32 pitch
Definition: TexFile.h:29
quint32 unknown9
Definition: TexFile.h:71
quint32 unknown3
Definition: TexFile.h:16
quint32 runtimeData4
Definition: TexFile.h:67
quint32 nbBlueBits1
Definition: TexFile.h:42
quint32 minAlphaBits
Definition: TexFile.h:19
quint32 runtimeData2
Definition: TexFile.h:62
quint32 nbColorsPerPalette1
Definition: TexFile.h:25
quint32 referenceAlpha
Definition: TexFile.h:63
quint32 version
Definition: TexFile.h:12
quint32 blueBitmask
Definition: TexFile.h:46
quint32 minBitsPerColor
Definition: TexFile.h:17
quint32 unknown2
Definition: TexFile.h:15
quint32 greenShift
Definition: TexFile.h:49
quint32 imageHeight
Definition: TexFile.h:28
quint32 unknown7
Definition: TexFile.h:69
quint32 redShift
Definition: TexFile.h:48
quint32 runtimeData1
Definition: TexFile.h:36
quint32 hasColorKeyArray
Definition: TexFile.h:61
quint32 unknown11
Definition: TexFile.h:73
quint32 unknown5
Definition: TexFile.h:30
quint32 nbGreenBits2
Definition: TexFile.h:53
quint32 blueMax
Definition: TexFile.h:58
quint32 paletteSize
Definition: TexFile.h:34
quint32 runtimeData5
Definition: TexFile.h:68
quint32 maxAlphaBits
Definition: TexFile.h:20
quint32 unknown1
Definition: TexFile.h:13
quint32 redBitmask
Definition: TexFile.h:44
quint32 bitsPerIndex
Definition: TexFile.h:32
quint32 nbRedBits2
Definition: TexFile.h:52
quint32 runtimeData3
Definition: TexFile.h:64
quint32 paletteIndex
Definition: TexFile.h:66
quint32 nbGreenBits1
Definition: TexFile.h:41
quint32 imageWidth
Definition: TexFile.h:27
quint32 unknown8
Definition: TexFile.h:70
quint32 bitDepth
Definition: TexFile.h:26
quint32 blueShift
Definition: TexFile.h:50
quint32 bitsPerPixel
Definition: TexFile.h:37
quint32 unknown6
Definition: TexFile.h:65
quint32 nbColorsPerPalette2
Definition: TexFile.h:35
quint32 greenMax
Definition: TexFile.h:57
quint32 greenBitmask
Definition: TexFile.h:45
quint32 minBitsPerPixel
Definition: TexFile.h:21
quint32 nbAlphaBits1
Definition: TexFile.h:43
quint32 nbAlphaBits2
Definition: TexFile.h:55
quint32 maxBitsPerColor
Definition: TexFile.h:18
quint32 hasColorKey
Definition: TexFile.h:14
quint32 nbBlueBits2
Definition: TexFile.h:54
quint32 nbRedBits1
Definition: TexFile.h:40
quint32 alphaShift
Definition: TexFile.h:51
quint32 alphaBitmask
Definition: TexFile.h:47
quint32 indexedTo8bit
Definition: TexFile.h:33
quint32 nbPalettes
Definition: TexFile.h:24
quint32 bytesPerPixel
Definition: TexFile.h:38
quint32 unknown4
Definition: TexFile.h:23
quint32 alphaMax
Definition: TexFile.h:59
quint32 hasPal
Definition: TexFile.h:31