From 4edcd7087102bcd6c5c9194dd6ff95ce84f7bad8 Mon Sep 17 00:00:00 2001 From: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> Date: Thu, 23 May 2024 11:51:00 +0500 Subject: [PATCH] simplify api --- .../kotatsu/parsers/MangaLoaderContext.kt | 5 ++ .../koitharu/kotatsu/parsers/bitmap/Bitmap.kt | 53 ++----------------- .../parsers/site/all/MangaReaderToParser.kt | 2 +- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaLoaderContext.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaLoaderContext.kt index eca1324e3..0e755d14b 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 ebbfdcea8..6162e13ca 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 7f0d69df3..02ca01cd1 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) {