--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -454,7 +454,8 @@ public class ImageWallpaper extends WallpaperService {
// Center the scaled image
mScale = Math.max(1f, Math.max(dw / (float) mBackground.getWidth(),
dh / (float) mBackground.getHeight()));
- mScale = dw / (float) mBackground.getWidth();
+ //mScale = dw / (float) mBackground.getWidth();
final int availw = dw - (int) (mBackground.getWidth() * mScale);
final int availh = dh - (int) (mBackground.getHeight() * mScale);
int xPixels = availw / 2;
@@ -463,13 +464,16 @@ public class ImageWallpaper extends WallpaperService {
// Adjust the image for xOffset/yOffset values. If window manager is handling offsets,
// mXOffset and mYOffset are set to 0.5f by default and therefore xPixels and yPixels
// will remain unchanged
- final int availwUnscaled = (int)((float)dw/mScale) - mBackground.getWidth();
- final int availhUnscaled = (int)((float)dh/mScale) - mBackground.getHeight();
-
+ final int availwUnscaled = dw - mBackground.getWidth();
+ final int availhUnscaled = dh - mBackground.getHeight();
+ //End
if (availwUnscaled < 0)
- xPixels += (int) (availwUnscaled * (mXOffset - .5f) * mScale + .5f);
+ xPixels += (int) (availwUnscaled * (mXOffset - .5f) + .5f);
if (availhUnscaled < 0)
- yPixels += (int) (availhUnscaled * (mYOffset - .5f) * mScale + .5f);
+ yPixels += (int) (availhUnscaled * (mYOffset - .5f) + .5f);
mOffsetsChanged = false;
if (surfaceDimensionsChanged) {
Android N 固定壁纸大小不拉伸
最新推荐文章于 2024-06-28 03:05:52 发布