Take a picture. It comes as a byte array, which we collect in a bitmap and save to a file. But if you look at the resulting image, you will notice that it is slightly shifted to the right. Why is this happening and how to fix it?
The onPictureTaken method to which the array comes in:
public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) { imagesFolder.mkdir(); MyappDir.mkdir(); if (imagesFolder.listFiles().length == 0 | schet == null) { DataOutputStream out = null; Integer n = Integer.valueOf(1); try { out = new DataOutputStream(new FileOutputStream(schet)); out.writeInt(n.intValue()); out.close(); File image = new File(imagesFolder, "image_" + n + ".jpg"); Bitmap imageBmp = BitmapFactory.decodeByteArray(paramArrayOfByte, 0, paramArrayOfByte.length); Matrix matrix = new Matrix(); matrix.postRotate(90); imageBmp = imageBmp.createBitmap(imageBmp, 0, 0, 4128, 2322, matrix, true); FileOutputStream fos = new FileOutputStream(image); imageBmp.compress(Bitmap.CompressFormat.JPEG, 60, fos); fos.close(); galleryAddPic(); } catch (Exception e) { e.printStackTrace(); } } }