From e70d506ab329f1f96b0ee132317aa36edea1b94e Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 8 Mar 2011 21:38:39 -0800 Subject: Fix 4027057: Improve resolution of RecentApps thumbnail images. This fix ensures captured thumbnails in portrait mode have the same resolution as those in landscape by fixing the horizontal resolution and vertical resolution of the target image. The returned image is now always the same size and matches the landscape screen exactly. In portrait mode, it grabs the upper portion of the screen based on the vertical dimension of the target image. Change-Id: I203c39843f2f21ca28f6ef0dffec308ce5cb39fb --- .../systemui/statusbar/tablet/RecentAppsPanel.java | 4 +--- .../android/server/wm/WindowManagerService.java | 28 +++++++++++----------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java index 737a52beab1f..c5a7df205382 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/RecentAppsPanel.java @@ -513,9 +513,7 @@ public class RecentAppsPanel extends RelativeLayout implements StatusBarPanel, O paint.setFilterBitmap(true); paint.setAlpha(255); final int srcWidth = thumbnail.getWidth(); - final int height = thumbnail.getHeight(); - final int srcHeight = srcWidth > height ? height - : (height - height * srcWidth / height); + final int srcHeight = thumbnail.getHeight(); canvas.drawBitmap(thumbnail, new Rect(0, 0, srcWidth-1, srcHeight-1), new RectF(GLOW_PADDING, diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index eed41a0c0e9a..ee5c1f0349f4 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -4727,7 +4727,15 @@ public class WindowManagerService extends IWindowManager.Stub SystemProperties.set(StrictMode.VISUAL_PROPERTY, value); } - public Bitmap screenshotApplications(IBinder appToken, int maxWidth, int maxHeight) { + /** + * Takes a snapshot of the screen. In landscape mode this grabs the whole screen. + * In portrait mode, it grabs the upper region of the screen based on the vertical dimension + * of the target image. + * + * @param width the width of the target bitmap + * @param height the height of the target bitmap + */ + public Bitmap screenshotApplications(IBinder appToken, int width, int height) { if (!checkCallingPermission(android.Manifest.permission.READ_FRAME_BUFFER, "screenshotApplications()")) { throw new SecurityException("Requires READ_FRAME_BUFFER permission"); @@ -4739,7 +4747,7 @@ public class WindowManagerService extends IWindowManager.Stub final Rect frame = new Rect(); float scale; - int sw, sh, dw, dh; + int dw, dh; int rot; synchronized(mWindowMap) { @@ -4803,7 +4811,7 @@ public class WindowManagerService extends IWindowManager.Stub // Constrain frame to the screen size. frame.intersect(0, 0, dw, dh); - + if (frame.isEmpty() || maxLayer == 0) { return null; } @@ -4814,15 +4822,7 @@ public class WindowManagerService extends IWindowManager.Stub int fh = frame.height(); // First try reducing to fit in x dimension. - scale = maxWidth/(float)fw; - sw = maxWidth; - sh = (int)(fh*scale); - if (sh > maxHeight) { - // y dimension became too long; constrain by that. - scale = maxHeight/(float)fh; - sw = (int)(fw*scale); - sh = maxHeight; - } + scale = width/(float)fw; // The screen shot will contain the entire screen. dw = (int)(dw*scale); @@ -4841,8 +4841,8 @@ public class WindowManagerService extends IWindowManager.Stub + ") to layer " + maxLayer); return null; } - - Bitmap bm = Bitmap.createBitmap(sw, sh, rawss.getConfig()); + + Bitmap bm = Bitmap.createBitmap(width, height, rawss.getConfig()); Matrix matrix = new Matrix(); ScreenRotationAnimation.createRotationMatrix(rot, dw, dh, matrix); matrix.postTranslate(-(int)(frame.left*scale), -(int)(frame.top*scale)); -- cgit v1.2.3-59-g8ed1b