From 886c5a0af5d33473627b8dbe54de71ca5f8f6431 Mon Sep 17 00:00:00 2001 From: Anton Chekulaev Date: Mon, 31 Dec 2018 17:48:14 +0700 Subject: [PATCH] Fixed file based 9-patch pad values get displayed wrong. --- CHANGES | 1 + .../ninepatcheditor/NinePatchEditorModel.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGES b/CHANGES index cc235ef8..dc4f49d6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ [LATEST] - Fixed high DPI scaling issue. +- Fixed file based 9-patch pad values get displayed wrong (in case they are not defined explicitly in the input image). [4.8.1] - Fixed texture regions get written with wrong padding. diff --git a/core/src/com/crashinvaders/texturepackergui/controllers/ninepatcheditor/NinePatchEditorModel.java b/core/src/com/crashinvaders/texturepackergui/controllers/ninepatcheditor/NinePatchEditorModel.java index 50bf1bc2..a06ce1ad 100644 --- a/core/src/com/crashinvaders/texturepackergui/controllers/ninepatcheditor/NinePatchEditorModel.java +++ b/core/src/com/crashinvaders/texturepackergui/controllers/ninepatcheditor/NinePatchEditorModel.java @@ -73,6 +73,11 @@ private Pixmap parseDataFromNinePatch(FileHandle imageFile) { break; } } + // If horizontal pad values are not defined, they equal to the horizontal patch values. + if (!padLeftFound) { + contentValues.left.set(patchValues.left.get()); + contentValues.right.set(patchValues.right.get()); + } boolean padTopFound = false; for (int y = 1; y < pixmap.getHeight()-1; y++) { int color = pixmap.getPixel(pixmap.getWidth()-1, y); @@ -84,6 +89,11 @@ private Pixmap parseDataFromNinePatch(FileHandle imageFile) { break; } } + // If vertical pad values are not defined, they equal to the vertical patch values. + if (!padTopFound) { + contentValues.top.set(patchValues.top.get()); + contentValues.bottom.set(patchValues.bottom.get()); + } // Cut off 1-pixel border markup Pixmap contentPixmap = new Pixmap(pixmap.getWidth() - 2, pixmap.getHeight() - 2, pixmap.getFormat());