Better exception name and deprecation
This commit is contained in:
parent
338a875b9c
commit
322d433467
|
@ -6,6 +6,7 @@ import android.graphics.ColorFilter
|
||||||
import android.graphics.PixelFormat
|
import android.graphics.PixelFormat
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
|
|
||||||
|
@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING)
|
||||||
internal class BitmapDrawable(private val bitmap: Bitmap) : Drawable() {
|
internal class BitmapDrawable(private val bitmap: Bitmap) : Drawable() {
|
||||||
|
|
||||||
override fun draw(canvas: Canvas) {
|
override fun draw(canvas: Canvas) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.drawable.AnimationDrawable
|
||||||
* Extension of the [AnimationDrawable] that provides an animationListener This will allow
|
* Extension of the [AnimationDrawable] that provides an animationListener This will allow
|
||||||
* for the caller to listen for specific animation related events.
|
* for the caller to listen for specific animation related events.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING)
|
||||||
class CustomAnimationDrawable : AnimationDrawable() {
|
class CustomAnimationDrawable : AnimationDrawable() {
|
||||||
private var onFrameChangeListener : (index : Int) -> Unit? = {}
|
private var onFrameChangeListener : (index : Int) -> Unit? = {}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import oupson.apng.utils.Utils.Companion.isPng
|
||||||
* @param maxWidth The max width of the APNG
|
* @param maxWidth The max width of the APNG
|
||||||
* @param maxHeight The max height of the APNG
|
* @param maxHeight The max height of the APNG
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Deprecated, Use ApngEncoder and ApngDecoder instead", level = DeprecationLevel.WARNING)
|
||||||
class Frame // Get width and height for image
|
class Frame // Get width and height for image
|
||||||
(
|
(
|
||||||
byteArray: ByteArray,
|
byteArray: ByteArray,
|
||||||
|
|
|
@ -28,6 +28,6 @@ class InvalidFrameSizeException(animationWidth : Int, animationHeight : Int, fra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BadFrameDiffSize(firstFrameWidth : Int, firstFrameHeight : Int, secondFrameWidth : Int, secondFrameHeight : Int) : Exception() {
|
class BadBitmapsDiffSize(firstBitmapWidth : Int, firstBitmapHeight : Int, secondBitmapWidth : Int, secondBitmapHeight : Int) : Exception() {
|
||||||
override val message: String = "${firstFrameWidth}x${firstFrameHeight} must be smaller than ${secondFrameWidth}x${secondFrameHeight}"
|
override val message: String = "${firstBitmapWidth}x${firstBitmapHeight} must be bigger than or equal to ${secondBitmapWidth}x${secondBitmapHeight}"
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ package oupson.apng.utils
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import oupson.apng.exceptions.BadFrameDiffSize
|
import oupson.apng.exceptions.BadBitmapsDiffSize
|
||||||
import oupson.apng.utils.Utils.Companion.BlendOp.APNG_BLEND_OP_OVER
|
import oupson.apng.utils.Utils.Companion.BlendOp.APNG_BLEND_OP_OVER
|
||||||
import oupson.apng.utils.Utils.Companion.BlendOp.APNG_BLEND_OP_SOURCE
|
import oupson.apng.utils.Utils.Companion.BlendOp.APNG_BLEND_OP_SOURCE
|
||||||
import oupson.apng.utils.Utils.Companion.DisposeOp.*
|
import oupson.apng.utils.Utils.Companion.DisposeOp.*
|
||||||
|
@ -225,10 +225,10 @@ class Utils {
|
||||||
* @param secondBitmap A [Bitmap], a second bitmap
|
* @param secondBitmap A [Bitmap], a second bitmap
|
||||||
* @return [DiffResult], the difference between the second and the first bitmap
|
* @return [DiffResult], the difference between the second and the first bitmap
|
||||||
*/
|
*/
|
||||||
@Throws(BadFrameDiffSize::class)
|
@Throws(BadBitmapsDiffSize::class)
|
||||||
fun getDiffBitmap(firstBitmap : Bitmap, secondBitmap : Bitmap) : DiffResult {
|
fun getDiffBitmap(firstBitmap : Bitmap, secondBitmap : Bitmap) : DiffResult {
|
||||||
if (firstBitmap.width < secondBitmap.width || firstBitmap.height < secondBitmap.height) {
|
if (firstBitmap.width < secondBitmap.width || firstBitmap.height < secondBitmap.height) {
|
||||||
throw BadFrameDiffSize(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)
|
||||||
|
|
Loading…
Reference in New Issue