diff --git a/apng_library/Module.md b/apng_library/Module.md index 57ee61c..24919bf 100644 --- a/apng_library/Module.md +++ b/apng_library/Module.md @@ -8,7 +8,7 @@ Contain things related to chunk parsing. # Package oupson.apng.decoder Contain class for decode APNG. -a + # Package oupson.apng.encoder Contain class for encoding APNG. diff --git a/apng_library/src/main/java/oupson/apng/APNGDisassembler.kt b/apng_library/src/main/java/oupson/apng/APNGDisassembler.kt index 59974e0..a22dea5 100644 --- a/apng_library/src/main/java/oupson/apng/APNGDisassembler.kt +++ b/apng_library/src/main/java/oupson/apng/APNGDisassembler.kt @@ -3,8 +3,8 @@ package oupson.apng import android.graphics.BitmapFactory import oupson.apng.chunks.IHDR import oupson.apng.chunks.fcTL -import oupson.apng.exceptions.BadApng -import oupson.apng.exceptions.BadCRC +import oupson.apng.exceptions.BadApngException +import oupson.apng.exceptions.BadCRCException import oupson.apng.exceptions.NotApngException import oupson.apng.exceptions.NotPngException import oupson.apng.utils.Utils @@ -18,6 +18,7 @@ import java.util.* import java.util.zip.CRC32 // TODO REWRITE +@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING) class APNGDisassembler { private var png: ArrayList? = null private var cover: ArrayList? = null @@ -163,9 +164,9 @@ class APNGDisassembler { val height = fcTL.pngHeight if (xOffset + width > maxWidth) { - throw BadApng("`yOffset` + `height` must be <= `IHDR` height") + throw BadApngException("`yOffset` + `height` must be <= `IHDR` height") } else if (yOffset + height > maxHeight) { - throw BadApng("`yOffset` + `height` must be <= `IHDR` height") + throw BadApngException("`yOffset` + `height` must be <= `IHDR` height") } png?.addAll(pngSignature.asList()) @@ -315,7 +316,7 @@ class APNGDisassembler { isApng = true } } - } else throw BadCRC() + } else throw BadCRCException() } /** diff --git a/apng_library/src/main/java/oupson/apng/Apng.kt b/apng_library/src/main/java/oupson/apng/Apng.kt index dbdbda0..e646d6e 100644 --- a/apng_library/src/main/java/oupson/apng/Apng.kt +++ b/apng_library/src/main/java/oupson/apng/Apng.kt @@ -24,6 +24,7 @@ import java.util.zip.CRC32 * If you want to create an APNG, use ApngEncoder instead */ @Suppress("unused") +@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING) class Apng { @Suppress("MemberVisibilityCanBePrivate") var maxWidth : Int? = null diff --git a/apng_library/src/main/java/oupson/apng/ApngAnimator.kt b/apng_library/src/main/java/oupson/apng/ApngAnimator.kt index 10d9c9a..6032834 100644 --- a/apng_library/src/main/java/oupson/apng/ApngAnimator.kt +++ b/apng_library/src/main/java/oupson/apng/ApngAnimator.kt @@ -26,6 +26,7 @@ import java.net.URL * Class to play APNG * For better performance but lesser features using [oupson.apng.decoder.ApngDecoder] is strongly recommended. */ +@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING) class ApngAnimator(private val context: Context?) { companion object { /** diff --git a/apng_library/src/main/java/oupson/apng/decoder/ApngDecoder.kt b/apng_library/src/main/java/oupson/apng/decoder/ApngDecoder.kt index 8921836..c8f1571 100644 --- a/apng_library/src/main/java/oupson/apng/decoder/ApngDecoder.kt +++ b/apng_library/src/main/java/oupson/apng/decoder/ApngDecoder.kt @@ -20,8 +20,8 @@ import oupson.apng.Loader import oupson.apng.chunks.IHDR import oupson.apng.chunks.fcTL import oupson.apng.decoder.ApngDecoder.Companion.decodeApng -import oupson.apng.exceptions.BadApng -import oupson.apng.exceptions.BadCRC +import oupson.apng.exceptions.BadApngException +import oupson.apng.exceptions.BadCRCException import oupson.apng.utils.Utils import oupson.apng.utils.Utils.Companion.isPng import java.io.* @@ -152,9 +152,9 @@ class ApngDecoder { val height = fcTL.pngHeight if (xOffset + width > maxWidth) { - throw BadApng("`xOffset` + `width` must be <= `IHDR` width") + throw BadApngException("`xOffset` + `width` must be <= `IHDR` width") } else if (yOffset + height > maxHeight) { - throw BadApng("`yOffset` + `height` must be <= `IHDR` height") + throw BadApngException("`yOffset` + `height` must be <= `IHDR` height") } png.addAll(Utils.pngSignature.asList()) @@ -468,7 +468,7 @@ class ApngDecoder { isApng = true } } - } else throw BadCRC() + } else throw BadCRCException() } while (byteRead != -1) inputStream.close() return drawable diff --git a/apng_library/src/main/java/oupson/apng/encoder/ApngEncoder.kt b/apng_library/src/main/java/oupson/apng/encoder/ApngEncoder.kt index 7f37b9c..b616ddf 100644 --- a/apng_library/src/main/java/oupson/apng/encoder/ApngEncoder.kt +++ b/apng_library/src/main/java/oupson/apng/encoder/ApngEncoder.kt @@ -33,6 +33,7 @@ class ApngEncoder( // TODO ADD SUPPORT FOR FIRST FRAME NOT IN ANIM // TODO OPTIMISE APNG + @Suppress("unused") @JvmOverloads fun writeFrame( inputStream: InputStream, @@ -119,6 +120,7 @@ class ApngEncoder( }*/ } + @Suppress("unused") fun writeEnd() { // Add IEND body length : 0 outputStream.write(Utils.to4BytesArray(0)) diff --git a/apng_library/src/main/java/oupson/apng/encoder/ExperimentalApngEncoder.kt b/apng_library/src/main/java/oupson/apng/encoder/ExperimentalApngEncoder.kt index dbf18a2..b5361f0 100644 --- a/apng_library/src/main/java/oupson/apng/encoder/ExperimentalApngEncoder.kt +++ b/apng_library/src/main/java/oupson/apng/encoder/ExperimentalApngEncoder.kt @@ -3,7 +3,7 @@ package oupson.apng.encoder import android.graphics.Bitmap import android.graphics.BitmapFactory import android.util.Log -import oupson.apng.exceptions.InvalidFrameSize +import oupson.apng.exceptions.InvalidFrameSizeException import oupson.apng.utils.Utils import java.io.ByteArrayOutputStream import java.io.IOException @@ -165,14 +165,13 @@ class ExperimentalApngEncoder( * @param blendOp See [Utils.BlendOp]. * @param disposeOp See [Utils.DisposeOp]. * @throws NullPointerException If the bitmap failed to be decoded - * @throws InvalidFrameSize If the frame size is bigger than the animation size, or the first frame size is not equal to the animation size. + * @throws InvalidFrameSizeException If the frame size is bigger than the animation size, or the first frame size is not equal to the animation size. * @throws IOException If something failed when writing into the output stream. */ @JvmOverloads @Throws( NullPointerException::class, - InvalidFrameSize::class, - InvalidFrameSize::class, + InvalidFrameSizeException::class, IOException::class ) fun writeFrame( @@ -197,11 +196,11 @@ class ExperimentalApngEncoder( * @param yOffsets The offset of the top bound of the frame in the animation. * @param blendOp See [Utils.BlendOp]. * @param disposeOp See [Utils.DisposeOp]. - * @throws InvalidFrameSize If the frame size is bigger than the animation size, or the first frame size is not equal to the animation size. + * @throws InvalidFrameSizeException If the frame size is bigger than the animation size, or the first frame size is not equal to the animation size. * @throws IOException If something failed when writing into the output stream. */ @JvmOverloads - @Throws(InvalidFrameSize::class, IOException::class) + @Throws(InvalidFrameSizeException::class, IOException::class) fun writeFrame( btm: Bitmap, delay: Float = 1000f, @@ -212,15 +211,15 @@ class ExperimentalApngEncoder( ) { if (currentFrame == 0) { if (btm.width != width) - throw InvalidFrameSize("Width of first frame must be equal to width of APNG. (${btm.width} != $width)") + throw InvalidFrameSizeException("Width of first frame must be equal to width of APNG. (${btm.width} != $width)") if (btm.height != height) - throw InvalidFrameSize("Height of first frame must be equal to height of APNG. (${btm.height} != $height)") + throw InvalidFrameSizeException("Height of first frame must be equal to height of APNG. (${btm.height} != $height)") } if (btm.width > width) - throw InvalidFrameSize("Frame width must be inferior or equal at the animation width") + throw InvalidFrameSizeException("Frame width must be inferior or equal at the animation width") else if (btm.height > height) - throw InvalidFrameSize("Frame height must be inferior or equal at the animation height") + throw InvalidFrameSizeException("Frame height must be inferior or equal at the animation height") writeFCTL(btm, delay, disposeOp, blendOp, xOffsets, yOffsets) writeImageData(btm) diff --git a/apng_library/src/main/java/oupson/apng/exceptions/customException.kt b/apng_library/src/main/java/oupson/apng/exceptions/customException.kt index 2c71b0e..88e9791 100644 --- a/apng_library/src/main/java/oupson/apng/exceptions/customException.kt +++ b/apng_library/src/main/java/oupson/apng/exceptions/customException.kt @@ -1,12 +1,9 @@ -@file:Suppress("unused") - package oupson.apng.exceptions class NoFrameException : Exception() class NotPngException : Exception() class NotApngException : Exception() -class NoFcTL : Exception() -class BadCRC : Exception() -class BadApng(override val message: String? = null) : Exception() +class BadCRCException : Exception() +class BadApngException(override val message: String? = null) : Exception() -class InvalidFrameSize(override val message: String?) : Exception() \ No newline at end of file +class InvalidFrameSizeException(override val message: String?) : Exception() \ No newline at end of file diff --git a/apng_library/src/main/java/oupson/apng/imageUtils/PngEncoder.kt b/apng_library/src/main/java/oupson/apng/imageUtils/PngEncoder.kt index 5989916..7275ae9 100644 --- a/apng_library/src/main/java/oupson/apng/imageUtils/PngEncoder.kt +++ b/apng_library/src/main/java/oupson/apng/imageUtils/PngEncoder.kt @@ -137,6 +137,7 @@ class PngEncoder { return newArray } + @Suppress("unused") fun release() { image?.recycle() image = null