Optimize image channel detection
Speeds up compression
This commit is contained in:
parent
2bd89ac249
commit
4763835c11
1 changed files with 20 additions and 18 deletions
|
@ -3010,9 +3010,12 @@ Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
|
|||
ERR_FAIL_COND_V(is_compressed(), USED_CHANNELS_RGBA);
|
||||
bool r = false, g = false, b = false, a = false, c = false;
|
||||
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
Color col = get_pixel(i, j);
|
||||
const uint8_t *data_ptr = data.ptr();
|
||||
|
||||
uint32_t data_total = width * height;
|
||||
|
||||
for (uint32_t i = 0; i < data_total; i++) {
|
||||
Color col = _get_color_at_ofs(data_ptr, i);
|
||||
|
||||
if (col.r > 0.001) {
|
||||
r = true;
|
||||
|
@ -3031,7 +3034,6 @@ Image::UsedChannels Image::detect_used_channels(CompressSource p_source) {
|
|||
c = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UsedChannels used_channels;
|
||||
|
||||
|
|
Loading…
Reference in a new issue