V-Gears 0
Free Final Fantasy VII engine.
TexFile.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include "common/TypeDefine.h"
19#include "common/File.h"
20
21class TexFile{
22
23 public:
24
31 TexFile(File file);
32
38 TexFile(std::string path);
39
43 ~TexFile();
44
56 void SavePng(
57 std::string file_name, unsigned int x, unsigned int y, unsigned int w, unsigned int h,
58 unsigned int palette = 0
59 );
60
68 void SavePng(std::string file_name, unsigned int palette = 0);
69
87 void SavePng(
88 std::string file_name, unsigned int x1, unsigned int x2, unsigned int y1, unsigned int y2,
89 unsigned int w1, unsigned int w2, unsigned int h, unsigned int palette = 0
90 );
91
92 private:
93
101 void Read(File file);
102
107
112
117
122
127
134
141
148
155
162
169
174
179
184
191
196
201
208
213
218
225
232
239
246
253
258
263
264 // Pixel format 0 for non-paletted images.
265
270
275
280
285
290
295
300
305
310
315
320
325
332
339
346
353
358
363
368
373
374 // Pixel format end.
375
382
389
397
404
409
416
423
430
435
440
445
450
451 // Palette data.
452
458 std::vector<std::vector<Ogre::ColourValue>> palettes_;
459
460 // Pixel data.
461
465 std::vector<Ogre::ColourValue> pixel_colour_;
466
473 std::vector<u8> pixel_ref_;
474
475 // Colour key array
476
480 std::vector<u8> colour_key_array_;
481};
Ogre::uint32 u32
Definition: TypeDefine.h:23
Represents a file.
Definition: File.h:24
Definition: TexFile.h:21
std::vector< std::vector< Ogre::ColourValue > > palettes_
Palette data.
Definition: TexFile.h:458
u32 bits_alpha_2_
Alpha bits.
Definition: TexFile.h:352
u32 bits_green_2_
Green bits.
Definition: TexFile.h:338
u32 run_3_
Runtime data.
Definition: TexFile.h:422
u32 run_2_
Runtime data.
Definition: TexFile.h:403
u32 unknown_0_
Unknown data.
Definition: TexFile.h:111
std::vector< u8 > colour_key_array_
Colour key array.
Definition: TexFile.h:480
u32 bytes_per_pixel_
Bytes per pixel.
Definition: TexFile.h:262
u32 palette_count_
Number of colour palettes.
Definition: TexFile.h:178
u32 bits_red_
Number of red bits.
Definition: TexFile.h:269
u32 bitmask_green_
Green bitmask.
Definition: TexFile.h:294
TexFile(File file)
Constructor.
Definition: TexFile.cpp:27
u32 run_0_
Runtime data.
Definition: TexFile.h:252
u32 width_
Image width.
Definition: TexFile.h:195
void SavePng(std::string file_name, unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int palette=0)
Saves a fragment of the TEX file as a PNG file.
Definition: TexFile.cpp:134
u32 unknown_8_
Unknown data.
Definition: TexFile.h:444
u32 colours_per_palette_
Number of colours per palette.
Definition: TexFile.h:245
u32 max_red_
Max value for red colour.
Definition: TexFile.h:357
u32 bits_alpha_
Number of alpha bits.
Definition: TexFile.h:284
u32 unknown_6_
Unknown data.
Definition: TexFile.h:434
u32 bitmask_blue_
Blue bitmask.
Definition: TexFile.h:299
u32 bit_depth_
Bit depth.
Definition: TexFile.h:190
u32 max_alpha_
Max alpha value.
Definition: TexFile.h:372
u32 height_
Image height.
Definition: TexFile.h:200
std::vector< u8 > pixel_ref_
Pixel data for paletted images.
Definition: TexFile.h:473
u32 unknown_7_
Unknown data.
Definition: TexFile.h:439
u32 bits_green_
Number of green bits.
Definition: TexFile.h:274
u32 has_palette_
Indicates a paletted image.
Definition: TexFile.h:217
u32 max_green_
Max value for green colour.
Definition: TexFile.h:362
~TexFile()
Destructor.
Definition: TexFile.cpp:132
u32 shift_red_
Red shift.
Definition: TexFile.h:309
u32 bits_per_index_
Bits per index.
Definition: TexFile.h:224
u32 run_1_
Runtime data.
Definition: TexFile.h:388
u32 bits_red_2_
Red bits.
Definition: TexFile.h:331
std::vector< Ogre::ColourValue > pixel_colour_
Pixel data for non paletted images.
Definition: TexFile.h:465
u32 bitmask_alpha_
Alpha bitmask.
Definition: TexFile.h:304
u32 max_blue_
Max value for blue colour.
Definition: TexFile.h:367
void Read(File file)
Reads data from a file.
Definition: TexFile.cpp:31
u32 min_alpha_bits_
Minimum alpha bits.
Definition: TexFile.h:147
u32 max_bpp_
Maximum bits per pixel.
Definition: TexFile.h:168
u32 min_bpp_
Minimum bits per pixel.
Definition: TexFile.h:161
u32 bitmask_red_
Red shift.
Definition: TexFile.h:289
u32 colour_k_array_
Colour key array flag.
Definition: TexFile.h:381
u32 max_alpha_bits_
Minimum alpha bits.
Definition: TexFile.h:154
u32 version_
File format version.
Definition: TexFile.h:106
u32 bits_per_pixel_
Bits per pixel.
Definition: TexFile.h:257
u32 unknown_2_
Unknown data.
Definition: TexFile.h:126
u32 run_4_
Runtime data.
Definition: TexFile.h:429
u32 shift_blue_
Blue shift.
Definition: TexFile.h:319
u32 unknown_4_
Unknown data.
Definition: TexFile.h:212
u32 min_bpc_
Minimum bits per color.
Definition: TexFile.h:133
u32 palette_size_
Palette size.
Definition: TexFile.h:238
u32 unknown_3_
Unknown data.
Definition: TexFile.h:173
u32 bits_blue_2_
Blue bits.
Definition: TexFile.h:345
u32 palette_colour_count_
Number of colours per palette.
Definition: TexFile.h:183
u32 bits_blue_
Number of blue bits.
Definition: TexFile.h:279
u32 pitch_
Pitch or bytes per row.
Definition: TexFile.h:207
u32 unknown_1_
Unknown data.
Definition: TexFile.h:121
u32 unknown_9_
Unknown data.
Definition: TexFile.h:449
u32 indexed_to_8_bit_
Indexed to 8 bit flag.
Definition: TexFile.h:231
u32 ref_alpha_
Alpha reference value.
Definition: TexFile.h:396
u32 colour_key_
Color key flag.
Definition: TexFile.h:116
u32 unknown_5_
Unknown data.
Definition: TexFile.h:408
u32 palette_index_
Palette index.
Definition: TexFile.h:415
u32 max_bpc_
Maximum bits per color.
Definition: TexFile.h:140
u32 shift_alpha_
Alpha shift.
Definition: TexFile.h:324
u32 shift_green_
Green shift.
Definition: TexFile.h:314