Merge pull request #44445 from theogen-ratkin/master
Add interpolation parameter to resize_to_po2()
This commit is contained in:
commit
16524d4ae1
3 changed files with 8 additions and 6 deletions
|
@ -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);
|
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.");
|
ERR_FAIL_COND_MSG(!_can_modify(format), "Cannot resize in compressed or custom image formats.");
|
||||||
|
|
||||||
int w = next_power_of_2(width);
|
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) {
|
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("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("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR));
|
||||||
ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2);
|
ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2);
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Resize the image, using the preferred interpolation method.
|
* 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 resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
|
||||||
void shrink_x2();
|
void shrink_x2();
|
||||||
bool is_size_po2() const;
|
bool is_size_po2() const;
|
||||||
|
|
|
@ -422,7 +422,7 @@
|
||||||
<argument index="2" name="interpolation" type="int" enum="Image.Interpolation" default="1">
|
<argument index="2" name="interpolation" type="int" enum="Image.Interpolation" default="1">
|
||||||
</argument>
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Resizes the image to the given [code]width[/code] and [code]height[/code]. New pixels are calculated using [code]interpolation[/code]. See [code]interpolation[/code] constants.
|
Resizes the image to the given [code]width[/code] and [code]height[/code]. New pixels are calculated using the [code]interpolation[/code] mode defined via [enum Interpolation] constants.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="resize_to_po2">
|
<method name="resize_to_po2">
|
||||||
|
@ -430,8 +430,10 @@
|
||||||
</return>
|
</return>
|
||||||
<argument index="0" name="square" type="bool" default="false">
|
<argument index="0" name="square" type="bool" default="false">
|
||||||
</argument>
|
</argument>
|
||||||
|
<argument index="1" name="interpolation" type="int" enum="Image.Interpolation" default="1">
|
||||||
|
</argument>
|
||||||
<description>
|
<description>
|
||||||
Resizes the image to the nearest power of 2 for the width and height. If [code]square[/code] is [code]true[/code] then set width and height to be the same.
|
Resizes the image to the nearest power of 2 for the width and height. If [code]square[/code] is [code]true[/code] then set width and height to be the same. New pixels are calculated using the [code]interpolation[/code] mode defined via [enum Interpolation] constants.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="rgbe_to_srgb">
|
<method name="rgbe_to_srgb">
|
||||||
|
|
Loading…
Reference in a new issue