2012-03-18 4 views
1

여기 내 문제가 있습니다. 큰 비트 맵을 포함하는 이미지보기가 있습니다. 즉, 이미지보기는 비트 맵이 이미지보기보다 크기 때문에 이미지보기의 일부만 보여줍니다. x, y 좌표 (x와 y는 비트 맵 좌표)에서 이미지 뷰의 비트 맵을 가운데에 맞출 수 있기를 원합니다.이미지 뷰 내에서 비트 맵 이동

어떻게하면 될까요?

감사합니다, 롭

답변

0

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

지금 당신은 그것의 감소 할 수 있습니다 정확히 비트 맵 얼마나 큰에 따라 문서를 여기에서 볼

ImageView.ScaleType FIT_CENTER으로 시도 이 같은 것을 사용하여 크기 :

private Bitmap decodeFile(File f) { 
    Bitmap b = null; 
    try { 
     // Decode image size 
     BitmapFactory.Options o = new BitmapFactory.Options(); 
     o.inJustDecodeBounds = true; 

     FileInputStream fis = new FileInputStream(f); 
     BitmapFactory.decodeStream(fis, null, o); 
     fis.close(); 

     int scale = 1; 
     if (o.outHeight > 1024 || o.outWidth > 900) { 
      scale = (int) Math.pow(2, (int) Math.round(Math.log(1024/(double) Math.max(o.outHeight, o.outWidth))/Math.log(0.5))); 
     } 

     // Decode with inSampleSize 
     BitmapFactory.Options o2 = new BitmapFactory.Options(); 
     o2.inSampleSize = scale; 
     fis = new FileInputStream(f); 
     b = BitmapFactory.decodeStream(fis, null, o2); 
     fis.close(); 
    } catch (IOException e) { 
    } 
    return b; 
} 

크레딧 : How to scale bitmap to screen size?

+0

감사합니다. 그러나 문제는 내가 비트 맵을 이미지 뷰의 크기로 조정하는 것을 원하지 않는다는 것입니다. 좌표가 주어지면 이미지 뷰의 중심으로 옮기고 싶을뿐입니다. – rmonjo

관련 문제