mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-06 02:37:26 +01:00
Merge 991f6b1908
into 3cfc2be104
This commit is contained in:
commit
56b35d28bc
@ -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)
|
||||
}
|
||||
|
@ -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),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user