개발환경 : 안드로이드 4.0.3
간단히 말씀드리면 어플에서 폰자체 내장카메라를 호출하여 사진을 찍은후 저장된 파일을 확인하는 겁니다 .
문제는 기존 삼성갤럭시S(안드2.3.6), 갤럭시노트(안드4.1.2) 에서는 저장된 파일이 선명하게 나오는데요.
SKY 베가(안드4.2.2) 에서는 저장된 파일이 흐릿하게 나옵니다.
삼성폰에서 저장된 파일해상도가 1280*720 이라면 SKY폰 경우 176*144 흐릿하게 나옵니다
대충 사진 처리 로직은 대충 아래와 같습니다 .
함 검토해 주시고 어떻게 해야 할지 SKY 폰만 저장사진이 흐릿하게 나옵니다.
꼭 좀 해결해 주십시요
1. camera.startPreview();
// 폰 최적 해상도값(넓이,높이) 을 가져온후 카메라 start
2. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height){
Camera.Parameters parameters=camera.getParameters();
List<Size> sizes = parameters.getSupportedPreviewSizes();//PI09
Size optimalSize = getOptimalPreviewSize(sizes, width,height);//높이,넓이 값 구해오기
parameters.setPreviewSize(optimalSize.width, optimalSize.height);//PI09
parameters.setPictureFormat(PixelFormat.JPEG);
camera.setParameters(parameters);
camera.startPreview();
}
3. //찍힌 사진정보를 jpg 변환 후 저장 함수
private Camera.PictureCallback photoCallback=new Camera.PictureCallback()
{
public void onPictureTaken(byte[] data, final Camera camera){
BitmapFactory.Options options = new BitmapFactory.Options();
Bitmap source = BitmapFactory.decodeByteArray(data,0,data.length);//디코딩
try {
OutputStream outputStream = null;
String directory ="/sdcard/DCIM/Camera";
String filename = "test.jpg";
File dir = new File(directory);
if (!dir.exists()) dir.mkdirs();
File file = new File(directory, filename);
outputStream = new FileOutputStream(file);
if (source != null){
source.compress(CompressFormat.JPEG, 30, outputStream);//변환
}
outputStream.close();
source.recycle();
byte[] buffer = new byte[(int)file.length()];
FileInputStream savedImage_stream = new FileInputStream(file);
int total = (int)file.length();
int offset = 0;
int read = 0;
while(offset < total ){
read = savedImage_stream.read(buffer, offset, total);
offset += read ;
total -= read;
}
String currentDate =
DateFormat.format("yyyy-MM-dd kk.mm.ss",System.currentTimeMillis()).toString();
PictureTable.InsertPicture(getApplication().getApplicationContext(), buffer , routecode,
checkingcode, currentDate );
Thread.sleep(1000);
file.delete();
btnTakePicture.setEnabled(true);
camera.startPreview();
}catch (Exception e) {
Log.e(TAG, "exception while writing image");
}
}
};