我已經創建了應用程序,從Facebook加載圖片。我使用畢加索。畢加索將設置圖像結果到我的Imageview。我想要將該圖像轉換爲位圖。如何從imageview中獲取drawable並將其轉換爲位圖?
這裏是我的代碼來從Facebook獲得的圖像:
URL imageURL = new URL("https://graph.facebook.com/"+id+"/picture?type=large");
Picasso.with(getBaseContext()).load(imageURL.toString()).into(ImageView);
這裏是我的代碼來獲取圖像,並轉換爲位圖:(不行)
BitmapDrawable drawable = (BitmapDrawable) ImageView.getDrawable();
Bitmap bitmap = drawable.getBitmap();
bitmap = Bitmap.createScaledBitmap(bitmap, 70, 70, true);
ImageViewTest.setImageBitmap(bitmap);
ImageView.getDrawable()
總是返回null。
我需要你的幫助。 謝謝
爲什麼不能有畢加索只是給你的位圖,當你找回? – CommonsWare
但我看到它的參數是imageview。你的想法是將imageview轉換爲位圖? –
畢加索可以做多種選擇。請參閱[此答案](https://stackoverflow.com/a/46082179/115145)和[此答案](https://stackoverflow.com/a/46081082/115145)。 – CommonsWare