How to get Bitmap from NetworkImageView

3k Views Asked by At

I want Bitmap from networkimageview. here is my code and

    String url="https://graph.facebook.com/"+u_id+"/picture";
    mNetworkImageView = (NetworkImageView) findViewById(R.id.networkImageView);
    mImageLoader = MySingletonClass.getInstance(this).getImageLoader();
    mNetworkImageView.setImageUrl(url, mImageLoader);

After this I want bitmap from networkimageview. how to get it?

2

There are 2 best solutions below

2
On
        mImageLoader.get(url, new ImageLoader.ImageListener() {

        public void onErrorResponse(VolleyError arg0) {
           // image.setImageResource(R.drawable.icon_error); // set an error image if the download fails
        }

        public void onResponse(ImageContainer response, boolean arg1) {
            if (response.getBitmap() != null) {
                mNetworkImageView.setImageBitmap(CircleImage.getRoundedRectBitmap(response.getBitmap(), 100));
            } //else
               // image.setImageResource(R.drawable.icon_loading); // set the loading image while the download is in progress
        }
    });
4
On

Try this:

Bitmap bitmap = ((BitmapDrawable) mNetworkImageView.getDrawable()).getBitmap();

EDIT:

I check the Volley code and found that they are using a tag to store info about the image, so, try this:

ImageContainer container = (ImageContainer) mNetworkImageView.getTag();
final Bitmap bitmap = container.getBitmap();
if (bitmap != null) {
    //other code to processing bitmap
}