본문 바로가기

Android

Bitmap 비율 대로 이미지 크기 조정하기

  1. private Rect screenSize = new Rect(0000);  
  2.   
  3. bitmapSize = new Rect(00, player.getBitmapWidth(), player.getBitmapHeight());  
  4. float h = player.getBitmapHeight();  
  5. int oldY = screenSize.bottom;  
  6.   
  7. if (player.getBitmap() == null) {  
  8.     Log.e(TAG, "null bitmap");  
  9.     sendMessage(ON_ERROR, null);  
  10.     return ;  
  11. }  
  12.   
  13. int newY = (int)(h * getRatioScale(player.getBitmap(), surfaceWidth));  
  14. int gap = (oldY - newY) / 2;  
  15.   
  16. screenSize.top    += gap;  
  17. screenSize.bottom -= gap;