ff7tk  1.2.0.13
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 };
TexStruct::nbGreenBits2
quint32 nbGreenBits2
Definition: TexFile.h:53
TexStruct::redShift
quint32 redShift
Definition: TexFile.h:48
TexStruct::nbPalettes
quint32 nbPalettes
Definition: TexFile.h:24
TexStruct::blueBitmask
quint32 blueBitmask
Definition: TexFile.h:46
TexStruct::alphaMax
quint32 alphaMax
Definition: TexFile.h:59
TexStruct::imageHeight
quint32 imageHeight
Definition: TexFile.h:28
TexStruct::runtimeData4
quint32 runtimeData4
Definition: TexFile.h:67
TexStruct::redMax
quint32 redMax
Definition: TexFile.h:56
TexStruct::nbAlphaBits1
quint32 nbAlphaBits1
Definition: TexFile.h:43
TexStruct::unknown7
quint32 unknown7
Definition: TexFile.h:69
TexStruct::paletteSize
quint32 paletteSize
Definition: TexFile.h:34
TexStruct::bitsPerIndex
quint32 bitsPerIndex
Definition: TexFile.h:32
TexStruct::unknown6
quint32 unknown6
Definition: TexFile.h:65
TexFile::TexFile
TexFile()
Definition: TexFile.h:83
TexStruct::hasPal
quint32 hasPal
Definition: TexFile.h:31
TexStruct::hasColorKeyArray
quint32 hasColorKeyArray
Definition: TexFile.h:61
TexStruct::bitDepth
quint32 bitDepth
Definition: TexFile.h:26
TexStruct::imageWidth
quint32 imageWidth
Definition: TexFile.h:27
TexStruct::redBitmask
quint32 redBitmask
Definition: TexFile.h:44
TexStruct::bytesPerPixel
quint32 bytesPerPixel
Definition: TexFile.h:38
TexStruct::maxBitsPerColor
quint32 maxBitsPerColor
Definition: TexFile.h:18
TexStruct::unknown1
quint32 unknown1
Definition: TexFile.h:13
TexStruct::unknown2
quint32 unknown2
Definition: TexFile.h:15
TexStruct::alphaBitmask
quint32 alphaBitmask
Definition: TexFile.h:47
TexStruct::nbRedBits2
quint32 nbRedBits2
Definition: TexFile.h:52
TexStruct::blueShift
quint32 blueShift
Definition: TexFile.h:50
TexFile
Definition: TexFile.h:76
TexStruct::minBitsPerPixel
quint32 minBitsPerPixel
Definition: TexFile.h:21
TexFile::Version
Version
Definition: TexFile.h:79
TexStruct::nbColorsPerPalette1
quint32 nbColorsPerPalette1
Definition: TexFile.h:25
TexStruct::unknown9
quint32 unknown9
Definition: TexFile.h:71
TexStruct::maxBitsPerPixel
quint32 maxBitsPerPixel
Definition: TexFile.h:22
TexStruct::runtimeData2
quint32 runtimeData2
Definition: TexFile.h:62
TexStruct::pitch
quint32 pitch
Definition: TexFile.h:29
TexStruct::maxAlphaBits
quint32 maxAlphaBits
Definition: TexFile.h:20
TexStruct::version
quint32 version
Definition: TexFile.h:12
TexStruct::greenShift
quint32 greenShift
Definition: TexFile.h:49
TexStruct::bitsPerPixel
quint32 bitsPerPixel
Definition: TexFile.h:37
TexStruct::unknown10
quint32 unknown10
Definition: TexFile.h:72
TexStruct::minAlphaBits
quint32 minAlphaBits
Definition: TexFile.h:19
TexStruct::hasColorKey
quint32 hasColorKey
Definition: TexFile.h:14
TexStruct::unknown4
quint32 unknown4
Definition: TexFile.h:23
TexStruct::unknown5
quint32 unknown5
Definition: TexFile.h:30
TexStruct::runtimeData1
quint32 runtimeData1
Definition: TexFile.h:36
TexStruct::unknown3
quint32 unknown3
Definition: TexFile.h:16
TexStruct::referenceAlpha
quint32 referenceAlpha
Definition: TexFile.h:63
TexStruct::nbRedBits1
quint32 nbRedBits1
Definition: TexFile.h:40
TexStruct::minBitsPerColor
quint32 minBitsPerColor
Definition: TexFile.h:17
TexStruct::greenBitmask
quint32 greenBitmask
Definition: TexFile.h:45
TexStruct::nbAlphaBits2
quint32 nbAlphaBits2
Definition: TexFile.h:55
TexStruct::paletteIndex
quint32 paletteIndex
Definition: TexFile.h:66
TexStruct::alphaShift
quint32 alphaShift
Definition: TexFile.h:51
TexStruct
Definition: TexFile.h:10
TexStruct::nbBlueBits1
quint32 nbBlueBits1
Definition: TexFile.h:42
TexFile::~TexFile
~TexFile()
Definition: TexFile.h:87
TexStruct::nbGreenBits1
quint32 nbGreenBits1
Definition: TexFile.h:41
TexStruct::runtimeData5
quint32 runtimeData5
Definition: TexFile.h:68
TexStruct::nbBlueBits2
quint32 nbBlueBits2
Definition: TexFile.h:54
TexStruct::unknown11
quint32 unknown11
Definition: TexFile.h:73
TexStruct::runtimeData3
quint32 runtimeData3
Definition: TexFile.h:64
TexStruct::indexedTo8bit
quint32 indexedTo8bit
Definition: TexFile.h:33
TexStruct::unknown8
quint32 unknown8
Definition: TexFile.h:70
TexFile::None
@ None
Definition: TexFile.h:80
TextureFile
Definition: TextureFile.h:9
TexStruct::nbColorsPerPalette2
quint32 nbColorsPerPalette2
Definition: TexFile.h:35
TexStruct::greenMax
quint32 greenMax
Definition: TexFile.h:57
TextureFile::debug
void debug() const
Definition: TextureFile.cpp:87
TexStruct::blueMax
quint32 blueMax
Definition: TexFile.h:58