Skip to content

Instantly share code, notes, and snippets.

@CMingTseng
Created October 21, 2016 14:08
Show Gist options
  • Save CMingTseng/5b44033cc605b8297624d32b2f3cdfa2 to your computer and use it in GitHub Desktop.
Save CMingTseng/5b44033cc605b8297624d32b2f3cdfa2 to your computer and use it in GitHub Desktop.
//http://stackoverflow.com/questions/32949914/try-to-fetch-bitmap-from-uri-using-fresco
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(mImageCaptureUri)
.setAutoRotateEnabled(true)
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
final DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
dataSource.subscribe(new BaseBitmapDataSubscriber() {
@Override
public void onNewResultImpl(@Nullable Bitmap bitmap) {
if (dataSource.isFinished() && bitmap != null){
Log.d("Bitmap","has come");
bmp = Bitmap.createBitmap(bitmap);
dataSource.close();
}
}
@Override
public void onFailureImpl(DataSource dataSource) {
if (dataSource != null) {
dataSource.close();
}
}
}, CallerThreadExecutor.getInstance());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment