Merge pull request #106486 from BlueCube3310/image-ch-detect-fix

Image: Fix detecting color channels
This commit is contained in:
Thaddeus Crews
2025-05-19 08:01:40 -05:00

View File

@ -3464,18 +3464,24 @@ Image::UsedChannels Image::detect_used_channels(CompressSource p_source) const {
UsedChannels used_channels; UsedChannels used_channels;
if (!c && !a) { if (!c) {
used_channels = USED_CHANNELS_L; // Uniform RGB (grayscale).
} else if (!c && a) { if (a) {
used_channels = USED_CHANNELS_LA; used_channels = USED_CHANNELS_LA;
} else if (r && !g && !b && !a) { } else {
used_channels = USED_CHANNELS_R; used_channels = USED_CHANNELS_L;
} else if (r && g && !b && !a) { }
used_channels = USED_CHANNELS_RG;
} else if (r && g && b && !a) {
used_channels = USED_CHANNELS_RGB;
} else { } else {
used_channels = USED_CHANNELS_RGBA; // Colored image.
if (a) {
used_channels = USED_CHANNELS_RGBA;
} else if (b) {
used_channels = USED_CHANNELS_RGB;
} else if (g) {
used_channels = USED_CHANNELS_RG;
} else {
used_channels = USED_CHANNELS_R;
}
} }
if (p_source == COMPRESS_SOURCE_SRGB && (used_channels == USED_CHANNELS_R || used_channels == USED_CHANNELS_RG)) { if (p_source == COMPRESS_SOURCE_SRGB && (used_channels == USED_CHANNELS_R || used_channels == USED_CHANNELS_RG)) {