From 04847ef5f98d9a20a72286c44cc26302ec82dec5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 19 Apr 2019 15:54:33 -0300 Subject: Added ability for multiple images to be imported as an atlas This adds support for groups in the import system, which point to a single file. Add property hint for saving files in file field --- core/image.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'core/image.cpp') diff --git a/core/image.cpp b/core/image.cpp index 90afd9f35a..99d5eab864 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1876,7 +1876,7 @@ Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const P Rect2 Image::get_used_rect() const { - if (format != FORMAT_LA8 && format != FORMAT_RGBA8) + if (format != FORMAT_LA8 && format != FORMAT_RGBA8 && format != FORMAT_RGBAF && format != FORMAT_RGBAH && format != FORMAT_RGBA4444 && format != FORMAT_RGBA5551) return Rect2(Point2(), Size2(width, height)); int len = data.size(); @@ -1884,17 +1884,13 @@ Rect2 Image::get_used_rect() const { if (len == 0) return Rect2(); - //int data_size = len; - PoolVector::Read r = data.read(); - const unsigned char *rptr = r.ptr(); - - int ps = format == FORMAT_LA8 ? 2 : 4; + const_cast(this)->lock(); int minx = 0xFFFFFF, miny = 0xFFFFFFF; int maxx = -1, maxy = -1; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { - bool opaque = rptr[(j * width + i) * ps + (ps - 1)] > 2; + bool opaque = get_pixel(i, j).a > 0.99; if (!opaque) continue; if (i > maxx) @@ -1908,6 +1904,8 @@ Rect2 Image::get_used_rect() const { } } + const_cast(this)->unlock(); + if (maxx == -1) return Rect2(); else -- cgit v1.2.3