1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

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
This commit is contained in:
Juan Linietsky
2019-04-19 15:54:33 -03:00
parent 8e652a1400
commit 04847ef5f9
35 changed files with 1818 additions and 33 deletions

View File

@@ -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<uint8_t>::Read r = data.read();
const unsigned char *rptr = r.ptr();
int ps = format == FORMAT_LA8 ? 2 : 4;
const_cast<Image *>(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<Image *>(this)->unlock();
if (maxx == -1)
return Rect2();
else