Skip to content

Commit cd455c8

Browse files
authored
Merge pull request #1 from LeshaInc/master
Use 4 bytes to encode width+height instead of 2
2 parents ea91cd7 + 66c4f66 commit cd455c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/kotlin/totoro/pix/converter/Converter.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ object Converter {
1313
// encode width / height
1414
val width = Math.min(image.width.toInt(), 160)
1515
val height = Math.min(image.height.toInt(), 100)
16-
matrix.add(width.toByte())
17-
matrix.add((height / 2).toByte())
16+
17+
matrix.add((width shr 8 and 0xFF).toByte())
18+
matrix.add((width shr 0 and 0xFF).toByte())
19+
matrix.add((height / 2 shr 8 and 0xFF).toByte())
20+
matrix.add((height / 2 shr 0 and 0xFF).toByte())
21+
1822
println("Width: $width")
1923
println("Height: $height\n")
2024

0 commit comments

Comments
 (0)