1
사진을 찍어 편집해야합니다. 원본 카메라를 사용하여 큰 크기의 이미지를 반환하므로 편집 할 새 템플릿 이미지를 만들 때 outOfMemoryError 때문에 응용 프로그램이 닫힙니다. 내 응용 프로그램에 이미지를로드하기 전에 이미지의 크기를 조절할 수있는 방법이 있습니까? 카메라카메라로 사진 찍고 편집하십시오
내 코드 걸릴 이미지 :
void loadImageFromCamera(){
Intent takePicture = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = null;
try{
// place where to store camera taken picture
photo = this.createTemporaryFile("picture", ".jpg");
photo.delete();
} catch(Exception e){
}
mImageUri = Uri.fromFile(photo);
takePicture.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
startActivityForResult(takePicture, 0);
}
private File createTemporaryFile(String part, String ext) throws Exception{
File tempDir = Environment.getExternalStorageDirectory();
tempDir = new File(tempDir.getAbsolutePath() + "/.temp/");
if(!tempDir.exists()){
tempDir.mkdir();
}
return File.createTempFile(part, ext, tempDir);
}
public void grabImage(){
this.getContentResolver().notifyChange(mImageUri, null);
ContentResolver cr = this.getContentResolver();
try {
originImage = android.provider.MediaStore.Images.Media.getBitmap(cr, mImageUri);
}catch (Exception e){
}
}
때문에 이미지를 크기를 조정하려면 이미지 사용에게 다음과 같은 방법으로 크기를 조정할 수 있습니다 outOfMemoryError. \ n 코드를 추가하려고하지만 작동하지 않습니다 : |. 내 응용 프로그램에로드되기 전에 크기가 조정되어야합니다. – Sunary
예 응용 프로그램로드 후 이미지의 크기가 조정됩니다. –
고마워요.하지만로드하기 전에 크기를 조정해야합니다. 그것을로드하기 전에 어쨌든 이미지 크기를 조정할 수 있습니까? – Sunary