You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a custom decoder for encrypted images. My Decoder decrypts the encrypted input stream and then decodes Images just like it is done in DefaultImageDecoder. I noticed that images fetched using this decoder are not saved in cache and is fetched from network every time. I would like to cache these images just like others
Reproduction
class MyImageDecoder(private val elementToDecrypt: ElementToDecrypt?) : ImageDecoder {
private val poolFactory: PoolFactory by inject(PoolFactory::class.java)
val defaultDecoder: DefaultImageDecoder by inject(DefaultImageDecoder::class.java)
override fun decode(
encodedImage: EncodedImage,
length: Int,
qualityInfo: QualityInfo,
options: ImageDecodeOptions
): CloseableImage {
var decryptedInputStream: InputStream? = null
var clearEncodedImage: EncodedImage? = null
try {
val inputStream = encodedImage.inputStream
decryptedInputStream = elementToDecrypt?.let {
DecryptStore.decryptStream(inputStream, elementToDecrypt)
} ?: inputStream
val bytes = poolFactory.pooledByteBufferFactory.newByteBuffer(decryptedInputStream)
val bytesClosable = CloseableReference.of(bytes)
clearEncodedImage = EncodedImage(bytesClosable)
var imageFormat = encodedImage.imageFormat
if (imageFormat == null || imageFormat === ImageFormat.UNKNOWN) {
imageFormat =
ImageFormatChecker.getImageFormat_WrapIOException(clearEncodedImage.inputStream)
encodedImage.imageFormat = imageFormat
}
when {
imageFormat === DefaultImageFormats.JPEG -> {
return defaultDecoder.decodeJpeg(clearEncodedImage, length, qualityInfo, options)
}
imageFormat === DefaultImageFormats.GIF -> {
return defaultDecoder.decodeGif(clearEncodedImage, length, qualityInfo, options)
}
imageFormat === DefaultImageFormats.WEBP_ANIMATED -> {
return defaultDecoder.decodeAnimatedWebp(clearEncodedImage, length, qualityInfo, options)
}
imageFormat === ImageFormat.UNKNOWN -> {
throw DecodeException("unknown image format", clearEncodedImage)
}
else -> {
throw DecodeException("unknown image format", clearEncodedImage)
}
}
} catch (ex: Exception) {
Timber.e("Something went wrong decoding the image")
throw ex
} finally {
decryptedInputStream?.close()
clearEncodedImage?.close()
}
}
}
Additional Information
Fresco version: 2.3.0
The text was updated successfully, but these errors were encountered:
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "bug" or "enhancement" and I will leave it open. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to reopen with up-to-date information.
#2501 # Description
I am using a custom decoder for encrypted images. My Decoder decrypts the encrypted input stream and then decodes Images just like it is done in
DefaultImageDecoder
. I noticed that images fetched using this decoder are not saved in cache and is fetched from network every time. I would like to cache these images just like othersReproduction
Additional Information
The text was updated successfully, but these errors were encountered: