mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-10 21:25:30 -04:00
Opt[bitmap_pan]: change pan behaviour to be more efficient
Also: fix typos
This commit is contained in:
parent
e581699961
commit
1fd64e0a3a
@ -21,13 +21,13 @@ public class BitmapCropBehaviour implements CropperBehaviour{
|
||||
public void pan(float panX, float panY) {
|
||||
if(mHostView.horizontalLock) panX = 0;
|
||||
if(mHostView.verticalLock) panY = 0;
|
||||
mTranslateMatrix.postTranslate(panX, panY);
|
||||
if(panX != 0 || panY != 0) {
|
||||
// Only mark the matrix as outdated if any amount of panning has occured
|
||||
// Actually translate and refresh only if either of the pan deltas are nonzero
|
||||
mTranslateMatrix.postTranslate(panX, panY);
|
||||
mTranslateInverseOutdated = true;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public void zoom(float zoomLevel, float midpointX, float midpointY) {
|
||||
// Do this to avoid constantly inverting the same matrix on each touch event.
|
||||
@ -83,7 +83,7 @@ public class BitmapCropBehaviour implements CropperBehaviour{
|
||||
Matrix imageInverse = new Matrix();
|
||||
inverse(mImageMatrix, imageInverse);
|
||||
// By inverting the matrix we will effectively "divide" our rectangle by it, thus getting
|
||||
// its two points on the bitmap's surface. Math be cool indeed.
|
||||
// its two points on the surface of the bitmap. Math be cool indeed.
|
||||
float[] src = new float[] {
|
||||
mHostView.mSelectionRect.left,
|
||||
mHostView.mSelectionRect.top,
|
||||
|
@ -139,8 +139,8 @@ public class CropperView extends View {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
protected void onSizeChanged(int w, int h, int oldW, int oldH) {
|
||||
super.onSizeChanged(w, h, oldW, oldH);
|
||||
int lesserDimension = (int)(Math.min(w, h) - mSelectionPadding);
|
||||
// Calculate the corners of the new selection frame. It should always appear at the center of the view.
|
||||
int centerShiftX = (w - lesserDimension) / 2;
|
||||
|
@ -38,7 +38,7 @@ public class RegionDecoderCropBehaviour extends BitmapCropBehaviour {
|
||||
};
|
||||
|
||||
/**
|
||||
* Decoade a region from this Bitmap based on a subsection in the View coordinate space.
|
||||
* Decode a region from this Bitmap based on a subsection in the View coordinate space.
|
||||
* @param targetDrawRect an output Rect. This Rect is the position at which the region must
|
||||
* be rendered within subsectionRect.
|
||||
* @param subsectionRect the subsection in View coordinate space. Note that this Rect is modified
|
||||
@ -46,7 +46,7 @@ public class RegionDecoderCropBehaviour extends BitmapCropBehaviour {
|
||||
* @return null if the resulting region is bigger than the original image
|
||||
* null if the resulting region is completely out of the original image bounds
|
||||
* null if the resulting region is smaller than 16x16 pixels
|
||||
* null if a region decoding error has occured
|
||||
* null if a region decoding error has occurred
|
||||
* the resulting Bitmap region otherwise.
|
||||
*/
|
||||
private Bitmap decodeRegionBitmap(RectF targetDrawRect, RectF subsectionRect) {
|
||||
@ -189,7 +189,7 @@ public class RegionDecoderCropBehaviour extends BitmapCropBehaviour {
|
||||
|
||||
/**
|
||||
* Transform the coordinates of the Rect using the supplied Matrix.
|
||||
* @param rect the input/ouput Rect for this operation
|
||||
* @param rect the input/output Rect for this operation
|
||||
* @param regionImageInverse the Matrix for transforming the Rect.
|
||||
*/
|
||||
private void transformRect(RectF rect, Matrix regionImageInverse) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user