Getting Image from ImageView

后端 未结 3 518
萌比男神i
萌比男神i 2020-12-08 20:03

I have a gallery that shows an array of images, when clicked they are displayed in an imageview. I want to be able to SHARE the image that is currently being displayed in an

3条回答
  •  庸人自扰
    2020-12-08 20:30

    My Best Function

    public class MainActivity extends Activity {
    
        private ImageView imgView,bitmap;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            imgView=(ImageView) findViewById(R.id.imgView);
            bitmap=(ImageView) findViewById(R.id.bitmap);
    
            //set view to bitmap image
            bitmap.setImageBitmap(convertImageViewToBitmap(imgView));
        }
    
        //function to convert imageView to Bitmap
    
        private Bitmap convertImageViewToBitmap(ImageView v){
    
            Bitmap bm=((BitmapDrawable)v.getDrawable()).getBitmap();
    
            return bm;
        }
    
    }
    

提交回复
热议问题