Skip to content

Commit

Permalink
Make BlurView honour changes to scaleX/scaleY
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsekov committed Jun 6, 2023
1 parent 676ecab commit 34ae140
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ private void setupInternalCanvasMatrix() {

int left = blurViewLocation[0] - rootLocation[0];
int top = blurViewLocation[1] - rootLocation[1];
float scaleX = rootView.getScaleX();
float scaleY = rootView.getScaleY();

// https://github.com/Dimezis/BlurView/issues/128
float scaleFactorH = (float) blurView.getHeight() / internalBitmap.getHeight();
float scaleFactorW = (float) blurView.getWidth() / internalBitmap.getWidth();
float scaleFactorH = (float) (blurView.getHeight() * scaleY) / internalBitmap.getHeight();
float scaleFactorW = (float) (blurView.getWidth() * scaleX) / internalBitmap.getWidth();

float scaledLeftPosition = -left / scaleFactorW;
float scaledTopPosition = -top / scaleFactorH;

internalCanvas.translate(scaledLeftPosition, scaledTopPosition);
internalCanvas.scale(1 / scaleFactorW, 1 / scaleFactorH);
internalCanvas.scale(scaleX / scaleFactorW, scaleY / scaleFactorH);
}

@Override
Expand Down

0 comments on commit 34ae140

Please sign in to comment.