Working on ExperimentalApngEncoder

This commit is contained in:
Oupson 2020-09-16 23:18:55 +02:00
parent 0698836c7a
commit 6321ebe5be
2 changed files with 13 additions and 7 deletions

View File

@ -46,12 +46,16 @@ class ExperimentalApngEncoder(
disposeOp: Utils.Companion.DisposeOp = Utils.Companion.DisposeOp.APNG_DISPOSE_OP_NONE, disposeOp: Utils.Companion.DisposeOp = Utils.Companion.DisposeOp.APNG_DISPOSE_OP_NONE,
usePngEncoder: Boolean = false usePngEncoder: Boolean = false
) { ) {
val btm = BitmapFactory.decodeStream(inputStream).let { val btm = BitmapFactory.decodeStream(inputStream, null, BitmapFactory.Options().also { conf -> if (Build.VERSION.SDK_INT >=
Build.VERSION_CODES.O) {
conf.outConfig = config
}
})?.let {
if (it.config != config) if (it.config != config)
it.copy(config, it.isMutable) it.copy(config, it.isMutable)
else else
it it
} }!!
inputStream.close() inputStream.close()
writeFrame(btm, delay, xOffsets, yOffsets, blendOp, disposeOp, usePngEncoder) writeFrame(btm, delay, xOffsets, yOffsets, blendOp, disposeOp, usePngEncoder)
@ -210,11 +214,11 @@ class ExperimentalApngEncoder(
) )
// COMPRESSION // COMPRESSION
ihdrBody.add(0.toByte()) ihdrBody.add(0)
// FILTER // FILTER
ihdrBody.add(0.toByte()) ihdrBody.add(0)
// INTERLACE // INTERLACE
ihdrBody.add(0.toByte()) ihdrBody.add(0)
// Generate CRC // Generate CRC
val crC32 = CRC32() val crC32 = CRC32()

View File

@ -143,13 +143,15 @@ class CreatorActivity : AppCompatActivity() {
) )
else else
btm, btm,
delay = uri.second.toFloat() delay = uri.second.toFloat(),
usePngEncoder = true
) )
//input.close() //input.close()
} else { } else {
encoder.writeFrame( encoder.writeFrame(
str, str,
delay = uri.second.toFloat() delay = uri.second.toFloat(),
usePngEncoder = true
) )
} }
str.close() str.close()