More TODO
This commit is contained in:
parent
36ac99d97f
commit
b4bd0dd17e
|
@ -2,6 +2,7 @@ package oupson.apng.chunks
|
|||
|
||||
import oupson.apng.utils.Utils
|
||||
|
||||
// TODO REMOVE
|
||||
class IHDR : Chunk {
|
||||
override var body = byteArrayOf()
|
||||
var pngWidth = -1
|
||||
|
|
|
@ -5,6 +5,7 @@ import oupson.apng.utils.Utils.Companion.decodeBlendOp
|
|||
import oupson.apng.utils.Utils.Companion.decodeDisposeOp
|
||||
|
||||
@Suppress("ClassName")
|
||||
// TODO REMOVE
|
||||
class fcTL : Chunk {
|
||||
override var body : ByteArray = byteArrayOf()
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ class ApngDecoder {
|
|||
var blendOp: Utils.Companion.BlendOp = Utils.Companion.BlendOp.APNG_BLEND_OP_SOURCE
|
||||
var disposeOp: Utils.Companion.DisposeOp =
|
||||
Utils.Companion.DisposeOp.APNG_DISPOSE_OP_NONE
|
||||
// TODO REMOVE
|
||||
val ihdr = IHDR()
|
||||
var isApng = false
|
||||
|
||||
|
@ -142,6 +143,8 @@ class ApngDecoder {
|
|||
}
|
||||
png = ArrayList()
|
||||
val fcTL = fcTL()
|
||||
|
||||
// TODO REMOVE FCTL CLASS
|
||||
fcTL.parse(byteArray)
|
||||
delay = fcTL.delay
|
||||
yOffset = fcTL.yOffset
|
||||
|
@ -851,6 +854,7 @@ class ApngDecoder {
|
|||
* @param height The height of the frame.
|
||||
* @return [ByteArray] The generated IHDR.
|
||||
*/
|
||||
// TODO REMOVE IHDR
|
||||
private fun generateIhdr(ihdrOfApng: IHDR, width: Int, height: Int): ByteArray {
|
||||
val ihdr = ArrayList<Byte>()
|
||||
// We need a body var to know body length and generate crc
|
||||
|
|
|
@ -217,7 +217,12 @@ class Utils {
|
|||
* @property offsetY the y offset
|
||||
* @property blendOp a [BlendOp]
|
||||
*/
|
||||
data class DiffResult(val bitmap: Bitmap, val offsetX : Int, val offsetY : Int, val blendOp: BlendOp)
|
||||
data class DiffResult(
|
||||
val bitmap: Bitmap,
|
||||
val offsetX: Int,
|
||||
val offsetY: Int,
|
||||
val blendOp: BlendOp
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the difference between two bitmaps
|
||||
|
@ -228,10 +233,19 @@ class Utils {
|
|||
@Throws(BadBitmapsDiffSize::class)
|
||||
fun getDiffBitmap(firstBitmap: Bitmap, secondBitmap: Bitmap): DiffResult {
|
||||
if (firstBitmap.width < secondBitmap.width || firstBitmap.height < secondBitmap.height) {
|
||||
throw BadBitmapsDiffSize(firstBitmap.width, firstBitmap.height, firstBitmap.width, firstBitmap.height)
|
||||
throw BadBitmapsDiffSize(
|
||||
firstBitmap.width,
|
||||
firstBitmap.height,
|
||||
firstBitmap.width,
|
||||
firstBitmap.height
|
||||
)
|
||||
}
|
||||
|
||||
val resultBtm = Bitmap.createBitmap(secondBitmap.width, secondBitmap.height, Bitmap.Config.ARGB_8888)
|
||||
val resultBtm = Bitmap.createBitmap(
|
||||
secondBitmap.width,
|
||||
secondBitmap.height,
|
||||
Bitmap.Config.ARGB_8888
|
||||
)
|
||||
|
||||
var offsetX = resultBtm.width + 1
|
||||
var offsetY = resultBtm.height + 1
|
||||
|
@ -240,12 +254,17 @@ class Utils {
|
|||
var lastY = 0
|
||||
|
||||
// Find if the image contain transparent pixels, if true, then transparent pixels must replace the pixels in the buffer
|
||||
val blendOp = if(containTransparency(secondBitmap)) APNG_BLEND_OP_SOURCE else APNG_BLEND_OP_OVER
|
||||
val blendOp =
|
||||
if (containTransparency(secondBitmap)) APNG_BLEND_OP_SOURCE else APNG_BLEND_OP_OVER
|
||||
|
||||
for (y in 0 until secondBitmap.height) {
|
||||
for (x in 0 until secondBitmap.width) {
|
||||
val btmPixel = secondBitmap.getPixel(x, y)
|
||||
if (firstBitmap.getPixel(x, y) == btmPixel) { // Similar pixels could be forgotten
|
||||
if (firstBitmap.getPixel(
|
||||
x,
|
||||
y
|
||||
) == btmPixel
|
||||
) { // Similar pixels could be forgotten
|
||||
if (blendOp == APNG_BLEND_OP_OVER)
|
||||
resultBtm.setPixel(x, y, Color.TRANSPARENT)
|
||||
else
|
||||
|
@ -271,7 +290,8 @@ class Utils {
|
|||
val newHeight = lastY - offsetY
|
||||
|
||||
// Resize bitmap
|
||||
val resizedResultBtm = Bitmap.createBitmap(resultBtm, offsetX, offsetY, newWidth, newHeight)
|
||||
val resizedResultBtm =
|
||||
Bitmap.createBitmap(resultBtm, offsetX, offsetY, newWidth, newHeight)
|
||||
|
||||
return DiffResult(resizedResultBtm, offsetX, offsetY, blendOp)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue