마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

카메라 Camera 회전된 Bitmap crop 답변 부탁드립니다.

0 추천

 

회전된 bitmap 이미지를 crop 하려고 하는데 가지고 안들어가지네요.

소스에선 이미지 파일을 가지겨나는데 마지막인 비트맵을 어떻게 못가져가나요... 파일로 저장 안하구요.

 

private void performCrop(Uri picUri) {
	    try {

	        Intent cropIntent = new Intent("com.android.camera.action.CROP");
	        // indicate image type and Uri
	        cropIntent.setDataAndType(picUri, "image/*");
	        // set crop properties
	        cropIntent.putExtra("crop", "true");
	        // indicate aspect of desired crop
	        cropIntent.putExtra("aspectX", 1);
	        cropIntent.putExtra("aspectY", 1);
	        // indicate output X and Y
	        cropIntent.putExtra("outputX", 256);
	        cropIntent.putExtra("outputY", 256);
	        // retrieve data on return
	        cropIntent.putExtra("return-data", true);
	        // start the activity - we handle returning in onActivityResult
	        startActivityForResult(cropIntent, PIC_CROP);
	    }
	    // respond to users whose devices do not support the crop action
	    catch (ActivityNotFoundException anfe) {
	        // display an error message
	        String errorMessage = "Whoops - your device doesn't support the crop action!";
	        Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
	        toast.show();
	    }
	}

	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	    super.onActivityResult(requestCode, resultCode, data);

	    if (requestCode == PIC_CROP) {
	    	if(resultCode == RESULT_OK){
	    		Log.e("data : " , data.toString());
		        if (data != null) {
		            // get the returned data
		            Bundle extras = data.getExtras();
		            // get the cropped bitmap
		            Bitmap selectedBitmap = extras.getParcelable("data");
	
		            selectedBitmap = selectedBitmap.createScaledBitmap(bitmap, 450, 200, true);
			        resultImage.clearFocus();
		            resultImage.setImageBitmap(selectedBitmap);
		        }
	    	}else if(resultCode == RESULT_CANCELED){
	    		// 취소 시
	    	}else{
	    		return ;
	    	}
	    }

	}

 

익명사용자 님이 2015년 5월 15일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...