fix: images.detectsColor() and images.pixel() cause "x > image.width" exception when image is landscape
This commit is contained in:
@@ -18,7 +18,7 @@ public class ScreenMetrics {
|
||||
private static Display display;
|
||||
|
||||
public static void initIfNeeded(Activity activity) {
|
||||
if(initialized)
|
||||
if (initialized)
|
||||
return;
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
|
||||
@@ -86,17 +86,11 @@ public class ScreenMetrics {
|
||||
}
|
||||
|
||||
public int scaleX(int x) {
|
||||
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||
return scaleX(x, mDesignWidth);
|
||||
else
|
||||
return scaleY(x, mDesignWidth);
|
||||
return scaleX(x, mDesignWidth);
|
||||
}
|
||||
|
||||
public int scaleY(int y) {
|
||||
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||
return scaleY(y, mDesignHeight);
|
||||
else
|
||||
return scaleX(y, mDesignHeight);
|
||||
return scaleY(y, mDesignHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,17 +100,11 @@ public class ScreenMetrics {
|
||||
}
|
||||
|
||||
public int rescaleX(int x) {
|
||||
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||
return rescaleX(x, mDesignWidth);
|
||||
else
|
||||
return rescaleY(x, mDesignWidth);
|
||||
return rescaleX(x, mDesignWidth);
|
||||
}
|
||||
|
||||
|
||||
public int rescaleY(int y) {
|
||||
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||
return rescaleY(y, mDesignHeight);
|
||||
else
|
||||
return rescaleX(y, mDesignHeight);
|
||||
return rescaleY(y, mDesignHeight);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user