diff options
| author | Crazy-P | 2018-04-21 22:35:23 +0800 |
|---|---|---|
| committer | Crazy-P | 2018-04-21 22:35:23 +0800 |
| commit | e6deba8d196a206ff350bc4d9fff783f78395d33 (patch) | |
| tree | 883389f54ba956f929dc1b9d7b4f6d68c0f8ccbb /core/image.cpp | |
| parent | 7d6f210ccb5de9ef414f94ad42f9f3dea14c0493 (diff) | |
| download | godot-e6deba8d196a206ff350bc4d9fff783f78395d33.tar.gz godot-e6deba8d196a206ff350bc4d9fff783f78395d33.tar.zst godot-e6deba8d196a206ff350bc4d9fff783f78395d33.zip | |
Diffstat (limited to 'core/image.cpp')
| -rw-r--r-- | core/image.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/image.cpp b/core/image.cpp index 2ac8ffea5..9f03892e7 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -366,6 +366,8 @@ int Image::get_mipmap_count() const { template <uint32_t read_bytes, bool read_alpha, uint32_t write_bytes, bool write_alpha, bool read_gray, bool write_gray> static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p_dst) { + uint32_t max_bytes = MAX(read_bytes, write_bytes); + for (int y = 0; y < p_height; y++) { for (int x = 0; x < p_width; x++) { @@ -379,7 +381,8 @@ static void _convert(int p_width, int p_height, const uint8_t *p_src, uint8_t *p rgba[1] = rofs[0]; rgba[2] = rofs[0]; } else { - for (uint32_t i = 0; i < MAX(read_bytes, write_bytes); i++) { + + for (uint32_t i = 0; i < max_bytes; i++) { rgba[i] = (i < read_bytes) ? rofs[i] : 0; } |
