PalF Class¶
The PalF class is the main class for parsing and working with Zoo Tycoon 1 palette files.
Source code in include/ztalib/PalF.h and src/PalF.cpp.
Import¶
Import the PalF class as so:
class PalF¶
class PalF
{
struct Color
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
};
PalF();
int load(std::string fileName);
std::string location();
void location(std::string loc);
uint32_t locationSize();
void locationSize(uint32_t size);
int colorModel();
void colorModel(int model);
int numColors();
void numColors(int count);
Color getColor(int index);
};
Example¶
struct PalF::Color¶
Represents a single color in the palette. Contains red, green, blue, and alpha components as 8-bit unsigned integers.
meth load¶
Load a PalF file from disk. Returns 0 on success, non-zero on failure.
Example
#include "ztalib/PalF.h"
int main()
{
PalF pal;
int result = pal.load("path/to/file");
if (result != 0) {
// Handle error
}
}
meth location¶
Get or set the location of the palette file. This is the file path used when loading the palette.
Example
#include "ztalib/PalF.h"
int main()
{
PalF pal;
pal.location("path/to/palette");
std::string loc = pal.location();
std::cout << "Palette location: " << loc << std::endl;
}
meth locationSize¶
Get or set the size of the palette file. This is the number of bytes in the file. Byte count must be accurate for future encoding of the palette file to work correctly.
Example
#include "ztalib/PalF.h"
int main()
{
PalF pal;
pal.locationSize(1024);
uint32_t size = pal.locationSize();
std::cout << "Palette size: " << size << std::endl;
}
meth colorModel¶
Get or set the color model used when parsing the palette file. 0 == RGBA, 1 == BGRA.
Example
#include "ztalib/PalF.h"
int main()
{
PalF pal;
pal.colorModel(0); // Set to RGBA
int model = pal.colorModel();
std::cout << "Color model: " << (model == 0 ? "RGBA" : "BGRA") << std::endl;
}
meth numColors¶
Get or set the number of colors in the palette. This is used when parsing the palette file to determine how many colors to read.
Example
#include "ztalib/PalF.h"
int main()
{
PalF pal;
pal.numColors(256); // Set to 256 colors
int count = pal.numColors();
std::cout << "Number of colors: " << count << std::endl;
}
meth getColor¶
Get the color at the specified index in the palette. Returns a Color struct containing the RGBA values of the color.
Example