2011-07-20 68 views
1

我遇到图片问题;拍完照片后,它会自动旋转90度。我如何删除它?我需要一张人像照片。如何删除自动图片旋转?

public void surfaceCreated(SurfaceHolder holder) 
{ 



try 
{ 

    camera.setPreviewCallback(this); 
     camera.setPreviewDisplay(holder); 
     Camera.Parameters p = camera.getParameters(); 
     p.setPictureSize(1024, 768); 
     p.setPictureFormat (PixelFormat.RGB_565); 
     camera.setParameters(p); 


     } 


catch (IOException e) 
{ 
    e.printStackTrace(); 
} 





if (this.getResources().getConfiguration().orientation != Configuration.UI_MODE_TYPE_CAR) 
{ 

    camera.setDisplayOrientation(90); 

} 
else 
{ 

    camera.setDisplayOrientation(0); 

} 

preview.setLayoutParams(lp); 
camera.startPreview(); 
} 

    public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) 
    { 


FileOutputStream fileOutputStream = null; 

try { 

File saveDir = new File("/sdcard/CameraExample/"); 

if (!saveDir.exists()) 
{ 
saveDir.mkdirs(); 
} 

BitmapFactory.Options options = new BitmapFactory.Options(); 



Bitmap myImage = BitmapFactory.decodeByteArray(paramArrayOfByte, 0,paramArrayOfByte.length, options); 

Bitmap bmpResult = Bitmap.createBitmap(myImage.getWidth(), myImage.getHeight(),Config.RGB_565); 




Paint paint = new Paint();   

Canvas myCanvas = new Canvas(bmpResult); 

myCanvas.drawBitmap(myImage, 0, 0, paint); 




    fileOutputStream = new FileOutputStream("/sdcard/CameraExample/"+ sdf.format(new  Date())+".bmp"); 

BufferedOutputStream bos = newBufferedOutputStream(fileOutputStream); 


bmpResult.compress(CompressFormat.PNG, 100, bos); 

bos.flush(); 
bos.close(); 
+0

显示的代码。 – jamapag

+0

编辑,但在我看来不是问题。 – Domos

回答

0

尝试是这样的:在您创建图像

if (this.getResources().getConfiguration().orientation != Configuration.UI_MODE_TYPE_CAR) 
{ 

    Matrix mat = new Matrix(); 
    mat.preRotate(90); 
    Bitmap rotated = Bitmap.createBitmap(bmpResult, 0, 0, 
        myImage.getWidth(), myImage.getHeight(), mat, true); 

} 
+0

是的,一切都很好,但它削减了图片(右下方。 – Domos