전화 파일에서 이미지를로드하려고합니다. 40킬로바이트 사진에 대한파일에서 이미지를로드하려고하는데 검은 색 원이 표시됩니다.
이결과, 275x269
하지만 더 큰 이미지를로드 할 때, 이런 일이 발생 :
파일이 작은 이미지 잘 때 간다2.63MB 그림 결과, 4160x2340
내 코드 - 파일 가져 오기 :
private void selectImage(){
Intent i = new Intent();
i.setType("image/*");
i.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(i, "Select File"), SELECT_FILE);
}
이미지 뷰의 배경으로 설정 이미지 :
07-20 17:32:57.949 3200-3200/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 265K, 6% free 5668K/5972K, paused 4ms, total 6ms
07-20 17:32:58.079 3200-3200/rafael.couto.newmoka I/dalvikvm-heap: Grow heap (frag case) to 42.701MB for 38937612-byte allocation
07-20 17:32:58.079 3200-3208/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 2K, 1% free 43691K/44000K, paused 5ms, total 5ms
07-20 17:32:59.599 3200-3200/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 2120K, 6% free 45599K/48036K, paused 4ms, total 4ms
07-20 17:33:00.889 3200-3200/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 2043K, 9% free 47650K/52132K, paused 4ms, total 4ms
07-20 17:33:00.899 3200-3200/rafael.couto.newmoka I/dalvikvm-heap: Grow heap (frag case) to 54.569MB for 8392804-byte allocation
07-20 17:33:00.909 3200-3208/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 0K, 8% free 55846K/60332K, paused 4ms, total 4ms
07-20 17:33:03.209 3200-3200/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 4094K, 15% free 51752K/60332K, paused 3ms, total 3ms
07-20 17:33:03.239 3200-3200/rafael.couto.newmoka I/dalvikvm-heap: Grow heap (frag case) to 66.586MB for 16793700-byte allocation
07-20 17:33:03.249 3200-3208/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 0K, 12% free 68152K/76736K, paused 8ms, total 8ms
07-20 17:33:03.589 3200-3200/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 8200K, 22% free 59952K/76736K, paused 2ms, total 2ms
07-20 17:33:03.589 3200-3200/rafael.couto.newmoka I/dalvikvm-heap: Grow heap (frag case) to 67.363MB for 9210496-byte allocation
07-20 17:33:03.599 3200-3208/rafael.couto.newmoka D/dalvikvm: GC_FOR_ALLOC freed 156K, 11% free 68790K/76736K, paused 7ms, total 7ms
가 무엇을거야 내가 무엇을해야합니까 :
public void onActivityResult(int resultCode, Intent data){
super.onActivityResult(resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if(data!=null) {
try {
photo = MediaStore.Images.Media
.getBitmap(getApplicationContext().getContentResolver(),
data.getData());
}catch(Exception e){
e.printStackTrace();
}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 100, baos);
imageView.setImageBitmap(photo);
}
}
}
안드로이드 모니터가 나를 보여줍니다 이것은 무엇?
무슨 일이 일어나고, 이미지가 너무 크고 메모리 문제로 인해로드되지 않습니다. 수행 할 작업,보기의 크기에 맞게 이미지의 크기를 조정하십시오. – petey
그렇게하는 가장 좋은 방법은 무엇입니까? –
이미지의 크기를 조정하면 안드로이드 태그에 대해 몇 번 묻습니다. – petey