1 / 7

Camera

Camera. 암시적 인텐트 (implicit intent) 사용 암시적 인텐트 : 수행할 액션과 요구되는 데이터로 activity 를 시작 “ 사진 찍기 or 이미지 가져오기 ” 버튼를 선택하는 경우 두 가지의 옵션이 가능 직접 해당 기능을 구현 각각 기능을 수행하는 외부 activity 에게 intent 를 보내서 수행결과를 받아옴 이중 후자를 선택하여 구현의 최소화를 꾀함 Intent 보내기 Intent intent = new Intent();

Télécharger la présentation

Camera

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Camera • 암시적 인텐트(implicit intent) 사용 • 암시적 인텐트 : 수행할 액션과 요구되는 데이터로 activity를 시작 • “사진 찍기 or 이미지 가져오기” 버튼를 선택하는 경우 두 가지의 옵션이 가능 • 직접 해당 기능을 구현 • 각각 기능을 수행하는 외부 activity에게 intent를 보내서 수행결과를 받아옴 • 이중 후자를 선택하여 구현의 최소화를 꾀함 • Intent 보내기 Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); // 해당 action을 제공하는 activity를 시작하도록 요구 intent.setType("image/*"); startActivityForResult(intent, USE_IMAGE_SELECTOR); // 액티비티를 호출한 후 결과값을 받기 위해서 사용

  2. Camera • 추가적인 내용을 지정하고 싶은 경우 putExtra를 사용 imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); • 결과 받기 : 호출당한 activity가 종료가 되면 OnActivityResult() method가 호출된다 void onActivityResult ( int requestCode, // startActivityForResult의 두번째 param int resultCode, // 정상종료의 경우 RESULT_OK Intent data) // 모든 결과를 담은 intent

  3. Camera issue 1 • 이슈1) 여러 activity로부터의 다른 결과값 • 암시적 인텐트의 경우 특정 action을 지원하는 여러 activity가 있을 수 있으며 이 경우 사용자는 어떤 것을 사용할지 선택할 수 있다.

  4. Camera issue 1 (cont.) • 카메라의 경우, 어느 activity를 택하느냐에 따라 data가 약간씩 다르게 전달되는 이슈가 있어 데이터가 전달될 수 있는 아래의 모든 경우를 고려한다 selPhotoUri = data.getData(); selectedPhotoBitmap = Images.Media.getBitmap(getContentResolver(), selPhotoUri); OR selectedPhotoBitmap = (Bitmap) data.getExtras().get("data");

  5. Camera issue 2 • 이슈2) 사진을 찍은 직후 넘겨지는 데이터 이상 • 안드로이드 버그(?)로 사진을 찍은 직후에 전달된 사진 데이터는 원본보다 훨씬 작게 전달된다 • 이는 단말 별로 다르게 보일 수 있다. 예) 옵티머스큐에서의 사이즈보다 넥서스원이나 갤럭시S에서의 이미지 사이즈가 더 작게 나옴 • 이를 보안하기 위하여 사진을 찍는 intent를 보낼 때 사진을 외부에 저장하도록 하는 옵션을 추가하였다. 이런 경우 리턴되는 데이터값은 좀 더 큰 사이즈가 되나, 원본 이미지보다는 여전히 조금은 작다.

  6. Camera issue 3 • 이슈3) 이미지 자동(?) rotation • 어떤 camera activity에서 받은 데이터는 이미지가 회전된 상태의 데이터가 넘겨진다. • 이는 activity마다 다른 현상이라 사용자가 직접 사진을 올리기 전 이미지를 rotation할 수 있는 기능을 추가하였다. Matrix matrix = new Matrix(); matrix.preRotate(90);// 90도 회전 try { Bitmap rotatedBitmap = Bitmap.createBitmap( imageViewBitmap, 0, 0, imageViewBitmap.getWidth(), imageViewBitmap.getHeight(), matrix, true); if (imageViewBitmap != rotatedBitmap) { imageView.setImageBitmap(rotatedBitmap); imageViewBitmap.recycle(); imageViewBitmap = rotatedBitmap; returntrue; }

More Related