Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well well. It seems I have kind of taken care of it. I used the advice from this: <a href="https://stackoverflow.com/questions/8332312/android-front-and-back-camera-orientation-landscape">Android, front and back camera Orientation , Landscape</a></p> <p>And changed my MakeSquare function to this:</p> <pre><code>public static Bitmap MakeSquare(byte[] data, int cameraID) { int width; int height; Matrix matrix = new Matrix(); Camera.CameraInfo info = new Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraID, info); // Convert ByteArray to Bitmap Bitmap bitPic = BitmapFactory.decodeByteArray(data, 0, data.length); width = bitPic.getWidth(); height = bitPic.getHeight(); // Perform matrix rotations/mirrors depending on camera that took the photo if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1}; Matrix matrixMirrorY = new Matrix(); matrixMirrorY.setValues(mirrorY); matrix.postConcat(matrixMirrorY); } matrix.postRotate(90); // Create new Bitmap out of the old one Bitmap bitPicFinal = Bitmap.createBitmap(bitPic, 0, 0, width, height,matrix, true); bitPic.recycle(); int desWidth; int desHeight; desWidth = bitPicFinal.getWidth(); desHeight = desWidth; Bitmap croppedBitmap = Bitmap.createBitmap(bitPicFinal, 0,bitPicFinal.getHeight() / 2 - bitPicFinal.getWidth() / 2,desWidth, desHeight); croppedBitmap = Bitmap.createScaledBitmap(croppedBitmap, 528, 528, true); return croppedBitmap; } </code></pre> <p>This seems to work and do the trick. Although I am not sure this was the best way, I am content with it. Now all I have to do is figure out why its not taking in the proper aspect ratio when using the front camera.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload