This commit is contained in:
Raikuha 2024-11-05 16:55:21 -03:00 committed by GitHub
commit 56b35d28bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 4 deletions

View File

@ -32,4 +32,6 @@ class BasePreferences(
fun displayProfile() = preferenceStore.getString("pref_display_profile_key", "")
fun alwaysUseSSIVToDecode() = preferenceStore.getBoolean("pref_always_use_ssiv_to_decode", false)
fun fallbackForLongStrips() = preferenceStore.getBoolean("pref_fallback_for_long_strips", false)
}

View File

@ -345,6 +345,10 @@ object SettingsAdvancedScreen : SearchableSettings {
pref = basePreferences.alwaysUseSSIVToDecode(),
title = stringResource(MR.strings.pref_always_use_ssiv_to_decode),
),
Preference.PreferenceItem.SwitchPreference(
pref = basePreferences.fallbackForLongStrips(),
title = stringResource(MR.strings.pref_fallback_for_long_strips),
),
),
)
}

View File

@ -10,10 +10,13 @@ import coil3.decode.ImageSource
import coil3.fetch.SourceFetchResult
import coil3.request.Options
import coil3.request.bitmapConfig
import eu.kanade.domain.base.BasePreferences
import eu.kanade.tachiyomi.util.system.GLUtil
import okio.BufferedSource
import tachiyomi.core.common.util.system.ImageUtil
import tachiyomi.decoder.ImageDecoder
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
/**
* A [Decoder] that uses built-in [ImageDecoder] to decode images that is not supported by the system.
@ -27,6 +30,8 @@ class TachiyomiImageDecoder(private val resources: ImageSource, private val opti
check(decoder != null && decoder.width > 0 && decoder.height > 0) { "Failed to initialize decoder" }
val fallbackForLongStrips by lazy { Injekt.get<BasePreferences>().fallbackForLongStrips().get() }
val srcWidth = decoder.width
val srcHeight = decoder.height
@ -50,10 +55,14 @@ class TachiyomiImageDecoder(private val resources: ImageSource, private val opti
options.bitmapConfig == Bitmap.Config.HARDWARE &&
maxOf(bitmap.width, bitmap.height) <= GLUtil.maxTextureSize
) {
val hwBitmap = bitmap.copy(Bitmap.Config.HARDWARE, false)
if (hwBitmap != null) {
bitmap.recycle()
bitmap = hwBitmap
if (
!fallbackForLongStrips || bitmap.width < dstWidth && bitmap.height*1.1 <= GLUtil.maxTextureSize
) {
val hwBitmap = bitmap.copy(Bitmap.Config.HARDWARE, false)
if (hwBitmap != null) {
bitmap.recycle()
bitmap = hwBitmap
}
}
}

View File

@ -393,6 +393,7 @@
<string name="pref_show_reading_mode_summary">Briefly show current mode when reader is opened</string>
<string name="pref_display_profile">Custom display profile</string>
<string name="pref_always_use_ssiv_to_decode">Always use SSIV to decode long strip images</string>
<string name="pref_fallback_for_long_strips">Add safety checks to load vertical strips</string>
<string name="pref_crop_borders">Crop borders</string>
<string name="pref_custom_brightness">Custom brightness</string>
<string name="pref_grayscale">Grayscale</string>