diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaLoaderContext.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaLoaderContext.kt index eca1324e..0e755d14 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaLoaderContext.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaLoaderContext.kt @@ -44,4 +44,9 @@ abstract class MangaLoaderContext { response: Response, redraw: (image: Bitmap) -> Bitmap ): Response + + abstract fun createBitmap( + width: Int, + height: Int + ): Bitmap } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/bitmap/Bitmap.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/bitmap/Bitmap.kt index ebbfdcea..6162e13c 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/bitmap/Bitmap.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/bitmap/Bitmap.kt @@ -1,53 +1,8 @@ package org.koitharu.kotatsu.parsers.bitmap -import kotlinx.io.Sink +interface Bitmap { + val width: Int + val height: Int -abstract class Bitmap { - abstract val width: Int - abstract val height: Int - - enum class CompressFormat { - JPEG, - PNG, - WEBP_LOSSY, - WEBP_LOSSLESS, - } - - enum class Config { - ALPHA_8, - RGB_565, - ARGB_8888, - RGBA_F16, - HARDWARE, - RGBA_1010102, - } - - abstract fun compress( - format: CompressFormat, - quality: Int, - sink: Sink - ): Boolean - - abstract fun getPixels( - /*@ColorInt*/ - pixels: IntArray, - offset: Int, - stride: Int, - x: Int, - y: Int, - width: Int, - height: Int, - ) - - abstract fun drawBitmap(sourceBitmap: Bitmap, src: Rect, dst: Rect) - - companion object { - fun createBitmap(width: Int, height: Int, config: Config): Bitmap { - throw NotImplementedError("createBitmap(width, height, config) is not implemented") - } - - fun createBitmap(source: Bitmap, x: Int, y: Int, width: Int, height: Int): Bitmap { - throw NotImplementedError("createBitmap(source, x, y, width, height) is not implemented") - } - } + fun drawBitmap(sourceBitmap: Bitmap, src: Rect, dst: Rect) } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt index 7f0d69df..02ca01cd 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/MangaReaderToParser.kt @@ -266,7 +266,7 @@ class MangaReaderToParser(context: MangaLoaderContext) : PagedMangaParser(contex val width = bitmap.width val height = bitmap.height - val result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) + val result = context.createBitmap(width, height) val pieces = ArrayList() for (y in 0 until height step PIECE_SIZE) {