diff options
Diffstat (limited to 'scene/resources/bit_mask.cpp')
-rw-r--r-- | scene/resources/bit_mask.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index b8a9ea3361..e512f8a968 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -41,16 +41,16 @@ void BitMap::create(const Size2 &p_size) { zeromem(bitmask.ptr(), bitmask.size()); } -void BitMap::create_from_image_alpha(const Image &p_image) { +void BitMap::create_from_image_alpha(const Ref<Image> &p_image) { - ERR_FAIL_COND(p_image.empty()); - Image img = p_image; - img.convert(Image::FORMAT_LA8); - ERR_FAIL_COND(img.get_format() != Image::FORMAT_LA8); + ERR_FAIL_COND(p_image.is_null() || p_image->empty()); + Ref<Image> img = p_image->duplicate(); + img->convert(Image::FORMAT_LA8); + ERR_FAIL_COND(img->get_format() != Image::FORMAT_LA8); - create(Size2(img.get_width(), img.get_height())); + create(Size2(img->get_width(), img->get_height())); - PoolVector<uint8_t>::Read r = img.get_data().read(); + PoolVector<uint8_t>::Read r = img->get_data().read(); uint8_t *w = bitmask.ptr(); for (int i = 0; i < width * height; i++) { |