OSDN Git Service

TexturePacker2, use -1,-1 if x or y ninepatch padding is omitted.
authorNathanSweet <nathan.sweet@gmail.com>
Thu, 4 Oct 2012 07:01:12 +0000 (00:01 -0700)
committerNathanSweet <nathan.sweet@gmail.com>
Thu, 4 Oct 2012 07:01:12 +0000 (00:01 -0700)
extensions/gdx-tools/src/com/badlogic/gdx/tools/imagepacker/ImageProcessor.java

index 4e04e45..2faea8a 100644 (file)
@@ -243,20 +243,30 @@ public class ImageProcessor {
                        return null;\r
                }\r
 \r
-               // Subtraction here is because the coordinates were computed before the 1px border was stripped.\r
-               if (startX > 0) {\r
-                       startX--;\r
-                       endX = raster.getWidth() - 2 - (endX - 1);\r
+               // -2 here is because the coordinates were computed before the 1px border was stripped.\r
+               if (startX == 0 && endX == 0) {\r
+                       startX = -1;\r
+                       endX = -1;\r
                } else {\r
-                       // If no start point was ever found, we assume full stretch.\r
-                       endX = raster.getWidth() - 2;\r
+                       if (startX > 0) {\r
+                               startX--;\r
+                               endX = raster.getWidth() - 2 - (endX - 1);\r
+                       } else {\r
+                               // If no start point was ever found, we assume full stretch.\r
+                               endX = raster.getWidth() - 2;\r
+                       }\r
                }\r
-               if (startY > 0) {\r
-                       startY--;\r
-                       endY = raster.getHeight() - 2 - (endY - 1);\r
+               if (startY == 0 && endY == 0) {\r
+                       startY = -1;\r
+                       endY = -1;\r
                } else {\r
-                       // If no start point was ever found, we assume full stretch.\r
-                       endY = raster.getHeight() - 2;\r
+                       if (startY > 0) {\r
+                               startY--;\r
+                               endY = raster.getHeight() - 2 - (endY - 1);\r
+                       } else {\r
+                               // If no start point was ever found, we assume full stretch.\r
+                               endY = raster.getHeight() - 2;\r
+                       }\r
                }\r
 \r
                int[] pads = new int[] {startX, endX, startY, endY};\r