Skip to content

Commit

Permalink
Mirror image when freezing
Browse files Browse the repository at this point in the history
  • Loading branch information
0xf104a committed Nov 18, 2023
1 parent 8042628 commit 48eb560
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/src/main/java/com/polar/mirror/FreezeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class FreezeController {
* @param provider camera provider
* @param lcOwner lifecycle owner used for binding camera usecases
*/
public void onCameraInitialized(ProcessCameraProvider provider, LifecycleOwner lcOwner){
public void onCameraInitialized(@NonNull ProcessCameraProvider provider, LifecycleOwner lcOwner){
CameraSelector cameraSelector = new CameraSelector.Builder()
.requireLensFacing(CameraSelector.LENS_FACING_FRONT)
.build();
Expand Down Expand Up @@ -82,11 +82,18 @@ private int getRotationAngleFromOrientation(int orientation){
private Bitmap processFreezeImage(byte[] bytes){
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Matrix matrix = new Matrix();
// Rotate image
int rotation = getRotationAngleFromOrientation(Utils.getOrientation(mContext));
matrix.postRotate(rotation);
bitmap = Bitmap.createBitmap(
bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true
);
//Mirror image
matrix = new Matrix();
matrix.preScale(-1.0f, 1.0f);
bitmap = Bitmap.createBitmap(
bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true
);
return bitmap;
}

Expand Down

0 comments on commit 48eb560

Please sign in to comment.