MPF: mpf dependent image decoding in viewer
This commit is contained in:
parent
8c5cfc4a87
commit
ae5c2f795e
4 changed files with 9 additions and 4 deletions
|
@ -99,7 +99,7 @@ class ImageByteStreamHandler(private val context: Context, private val arguments
|
||||||
|
|
||||||
if (isVideo(mimeType)) {
|
if (isVideo(mimeType)) {
|
||||||
streamVideoByGlide(uri, mimeType, sizeBytes)
|
streamVideoByGlide(uri, mimeType, sizeBytes)
|
||||||
} else if (!canDecodeWithFlutter(mimeType, rotationDegrees, isFlipped)) {
|
} else if (!canDecodeWithFlutter(mimeType, pageId, rotationDegrees, isFlipped)) {
|
||||||
// decode exotic format on platform side, then encode it in portable format for Flutter
|
// decode exotic format on platform side, then encode it in portable format for Flutter
|
||||||
streamImageByGlide(uri, pageId, mimeType, sizeBytes, rotationDegrees, isFlipped)
|
streamImageByGlide(uri, pageId, mimeType, sizeBytes, rotationDegrees, isFlipped)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,6 +29,8 @@ class MultiPageImageGlideModule : LibraryGlideModule() {
|
||||||
}
|
}
|
||||||
|
|
||||||
class MultiPageImage(val context: Context, val uri: Uri, val mimeType: String, val pageId: Int?) {
|
class MultiPageImage(val context: Context, val uri: Uri, val mimeType: String, val pageId: Int?) {
|
||||||
|
override fun toString(): String = "MultiPageImage#${hashCode()}{uri=$uri, mimeType=$mimeType, pageId=$pageId}"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun isSupported(mimeType: String) = MimeTypes.isHeic(mimeType) || mimeType == MimeTypes.JPEG
|
fun isSupported(mimeType: String) = MimeTypes.isHeic(mimeType) || mimeType == MimeTypes.JPEG
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ class MpEntry(val flags: Int, val format: Int, val type: Int, val size: Long, va
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "MpEntry#${hashCode()}{flags=$flags, format=$format, type=$type, size=$size, dataOffset=$dataOffset, dep1=$dep1, dep2=$dep2}"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val FLAG_REPRESENTATIVE = 1 shl 2
|
const val FLAG_REPRESENTATIVE = 1 shl 2
|
||||||
const val FLAG_DEPENDENT_CHILD = 1 shl 3
|
const val FLAG_DEPENDENT_CHILD = 1 shl 3
|
||||||
|
|
|
@ -82,9 +82,10 @@ object MimeTypes {
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
||||||
// as of Flutter v1.22.0, with additional custom handling for SVG
|
// as of Flutter v3.16.4, with additional custom handling for SVG
|
||||||
fun canDecodeWithFlutter(mimeType: String, rotationDegrees: Int?, isFlipped: Boolean?) = when (mimeType) {
|
fun canDecodeWithFlutter(mimeType: String, pageId: Int?, rotationDegrees: Int?, isFlipped: Boolean?) = when (mimeType) {
|
||||||
JPEG, GIF, WEBP, BMP, WBMP, ICO, SVG -> true
|
GIF, WEBP, BMP, WBMP, ICO, SVG -> true
|
||||||
|
JPEG -> (pageId ?: 0) == 0
|
||||||
PNG -> (rotationDegrees ?: 0) == 0 && !(isFlipped ?: false)
|
PNG -> (rotationDegrees ?: 0) == 0 && !(isFlipped ?: false)
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue