feat: updated godot version

This commit is contained in:
Sara Gerretsen 2026-04-04 19:38:56 +02:00
parent 0c508b0831
commit 42b028dbb5
4694 changed files with 236470 additions and 401376 deletions

View file

@ -29,14 +29,12 @@
/**************************************************************************/
#include "image.h"
#include "image.compat.inc"
#include "core/config/project_settings.h"
#include "core/error/error_macros.h"
#include "core/io/image_loader.h"
#include "core/io/resource_loader.h"
#include "core/math/math_funcs.h"
#include "core/object/class_db.h"
#include "core/templates/hash_map.h"
#include "core/variant/dictionary.h"
@ -1233,14 +1231,14 @@ static void _overlay(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst,
}
bool Image::is_size_po2() const {
return Math::is_power_of_2(width) && Math::is_power_of_2(height);
return is_power_of_2(width) && is_power_of_2(height);
}
void Image::resize_to_po2(bool p_square, Interpolation p_interpolation) {
ERR_FAIL_COND_MSG(is_compressed(), "Cannot resize in compressed image formats.");
int w = Math::next_power_of_2((uint32_t)width);
int h = Math::next_power_of_2((uint32_t)height);
int w = next_power_of_2((uint32_t)width);
int h = next_power_of_2((uint32_t)height);
if (p_square) {
w = h = MAX(w, h);
}
@ -1257,6 +1255,9 @@ void Image::resize_to_po2(bool p_square, Interpolation p_interpolation) {
void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
ERR_FAIL_COND_MSG(data.is_empty(), "Cannot resize image before creating it, use set_data() first.");
ERR_FAIL_COND_MSG(is_compressed(), "Cannot resize in compressed image formats.");
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
ERR_FAIL_COND_MSG(p_width <= 0, "Image width must be greater than 0.");
ERR_FAIL_COND_MSG(p_height <= 0, "Image height must be greater than 0.");
ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, vformat("Image width cannot be greater than %d pixels.", MAX_WIDTH));
@ -1267,19 +1268,9 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
return;
}
// Convert the image to 'standard' RGB(A) formats that may be resized.
Format original_format = format;
if (original_format == FORMAT_RGB565 || original_format == FORMAT_RGBA4444) {
convert(FORMAT_RGBA8);
} else if (original_format == FORMAT_RGBE9995) {
convert(FORMAT_RGBH);
}
Image dst(p_width, p_height, false, format);
// Setup mipmap-aware scaling
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
Image dst2;
int mip1 = 0;
int mip2 = 0;
@ -1623,11 +1614,6 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
}
_copy_internals_from(dst);
// Reconvert the image to its original format.
if (original_format != format) {
convert(original_format);
}
}
void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
@ -2614,24 +2600,24 @@ void Image::initialize_data(const char **p_xpm) {
#define DETECT_ALPHA_MAX_THRESHOLD 254
#define DETECT_ALPHA_MIN_THRESHOLD 2
#define DETECT_ALPHA(m_value) \
{ \
uint8_t value = m_value; \
if (value < DETECT_ALPHA_MIN_THRESHOLD) \
bit = true; \
#define DETECT_ALPHA(m_value) \
{ \
uint8_t value = m_value; \
if (value < DETECT_ALPHA_MIN_THRESHOLD) \
bit = true; \
else if (value < DETECT_ALPHA_MAX_THRESHOLD) { \
detected = true; \
break; \
} \
detected = true; \
break; \
} \
}
#define DETECT_NON_ALPHA(m_value) \
{ \
uint8_t value = m_value; \
if (value > 0) { \
detected = true; \
break; \
} \
{ \
uint8_t value = m_value; \
if (value > 0) { \
detected = true; \
break; \
} \
}
bool Image::is_invisible() const {
@ -2821,18 +2807,19 @@ Vector<uint8_t> Image::save_jpg_to_buffer(float p_quality) const {
return save_jpg_buffer_func(Ref<Image>((Image *)this), p_quality);
}
Error Image::save_exr(const String &p_path, bool p_grayscale, bool p_color_image, float p_max_value) const {
Error Image::save_exr(const String &p_path, bool p_grayscale) const {
if (save_exr_func == nullptr) {
return ERR_UNAVAILABLE;
}
return save_exr_func(p_path, Ref<Image>((Image *)this), p_grayscale, p_color_image, p_max_value);
return save_exr_func(p_path, Ref<Image>((Image *)this), p_grayscale);
}
Vector<uint8_t> Image::save_exr_to_buffer(bool p_grayscale, bool p_color_image, float p_max_value) const {
Vector<uint8_t> Image::save_exr_to_buffer(bool p_grayscale) const {
if (save_exr_buffer_func == nullptr) {
return Vector<uint8_t>();
}
return save_exr_buffer_func(Ref<Image>((Image *)this), p_grayscale, p_color_image, p_max_value);
return save_exr_buffer_func(Ref<Image>((Image *)this), p_grayscale);
}
Error Image::save_dds(const String &p_path) const {
@ -3879,8 +3866,8 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("save_png_to_buffer"), &Image::save_png_to_buffer);
ClassDB::bind_method(D_METHOD("save_jpg", "path", "quality"), &Image::save_jpg, DEFVAL(0.75));
ClassDB::bind_method(D_METHOD("save_jpg_to_buffer", "quality"), &Image::save_jpg_to_buffer, DEFVAL(0.75));
ClassDB::bind_method(D_METHOD("save_exr", "path", "grayscale", "color_image", "max_linear_value"), &Image::save_exr, DEFVAL(false), DEFVAL(false), DEFVAL(-1.0));
ClassDB::bind_method(D_METHOD("save_exr_to_buffer", "grayscale", "color_image", "max_linear_value"), &Image::save_exr_to_buffer, DEFVAL(false), DEFVAL(false), DEFVAL(-1.0));
ClassDB::bind_method(D_METHOD("save_exr", "path", "grayscale"), &Image::save_exr, DEFVAL(false));
ClassDB::bind_method(D_METHOD("save_exr_to_buffer", "grayscale"), &Image::save_exr_to_buffer, DEFVAL(false));
ClassDB::bind_method(D_METHOD("save_dds", "path"), &Image::save_dds);
ClassDB::bind_method(D_METHOD("save_dds_to_buffer"), &Image::save_dds_to_buffer);