Cómo obtener una imagen recortada de ImageView

Utilizo ImageView para recortar un mapa de bits. Una vez que se recorta quiero obtener esa imagen recortada, pero recibo lo mismo que el original. ¿Hay una manera de obtener sólo la parte visible de la imagen?

ImageView iv = new ImageView(this); iv.setImageBitmap(OriginalBitmap); iv.setScaleType(ScaleType.CENTER_CROP); Bitmap CroppedBitmap = ((BitmapDrawable) iv.getDrawable()).getBitmap(); 

El valor de CroppedBitmap es como el OriginalBitmap. ¿Cómo puedo obtener el recortado?

Este ejemplo funciona para mí iv.setDrawingCacheEnabled(true); Bitmap croppedBitmap = iv.getDrawingCache() iv.setDrawingCacheEnabled(true); Bitmap croppedBitmap = iv.getDrawingCache()

Este código siguiente para recortar la imagen 200×200

 Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.android); int width = bitmapOrg.width(); int height = bitmapOrg.height(); int newWidth = 200; int newHeight = 200; // calculate the scale - in this case = 0.4f float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // createa matrix for the manipulation Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(scaleWidth, scaleHeight); // recreate the new Bitmap Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0, width, height, matrix, true); // make a Drawable from Bitmap to allow to set the BitMap // to the ImageView, ImageButton or what ever BitmapDrawable bmd = new BitmapDrawable(resizedBitmap); iv.setImageDrawable(bmd); 
  • La imagen Captcha no se puede actualizar con Glide
  • Android: crear imagen circular con picasso
  • ¿Es posible obtener coordenadas en tiempo real de un ImageView mientras está en la animación de Translate?
  • Repita la imagen con ImageView en RelativeLayout
  • Cómo guardar la ruta de la imagen utilizando las preferencias compartidas
  • Recibo sólo pantalla en blanco mientras se utiliza svg-android
  • Android - Lienzo negro cuando se utiliza Flood-Fill
  • Cómo colocar una imagen en la parte superior de otra imagen en android
  • Máscara ImageView con fondo de esquina redonda
  • BaseAdapter y ContextMenu
  • Esquinas redondeadas para una vista de imagen en android
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.