OSDN Git Service

Add support for ImageProcessor to accept BufferedImage objects as input
authorManuel Bua <manuel.bua@gmail.com>
Wed, 8 May 2013 19:28:29 +0000 (21:28 +0200)
committerManuel Bua <manuel.bua@gmail.com>
Wed, 8 May 2013 19:28:29 +0000 (21:28 +0200)
Update TexturePacker2 to accommodate ImageProcessor changes and exposes new
constructor and method.

extensions/gdx-tools/src/com/badlogic/gdx/tools/imagepacker/ImageProcessor.java
extensions/gdx-tools/src/com/badlogic/gdx/tools/imagepacker/TexturePacker2.java

index d21b310..0483b13 100644 (file)
@@ -46,8 +46,14 @@ public class ImageProcessor {
        public ImageProcessor (File rootDir, Settings settings) {\r
                this.settings = settings;\r
 \r
-               rootPath = rootDir.getAbsolutePath().replace('\\', '/');\r
-               if (!rootPath.endsWith("/")) rootPath += "/";\r
+               if (rootDir != null) {\r
+                       rootPath = rootDir.getAbsolutePath().replace('\\', '/');\r
+                       if (!rootPath.endsWith("/")) rootPath += "/";\r
+               }\r
+       }\r
+\r
+       public ImageProcessor (Settings settings) {\r
+               this(null, settings);\r
        }\r
 \r
        public void addImage (File file) {\r
@@ -68,6 +74,10 @@ public class ImageProcessor {
                int dotIndex = name.lastIndexOf('.');\r
                if (dotIndex != -1) name = name.substring(0, dotIndex);\r
 \r
+               addImage(image, name);\r
+       }\r
+\r
+       public void addImage (BufferedImage image, String name) {\r
                Rect rect = null;\r
 \r
                // Strip ".9" from file name, read ninepatch split pixels, and strip ninepatch split pixels.\r
index 8c8b7f5..81a0558 100644 (file)
@@ -65,10 +65,18 @@ public class TexturePacker2 {
                imageProcessor = new ImageProcessor(rootDir, settings);\r
        }\r
 \r
+       public TexturePacker2 (Settings settings) {\r
+               this(null, settings);\r
+       }\r
+\r
        public void addImage (File file) {\r
                imageProcessor.addImage(file);\r
        }\r
 \r
+       public void addImage (BufferedImage image, String name) {\r
+               imageProcessor.addImage(image, name);\r
+       }\r
+\r
        public void pack (File outputDir, String packFileName) {\r
                outputDir.mkdirs();\r
 \r