鉴于
ImageView image = R.findViewById(R.id.imageView);
image.setImageBitmap(someBitmap);
是否有可能检索位图?
鉴于
ImageView image = R.findViewById(R.id.imageView);
image.setImageBitmap(someBitmap);
是否有可能检索位图?
当前回答
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
其他回答
对于那些正在寻找Kotlin解决方案从ImageView获得位图的人。
var bitmap = (image.drawable as BitmapDrawable).bitmap
试试下面的代码:
Bitmap bitmap;
bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();
编写以下代码
ImageView yourImageView = (ImageView) findViewById(R.id.yourImageView);
Bitmap bitmap = ((BitmapDrawable)yourImageView.getDrawable()).getBitmap();
另一种获取图像位图的方法是这样做:
Bitmap imagenAndroid = BitmapFactory.decodeResource(getResources(),R.drawable.jellybean_statue);
imageView.setImageBitmap(imagenAndroid);
Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();