Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CMScreenshot: Fix for screen rotation

Fix for devices with 90 or 270 degree screen rotation. I even tested it this time.

Change-Id: Ib209152dc436feaad8443e88eaf780fe267e6d46
  • Loading branch information...
commit 1ed9c018394d176e4fe0bc097e4f9cd817bcb372 1 parent 08e96c9
@TomGiordano TomGiordano authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 src/com/cyanogenmod/screenshot/ScreenshotActivity.java
View
12 src/com/cyanogenmod/screenshot/ScreenshotActivity.java
@@ -74,7 +74,7 @@ void takeScreenshot()
try
{
Process p = Runtime.getRuntime().exec("/system/bin/screenshot");
- Log.d("Screenshot","Ran helper");
+ Log.d("CMScreenshot","Ran helper");
p.waitFor();
InputStream rawFile = new FileInputStream(mRawScreenshot);
mBitmap = BitmapFactory.decodeStream(rawFile);
@@ -83,20 +83,16 @@ void takeScreenshot()
tmpshot.delete();
// valid values for ro.sf.hwrotation are 0, 90, 180 & 270
- int rot = SystemProperties.getInt("ro.sf.hwrotation",0);
+ int rot = 360-SystemProperties.getInt("ro.sf.hwrotation",0);
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
// First round, natural device rotation
- if(rot > 0){
+ if(rot > 0 && rot < 360){
Log.d("CMScreenshot","rotation="+rot);
Matrix matrix = new Matrix();
matrix.postRotate(rot);
- // if rot = 90 or 270 swap height and width
- if(rot==90 || rot==270)
- mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getHeight(), mBitmap.getWidth(), matrix, true);
- else
- mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true);
+ mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true);
}
// Second round, device orientation:
Please sign in to comment.
Something went wrong with that request. Please try again.