I have a problem with pictures; after I take a picture, it automatically rotates 90-degrees. How I can remove this? I need a portrait picture.
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();
Try something like this: