Skip to content

Commit

Permalink
Fixed file based 9-patch pad values get displayed wrong.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaphore committed Dec 31, 2018
1 parent 56cc885 commit 886c5a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 886c5a0

Please sign in to comment.