diff options
Diffstat (limited to 'core/image.cpp')
-rw-r--r-- | core/image.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/core/image.cpp b/core/image.cpp index 4fc3b4becb..f547d7e973 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -735,6 +735,10 @@ static void _overlay(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, } } +bool Image::is_size_po2() const { + return uint32_t(width) == next_power_of_2(width) && uint32_t(height) == next_power_of_2(height); +} + void Image::resize_to_po2(bool p_square) { if (!_can_modify(format)) { @@ -1789,7 +1793,7 @@ Error Image::decompress() { _image_decompress_pvrtc(this); else if (format == FORMAT_ETC && _image_decompress_etc1) _image_decompress_etc1(this); - else if (format >= FORMAT_ETC2_R11 && format <= FORMAT_ETC2_RGB8A1 && _image_decompress_etc1) + else if (format >= FORMAT_ETC2_R11 && format <= FORMAT_ETC2_RGB8A1 && _image_decompress_etc2) _image_decompress_etc2(this); else return ERR_UNAVAILABLE; @@ -2632,6 +2636,9 @@ void Image::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "_set_data", "_get_data"); + BIND_CONSTANT(MAX_WIDTH); + BIND_CONSTANT(MAX_HEIGHT); + BIND_ENUM_CONSTANT(FORMAT_L8); //luminance BIND_ENUM_CONSTANT(FORMAT_LA8); //luminance-alpha BIND_ENUM_CONSTANT(FORMAT_R8); @@ -2898,15 +2905,15 @@ void Image::fix_alpha_edges() { if (dist >= closest_dist) continue; - const uint8_t *rp = &srcptr[(k * width + l) << 2]; + const uint8_t *rp2 = &srcptr[(k * width + l) << 2]; - if (rp[3] < alpha_threshold) + if (rp2[3] < alpha_threshold) continue; closest_dist = dist; - closest_color[0] = rp[0]; - closest_color[1] = rp[1]; - closest_color[2] = rp[2]; + closest_color[0] = rp2[0]; + closest_color[1] = rp2[1]; + closest_color[2] = rp2[2]; } } |