user3606902
user3606902

Reputation: 819

How to get Bitmap from NetworkImageView

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?

Upvotes: 0

Views: 3085

Answers (2)

user3606902
user3606902

Reputation: 819

        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
        }
    });

Upvotes: 6

romtsn
romtsn

Reputation: 12002

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
}

Upvotes: 3

Related Questions