'Android'에 해당되는 글 2건

카테고리 없음

일반 안드로이드에 내장된 프로그램으로 Intent 호출하여 찍는다면 orientation 정보가 추가되어있어 그것만 보고 돌리면 된다만
surface로 직접 만들어 찍으면 정보가 없다. 그럴땐 저장할 때 돌려주자 아래 처럼 2.2 이상에서 잘된다. 그 이하는 책임 못짐


PictureCallback jpegCallback = new PictureCallback() {
  
public void onPictureTaken(byte[] data, Camera camera) {
     
FileOutputStream outStream = null;
     
try {
        imageFilePath
= getFilename();
       
InputStream is = new ByteArrayInputStream(data);
       
Bitmap bmp = BitmapFactory.decodeStream(is);
       
// Getting width & height of the given image.
       
if (bmp != null){
          
int w = bmp.getWidth();
          
int h = bmp.getHeight();
          
// Setting post rotate to 90
          
Matrix mtx = new Matrix();
           mtx
.postRotate(90);
          
// Rotating Bitmap
          
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
          
ByteArrayOutputStream stream = new ByteArrayOutputStream();
           rotatedBMP
.compress(Bitmap.CompressFormat.PNG, 100, stream);
          
byte[] byteArray = stream.toByteArray();
           outStream
= new FileOutputStream
                             
(String.format(imageFilePath,System.currentTimeMillis()));
           outStream
.write(byteArray);
           outStream
.close();
       
} else {
           outStream
= new FileOutputStream
                             
(String.format(imageFilePath,System.currentTimeMillis()));
           outStream
.write(data);
           outStream
.close();          
       
}      

        preview
.camera.startPreview();
   
} catch (FileNotFoundException e) {
        e
.printStackTrace();
   
} catch (IOException e) {
        e
.printStackTrace();
   
} finally {
   
}
 
}
};
카테고리 없음
1
블로그 이미지

개발자

우와신난다