From 16c3a19d91aa2e8654fc477e8b9ee59c6122a960 Mon Sep 17 00:00:00 2001 From: bitsawer Date: Tue, 19 Sep 2023 13:53:09 +0300 Subject: [PATCH] Expose and document Image.get_mipmap_count() --- core/io/image.cpp | 1 + doc/classes/Image.xml | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/io/image.cpp b/core/io/image.cpp index 204db687d88..674af6b0a63 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -3412,6 +3412,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("convert", "format"), &Image::convert); + ClassDB::bind_method(D_METHOD("get_mipmap_count"), &Image::get_mipmap_count); ClassDB::bind_method(D_METHOD("get_mipmap_offset", "mipmap"), &Image::get_mipmap_offset); ClassDB::bind_method(D_METHOD("resize_to_po2", "square", "interpolation"), &Image::resize_to_po2, DEFVAL(false), DEFVAL(INTERPOLATE_BILINEAR)); diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 5f1f9e6c183..2782e877a95 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -201,7 +201,8 @@ - Generates mipmaps for the image. Mipmaps are precalculated lower-resolution copies of the image that are automatically used if the image needs to be scaled down when rendered. They help improve image quality and performance when rendering. This method returns an error if the image is compressed, in a custom format, or if the image's width/height is [code]0[/code]. + Generates mipmaps for the image. Mipmaps are precalculated lower-resolution copies of the image that are automatically used if the image needs to be scaled down when rendered. They help improve image quality and performance when rendering. This method returns an error if the image is compressed, in a custom format, or if the image's width/height is [code]0[/code]. Enabling [param renormalize] when generating mipmaps for normal textures will make sure all resulting vector values are normalized. + It is possible to check if the image has mipmaps by calling [method has_mipmaps] or [method get_mipmap_count]. @@ -222,6 +223,12 @@ Returns the image's height. + + + + Returns the number of mipmap levels or 0 if the image has no mipmaps. The largest main level image is not counted as a mipmap level by this method, so if you want to include it you can add 1 to this count. + +