minor fix

This commit is contained in:
Thibault Deckers 2022-11-06 12:31:13 +01:00
parent a4c6a82b4f
commit e8b46b02d8

View file

@ -19,12 +19,13 @@ class TiffRegionFetcher internal constructor(
result: MethodChannel.Result,
) {
try {
@Suppress("BlockingMethodInNonBlockingContext")
val fd = context.contentResolver.openFileDescriptor(uri, "r")?.detachFd()
if (fd == null) {
val pfd = context.contentResolver.openFileDescriptor(uri, "r")
if (pfd == null) {
result.error("getRegion-tiff-fd", "failed to get file descriptor for uri=$uri", null)
return
}
pfd.use {
val fd = pfd.detachFd()
val options = TiffBitmapFactory.Options().apply {
inDirectoryNumber = page
inSampleSize = sampleSize
@ -36,6 +37,7 @@ class TiffRegionFetcher internal constructor(
} else {
result.error("getRegion-tiff-null", "failed to decode region for uri=$uri page=$page regionRect=$regionRect", null)
}
}
} catch (e: Exception) {
result.error("getRegion-tiff-read-exception", "failed to read from uri=$uri page=$page regionRect=$regionRect", e.message)
}