-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for release
- Loading branch information
Showing
14 changed files
with
88 additions
and
201 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package oupson.apng.chunks | ||
|
||
interface Chunk { | ||
var body : ByteArray | ||
fun parse(byteArray: ByteArray) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
package oupson.apng.chunks | ||
|
||
class IDAT { | ||
private var bodySize = -1 | ||
import oupson.apng.utils.Utils.Companion.parseLength | ||
|
||
class IDAT : Chunk { | ||
var IDATBody: ArrayList<ByteArray> = ArrayList() | ||
override var body = byteArrayOf() | ||
|
||
fun parseIDAT(byteArray: ByteArray) { | ||
override fun parse(byteArray: ByteArray) { | ||
for (i in 0 until byteArray.size) { | ||
// Find IDAT chunk | ||
if (byteArray[i] == 0x49.toByte() && byteArray[i + 1] == 0x44.toByte() && byteArray[ i + 2 ] == 0x41.toByte() && byteArray[ i + 3 ] == 0x54.toByte()) { | ||
|
||
// Find the chunk length | ||
var lengthString = "" | ||
byteArray.copyOfRange( i - 4, i).forEach { | ||
lengthString += String.format("%02x", it) | ||
} | ||
bodySize = lengthString.toLong(16).toInt() | ||
|
||
val bodySize = parseLength(byteArray.copyOfRange(i - 4, i)) | ||
// Get image bytes | ||
val _IDATbody = ArrayList<Byte>() | ||
for (j in i +4 until i + 4 + bodySize) { | ||
_IDATbody.add(byteArray[j]) | ||
} | ||
IDATBody.add(_IDATbody.toByteArray()) | ||
IDATBody.add(byteArray.copyOfRange(i + 4, i + 4 + bodySize)) | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.