optmize crop limit

This commit is contained in:
lunarcleint
2024-04-17 00:03:32 -07:00
parent 62515b8b74
commit f0ef31313c
+2 -5
View File
@@ -92,10 +92,8 @@ class BitmapUtil {
var maxX:Int = limit != null ? Std.int(limit.x) : 0;
var maxY:Int = limit != null ? Std.int(limit.y) : 0;
for (y in 0...bitmap.height)
for (x in 0...bitmap.width) {
if (limit != null && !(x >= limit.x && x <= limit.x + limit.width && y >= limit.y && y <= limit.y + limit.height)) continue;
for (y in (limit != null ? Std.int(limit.x) : 0)...(limit != null ? Std.int(limit.height) : bitmap.height))
for (x in (limit != null ? Std.int(limit.y) : 0)...(limit != null ? Std.int(limit.width) : bitmap.width)) {
if (bitmap.getPixel32(x, y) != 0x00000000) {
if (x < minX) minX = x;
if (y < minY) minY = y;
@@ -104,7 +102,6 @@ class BitmapUtil {
}
}
return new Rectangle(minX, minY, maxX-minX+1, maxY-minY+1);
}
}