Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. Matrix matrix = new Matrix();
  2. matrix.setRotate(90f);
  3. Bitmap bitmap = Bitmap.createBitmap(mCacheBitmap, 0, 0, mCacheBitmap.getWidth(), mCacheBitmap.getHeight(), matrix, true);
  4.  
  5. if (mScale != 0) {
  6. canvas.drawBitmap(bitmap, new Rect(0,0,bitmap.getWidth(), bitmap.getHeight()),
  7. new Rect((int)((canvas.getWidth() - mScale*bitmap.getWidth()) / 2),
  8. (int)((canvas.getHeight() - mScale*bitmap.getHeight()) / 2),
  9. (int)((canvas.getWidth() - mScale*bitmap.getWidth()) / 2 + mScale*bitmap.getWidth()),
  10. (int)((canvas.getHeight() - mScale*bitmap.getHeight()) / 2 + mScale*bitmap.getHeight())), null);
  11. } else {
  12. canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
  13. new Rect((canvas.getWidth() - bitmap.getWidth()) / 2,
  14. (canvas.getHeight() - bitmap.getHeight()) / 2,
  15. (canvas.getWidth() - bitmap.getWidth()) / 2 + bitmap.getWidth(),
  16. (canvas.getHeight() - bitmap.getHeight()) / 2 + bitmap.getHeight()), null);
  17.  
  18. if ((getLayoutParams().width == ActionBar.LayoutParams.MATCH_PARENT) && (getLayoutParams().height == ActionBar.LayoutParams.MATCH_PARENT))
  19. mScale = Math.min(((float)height)/mFrameWidth, ((float)width)/mFrameHeight);
  20. else
  21. mScale = 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement