Skip to content

Commit 2f12172

Browse files
committed
fix(image): imageRotation scaling fix
1 parent e2ed015 commit 2f12172

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/image/platforms/android/java/com/nativescript/image/ScalingUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,18 @@ public Matrix getTransform(
144144
float focusY) {
145145
float sX = (float) parentRect.width() / (float) childWidth;
146146
float sY = (float) parentRect.height() / (float) childHeight;
147-
float rotationDelta = _imageRotation % 180;
148-
if (rotationDelta != 0) {
147+
float rotationDelta = (90 - (_imageRotation % 180))/90.0f;
148+
if (rotationDelta != 1) {
149149
float destSX = (float) parentRect.width() / (float) childHeight;
150150
float destSY = (float) parentRect.height() / (float) childWidth;
151-
final float pos = Math.abs(rotationDelta)/90.0f;
152-
sX = sX + pos * (destSX - sX);
153-
sY = sY + pos * (destSY - sY);
151+
if (rotationDelta < 0) {
152+
sX = destSX + rotationDelta * (destSX - sX);
153+
sY = destSY + rotationDelta * (destSY - sY);
154+
} else {
155+
sX = sX + (1 - rotationDelta) * (destSX - sX);
156+
sY = sY + (1 - rotationDelta) * (destSY - sY);
157+
}
158+
154159
}
155160
getTransformImpl(outTransform, parentRect, childWidth, childHeight, focusX, focusY, sX, sY);
156161
if (_imageMatrix != null) {

0 commit comments

Comments
 (0)