VOXEL: allow to save the palette glow color to png

master
Martin Gerhardy 2022-05-22 23:19:33 +02:00
parent 62e1fe1c5a
commit 18350dc9a2
2 changed files with 16 additions and 0 deletions

View File

@ -132,6 +132,21 @@ bool Palette::save(const char *name) const {
return true;
}
bool Palette::saveGlow(const char *name) const {
if (name == nullptr || name[0] == '\0') {
return false;
}
image::Image img(name);
Log::info("Save glow palette colors to %s", name);
// must be voxel::PaletteMaxColors - otherwise the exporter uv coordinates must get adopted
img.loadRGBA((const uint8_t *)glowColors, sizeof(glowColors), lengthof(glowColors), 1);
if (!img.writePng()) {
Log::warn("Failed to write the glow palette colors file '%s'", name);
return false;
}
return true;
}
bool Palette::load(const uint8_t *rgbaBuf, size_t bufsize) {
if (bufsize % 4 != 0) {
Log::warn("Buf size doesn't match expectation: %i", (int)bufsize);

View File

@ -41,6 +41,7 @@ public:
}
bool load(const char *name);
bool save(const char *name = nullptr) const;
bool saveGlow(const char *name = nullptr) const;
bool load(const uint8_t *rgbaBuf, size_t bufsize);
bool minecraft();