Skip to content

Commit

Permalink
Merge pull request #1 from LeshaInc/master
Browse files Browse the repository at this point in the history
Use 4 bytes to encode width+height instead of 2
  • Loading branch information
MoonlightOwl authored Oct 20, 2017
2 parents ea91cd7 + 66c4f66 commit cd455c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/kotlin/totoro/pix/converter/Converter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ object Converter {
// encode width / height
val width = Math.min(image.width.toInt(), 160)
val height = Math.min(image.height.toInt(), 100)
matrix.add(width.toByte())
matrix.add((height / 2).toByte())

matrix.add((width shr 8 and 0xFF).toByte())
matrix.add((width shr 0 and 0xFF).toByte())
matrix.add((height / 2 shr 8 and 0xFF).toByte())
matrix.add((height / 2 shr 0 and 0xFF).toByte())

println("Width: $width")
println("Height: $height\n")

Expand Down

0 comments on commit cd455c8

Please sign in to comment.