summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTheogen Ratkin <feogenratkin@gmail.com>2020-12-18 10:14:55 -0400
committerTheogen Ratkin <feogenratkin@gmail.com>2020-12-18 14:05:07 -0400
commit46ea6750b422292e3f7bf15b5bb12aa4de68dbea (patch)
treec1595432fe118d7a248af10dc89a5b61a29b96d7 /core
parent68117f5e75944cfd6f8ad1534a15c334e7ed5e91 (diff)
Add interpolation parameter to resize_to_po2()
Image::resize_to_po2() now takes an optional p_interpolation parameter that it passes directly to resize() with default value INTERPOLATE_BILINEAR.
Diffstat (limited to 'core')
-rw-r--r--core/io/image.cpp6
-rw-r--r--core/io/image.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 7c32c02701..cd334ac6cb 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -993,7 +993,7 @@ 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) {
+void Image::resize_to_po2(bool p_square, Interpolation p_interpolation) {
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats.");
int w = next_power_of_2(width);
@@ -1008,7 +1008,7 @@ void Image::resize_to_po2(bool p_square) {
}
}
- resize(w, h);
+ resize(w, h, p_interpolation);
}
void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
@@ -3077,7 +3077,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_mipmap_offset", "mipmap"), &Image::get_mipmap_offset);
- ClassDB::bind_method(D_METHOD("resize_to_po2", "square"), &Image::resize_to_po2, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("resize_to_po2", "square", "interpolation"), &Image::resize_to_po2, DEFVAL(false), DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2);
diff --git a/core/io/image.h b/core/io/image.h
index 0151df0cf9..6b4488bd66 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -244,7 +244,7 @@ public:
/**
* Resize the image, using the preferred interpolation method.
*/
- void resize_to_po2(bool p_square = false);
+ void resize_to_po2(bool p_square = false, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
void shrink_x2();
bool is_size_po2() const;