capacitor-camera-module 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -582,5 +582,55 @@ public class CameraModulePlugin extends Plugin {
|
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
|
|
585
|
+
private Bitmap rotateBitmap(Bitmap bitmap, int rotationDegrees) {
|
|
586
|
+
if (rotationDegrees == 0) return bitmap;
|
|
587
|
+
|
|
588
|
+
Matrix matrix = new Matrix();
|
|
589
|
+
matrix.postRotate(rotationDegrees);
|
|
590
|
+
|
|
591
|
+
return Bitmap.createBitmap(
|
|
592
|
+
bitmap,
|
|
593
|
+
0,
|
|
594
|
+
0,
|
|
595
|
+
bitmap.getWidth(),
|
|
596
|
+
bitmap.getHeight(),
|
|
597
|
+
matrix,
|
|
598
|
+
true
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
@Override
|
|
603
|
+
public void onCaptureSuccess(@NonNull ImageProxy image) {
|
|
604
|
+
Bitmap bitmap = imageProxyToBitmap(image);
|
|
605
|
+
|
|
606
|
+
int rotationDegrees = image.getImageInfo().getRotationDegrees();
|
|
607
|
+
bitmap = rotateBitmap(bitmap, rotationDegrees);
|
|
608
|
+
|
|
609
|
+
String base64 = bitmapToBase64(bitmap);
|
|
610
|
+
|
|
611
|
+
JSObject ret = new JSObject();
|
|
612
|
+
ret.put("base64", base64);
|
|
613
|
+
|
|
614
|
+
image.close();
|
|
615
|
+
call.resolve(ret);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
private Bitmap mirrorBitmap(Bitmap bitmap) {
|
|
619
|
+
Matrix matrix = new Matrix();
|
|
620
|
+
matrix.preScale(-1, 1);
|
|
621
|
+
|
|
622
|
+
return Bitmap.createBitmap(
|
|
623
|
+
bitmap,
|
|
624
|
+
0,
|
|
625
|
+
0,
|
|
626
|
+
bitmap.getWidth(),
|
|
627
|
+
bitmap.getHeight(),
|
|
628
|
+
matrix,
|
|
629
|
+
true
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
585
635
|
|
|
586
636
|
}
|