Skip to content

Commit

Permalink
Fix image dimension derivation, add test images from http://pdpxart.t…
Browse files Browse the repository at this point in the history
…umblr.com

Took 9 minutes
  • Loading branch information
Darkyenus committed Sep 3, 2017
1 parent a4e880b commit 1ed5271
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ loading the image data into a internal image representation (bitmap). These flag
This flag also has multiple alternate forms: `#RGB`, `#RGBA`, `#RRGGBB`. Each letter (`R`, `G`, `B` or `A`) is
a hexadecimal digit.
* `9` - This image is a ninepatch (currently available only for bitmap images) (see *Dimensions* below)
* `scaling <algo>` - Use scaling algorithm `<algo>` available algorithms are `nearest`, `bilinear` and `bicubic`

**Dimensions**
In image scaling flags, `<W>` or `<H>` can not only contain a positive decimal number, but also a single symbol `?`.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/darkyen/resourcepacker/image/Image.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ sealed class Image(val file:Resource.ResourceFile, private val canBeNinepatch:Bo
}

if (newWidth == -1) {
newWidth = Math.round((_width.toDouble() / _height.toDouble()) * newHeight).toInt()
newWidth = Math.round((_fileWidth.toDouble() / _fileHeight.toDouble()) * newHeight).toInt()
} else {
newHeight = Math.round((_height.toDouble() / _width.toDouble()) * newWidth).toInt()
newHeight = Math.round((_fileHeight.toDouble() / _fileWidth.toDouble()) * newWidth).toInt()
}
_width = newWidth
_height = newHeight
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1ed5271

Please sign in to comment.