mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Fix CI texture depth when png export
This commit is contained in:
@@ -823,31 +823,29 @@ const char* n64graphics_get_write_version(void) {
|
||||
/**
|
||||
* Converts binary ci8 + palette to a single .png
|
||||
*/
|
||||
int convert_raw_to_ci8(unsigned char **png_output, int *size_output, uint8_t *texture, uint8_t *palette, int format, int width, int height, int depth) {
|
||||
FILE *pal_fp;
|
||||
uint8_t *pal;
|
||||
uint8_t *raw_fmt;
|
||||
rgba *imgr;
|
||||
ia *imgi;
|
||||
int pal_size;
|
||||
int res;
|
||||
int convert_raw_to_ci8(unsigned char **png_output, int *size_output, uint8_t *texture, uint8_t *palette, int format, int width, int height, int depth, int pal_depth) {
|
||||
uint8_t *raw_fmt;
|
||||
rgba *imgr;
|
||||
ia *imgi;
|
||||
int res;
|
||||
|
||||
raw_fmt = ci2raw(texture, palette, width, height, depth);
|
||||
switch (format) {
|
||||
case IMG_FORMAT_RGBA:
|
||||
INFO("Converting raw to RGBA16\n");
|
||||
imgr = raw2rgba(raw_fmt, width, height, depth);
|
||||
res = rgba2png(png_output, size_output, imgr, width, height);
|
||||
break;
|
||||
case IMG_FORMAT_IA:
|
||||
INFO("Converting raw to IA16\n");
|
||||
imgi = raw2ia(raw_fmt, width, height, depth);
|
||||
//res = ia2png(name, imgi, width, height);
|
||||
break;
|
||||
default:
|
||||
//ERROR("Unsupported palette format: %s\n", format2str(&config.pal_format));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
free(raw_fmt);
|
||||
free(pal);
|
||||
raw_fmt = ci2raw(texture, palette, width, height, depth);
|
||||
switch (format) {
|
||||
case IMG_FORMAT_RGBA:
|
||||
INFO("Converting raw to RGBA%d\n", pal_depth);
|
||||
imgr = raw2rgba(raw_fmt, width, height, pal_depth);
|
||||
res = rgba2png(png_output, size_output, imgr, width, height);
|
||||
free(imgr);
|
||||
break;
|
||||
case IMG_FORMAT_IA:
|
||||
INFO("Converting raw to IA%d\n", pal_depth);
|
||||
imgi = raw2ia(raw_fmt, width, height, pal_depth);
|
||||
//res = ia2png(name, imgi, width, height);
|
||||
free(imgi);
|
||||
break;
|
||||
default:
|
||||
//ERROR("Unsupported palette format: %s\n", format2str(&config.pal_format));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
free(raw_fmt);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ ia *raw2i(const uint8_t *raw, int width, int height, int depth);
|
||||
// N64 raw CI4/CI8 -> intermediate CI
|
||||
ci *raw2ci_torch(const uint8_t* raw, int width, int height, int depth);
|
||||
|
||||
int convert_raw_to_ci8(unsigned char **png_output, int *size_output, uint8_t *texture, uint8_t *palette, int format, int width, int height, int depth);
|
||||
int convert_raw_to_ci8(unsigned char **png_output, int *size_output, uint8_t *texture, uint8_t *palette, int format, int width, int height, int depth, int pal_depth);
|
||||
|
||||
int imgpal2rawci(uint8_t *rawci, const rgba *img, const rgba *pal, const uint8_t *wheel_mask, int raw_size, int ci_depth, int img_size, int pal_size);
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@ ExportResult TextureModdingExporter::Export(std::ostream&write, std::shared_ptr<
|
||||
auto palettePtr = tlutTextureMap[tlut];
|
||||
|
||||
if (palettePtr) {
|
||||
convert_raw_to_ci8(&raw, &size, texture->mBuffer.data(), (uint8_t *)palettePtr->mBuffer.data(), 0, texture->mWidth, texture->mHeight, palettePtr->mFormat.depth);
|
||||
convert_raw_to_ci8(&raw, &size, texture->mBuffer.data(), (uint8_t *)palettePtr->mBuffer.data(), 0, texture->mWidth, texture->mHeight, texture->mFormat.depth, palettePtr->mFormat.depth);
|
||||
|
||||
} else {
|
||||
auto symbol = GetSafeNode<std::string>(node, "symbol");
|
||||
|
||||
Reference in New Issue
Block a user