Fixed texture generation for 3 channel textures

This commit is contained in:
2021-11-14 23:25:26 -08:00
parent 9b4acae63c
commit 20428597b6
3 changed files with 24 additions and 33 deletions

View File

@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
xml[0] = '\0';
sprintf(xml,
"<texture channels=\"%i\" width=\"%i\" height=\"%i\">",
channels, w, h
STBI_rgb_alpha, w, h
);
// For each scale.
@ -70,8 +70,12 @@ int main(int argc, char *argv[]) {
scale = RESIZE_SCALES[i];
rw = w / scale;
rh = h / scale;
dataResized = malloc(sizeof(stbi_uc) * rw * rh * channels);
stbir_resize_uint8(dataOriginal, w, h, 0, dataResized, rw, rh, 0, channels);
dataResized = malloc(sizeof(stbi_uc) * rw * rh * STBI_rgb_alpha);
stbir_resize_uint8(
dataOriginal, w, h, 0,
dataResized, rw, rh, 0,
STBI_rgb_alpha
);
// Determine output path
sprintf(path, "%s_%i.texture", out, scale);
@ -87,7 +91,7 @@ int main(int argc, char *argv[]) {
}
// Write texture
fwrite(dataResized, sizeof(unsigned char), rw * rh * channels, file);
fwrite(dataResized, sizeof(unsigned char), rw * rh * STBI_rgb_alpha, file);
// Cleanup
fclose(file);