Commit 586e388c by german callejas

Cropper fixed

parent ec3773c9
......@@ -264,49 +264,22 @@ public class CropImageView extends android.support.v7.widget.AppCompatImageView
final float transX = matrixValues[Matrix.MTRANS_X];
final float transY = matrixValues[Matrix.MTRANS_Y];
final float bitmapLeft = (transX < 0) ? Math.abs(transX) : 0;
final float bitmapTop = (transY < 0) ? Math.abs(transY) : 0;
final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap();
/*Log.i("DETALLES","ScaleX: "+scaleX + "- ScaleY: "+scaleY);
Log.i("DETALLES","transX: "+transX + "- transY: "+transY);
Log.i("DETALLES","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate());
Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
final float cropWidth = Edge.getWidth();
final float cropHeight = Edge.getHeight();*/
/*Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/
// Ensure that the left and top edges are not outside of the ImageView bounds.
/*final float bitmapLeft = (transX < 0) ? Math.abs(transX) : 0;
final float bitmapTop = (transY < 0) ? Math.abs(transY) : 0;*/
// Get the original bitmap object.
//final Bitmap originalBitmap = ((BitmapDrawable) drawable).getBitmap();
/*final float bitmapLeft = ((findViewById(R.id.ScrollView)).getWidth() - originalBitmap.getWidth())/2;
final float bitmapTop = ((findViewById(R.id.ScrollView)).getHeight() - originalBitmap.getHeight())/2;*/
/* Log.i("DETALLES","bitmapLeft: "+bitmapLeft + "- bitmapTop: "+bitmapTop);
// Calculate the top-left corner of the crop window relative to the ~original~ bitmap size.
final float cropX = (bitmapLeft + Edge.LEFT.getCoordinate());
final float cropY = (bitmapTop + Edge.TOP.getCoordinate());
Log.i("DETALLES","Edge Left: "+Edge.LEFT.getCoordinate() + "- Edge Top: "+Edge.TOP.getCoordinate());
Log.i("DETALLES","Posicion X: "+cropX + "- Posicion Y: "+cropY);*/
// Calculate the crop window size relative to the ~original~ bitmap size.
// Make sure the right and bottom edges are not outside the ImageView bounds (this is just to address rounding discrepancies).
/*final float cropWidth = Edge.getWidth();
final float cropHeight = Edge.getHeight();
Log.i("DETALLES","ancho original: "+originalBitmap.getWidth() + " Alto original: "+originalBitmap.getHeight());
Log.i("DETALLES","ancho: "+cropWidth + " Alto: "+cropHeight);*/
// Crop the subset from the original Bitmap.
return Bitmap.createBitmap(originalBitmap,
(int) (Edge.LEFT.getCoordinate() - transX),
(int) (Edge.TOP.getCoordinate() - transY),
(int) Edge.getWidth(),
(int) Edge.getHeight());
final float cropX = (bitmapLeft + Edge.LEFT.getCoordinate()) / scaleX;
final float cropY = (bitmapTop + Edge.TOP.getCoordinate()) / scaleY;
final float cropWidth = Math.min(Edge.getWidth() / scaleX, originalBitmap.getWidth() - cropX);
final float cropHeight = Math.min(Edge.getHeight() / scaleY, originalBitmap.getHeight() - cropY);
return Bitmap.createBitmap(originalBitmap,
(int) cropX,
(int) cropY,
(int) cropWidth,
(int) cropHeight);
}
// Private Methods /////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment