Yokan / rebuild
Course 1 8624561

EinkPageTranscoder.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/services/download/EinkPageTranscoder.kt

implementation14 lines
1package eu.friedcutlet.yokan.services.download23/**4 * Re-encodes a downloaded manga page as a grayscale JPEG whose short side is at most [maxShortSide]5 * (see [eu.friedcutlet.yokan.database.einkScaledSize]). Null keeps the original bytes: undecodable or6 * animated images, or a result that would not be smaller.7 */8internal expect fun transcodeEinkPage(bytes: ByteArray, maxShortSide: Int): ByteArray?910internal const val EinkJpegQuality = 851112/** GIFs may be animated; the decoders below would keep only the first frame. */13internal fun ByteArray.isGif(): Boolean =14    size >= 4 && this[0] == 'G'.code.toByte() && this[1] == 'I'.code.toByte() && this[2] == 'F'.code.toByte() && this[3] == '8'.code.toByte()15

Search chapters, reference and source filenames.