use of com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder in project Signal-Android by WhisperSystems.
the class AttachmentBitmapDecoder method decode.
@Override
public Bitmap decode(Context context, Uri uri) throws Exception {
if (!PartAuthority.isLocalUri(uri)) {
return new SkiaImageDecoder().decode(context, uri);
}
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
if (masterSecret == null) {
throw new IllegalStateException("Can't decode without secret");
}
InputStream inputStream = PartAuthority.getAttachmentStream(context, masterSecret, uri);
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeStream(inputStream, null, options);
if (bitmap == null) {
throw new RuntimeException("Skia image region decoder returned null bitmap - image format may not be supported");
}
return bitmap;
} finally {
if (inputStream != null)
inputStream.close();
}
}
Aggregations