2012-01-31 3 views
1

640x480 픽셀로 사진을 찍으려면 카메라 해상도를 고정하고 싶습니다.안드로이드 - 640 x 480의 카메라 해상도 고정 방법

640x480보다 큰 사진은 천천히 전제가되고 때로는 내 응용 프로그램이 다운 될 수도 있습니다.
이 작업을 수행 할 수없는 경우 SD 카드에서 사진의 크기를 조정할 수있는 방법이 있습니까?

답변

3

here (commonsguy GitHub의)에서 촬영

. 이 같은 코드에서 뭔가 :

Bitmap smallBitmap = Bitmap.createScaledBitmap(sourceBitmap, 640, 480, true); 

및 크기 조정 후 경우

당신이 사용할 수있는 저장하는 비트 맵 바이트 배열을 공급하지합니다 .. 코드 당신이 이미 저장하기 위해 쓴 것 같아요으로 저장 :

ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
bMap.compress(CompressFormat.JPEG, 100, bos); // setup jpeg quality here 
byte[] data = bos.toByteArray(); 

희망이 있습니다. 환호

0

당신은

private Camera.Size getBestPreviewSize(int width, int height,Camera.Parameters parameters) 
{ 
    Camera.Size result=null; 

    for (Camera.Size size : parameters.getSupportedPreviewSizes()) { 
     if (size.width <= width && size.height <= height) { 
     if (result == null) { 
      result=size; 
     } 
     else { 
      int resultArea=result.width * result.height; 
      int newArea=size.width * size.height; 

      if (newArea > resultArea) { 
      result=size; 
      } 
     } 
     } 
    } 

    return(result); 
    } 

가능한 최저 해상도를 얻을 수 또는 당신이 원하는 해상도로 루프를 중지 시도 할 수 있습니다. 당신은 심지어 SD 카드에 저장하기 전에 사진 크기를 조정할 수

관련 문제