From 941879f6019db256c40a471f1a05b4e94d24d97b Mon Sep 17 00:00:00 2001
From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
Date: Sun, 12 Dec 2021 01:05:25 +0200
Subject: [PATCH] Expose BitMap's `convert_to_image` and `resize` methods to
GDScript
(cherry picked from commit 453912d48d320e358480d768414e8373964c51b1)
---
doc/classes/BitMap.xml | 13 +++++++++++++
scene/resources/bit_map.cpp | 2 ++
2 files changed, 15 insertions(+)
diff --git a/doc/classes/BitMap.xml b/doc/classes/BitMap.xml
index 78749d046cd..2308978c0ca 100644
--- a/doc/classes/BitMap.xml
+++ b/doc/classes/BitMap.xml
@@ -9,6 +9,12 @@
+
+
+
+ Returns an image of the same size as the bitmap and with a [enum Image.Format] of type [code]FORMAT_L8[/code]. [code]true[/code] bits of the bitmap are being converted into white pixels, and [code]false[/code] bits into black.
+
+
@@ -58,6 +64,13 @@
+
+
+
+
+ Resizes the image to [code]new_size[/code].
+
+
diff --git a/scene/resources/bit_map.cpp b/scene/resources/bit_map.cpp
index c4b7afa0aef..1b833b8325d 100644
--- a/scene/resources/bit_map.cpp
+++ b/scene/resources/bit_map.cpp
@@ -668,11 +668,13 @@ void BitMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_true_bit_count"), &BitMap::get_true_bit_count);
ClassDB::bind_method(D_METHOD("get_size"), &BitMap::get_size);
+ ClassDB::bind_method(D_METHOD("resize", "new_size"), &BitMap::resize);
ClassDB::bind_method(D_METHOD("_set_data"), &BitMap::_set_data);
ClassDB::bind_method(D_METHOD("_get_data"), &BitMap::_get_data);
ClassDB::bind_method(D_METHOD("grow_mask", "pixels", "rect"), &BitMap::grow_mask);
+ ClassDB::bind_method(D_METHOD("convert_to_image"), &BitMap::convert_to_image);
ClassDB::bind_method(D_METHOD("opaque_to_polygons", "rect", "epsilon"), &BitMap::_opaque_to_polygons_bind, DEFVAL(2.0));
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");