capacitor-camera-module 0.0.25 → 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.
@@ -54,6 +54,9 @@ import androidx.camera.core.ImageProxy;
54
54
  import android.graphics.ImageFormat;
55
55
  import android.media.Image;
56
56
 
57
+ import java.nio.ByteBuffer;
58
+ import androidx.annotation.NonNull;
59
+
57
60
  @CapacitorPlugin(
58
61
  name = "CameraModule",
59
62
  permissions = {
@@ -579,5 +582,55 @@ public class CameraModulePlugin extends Plugin {
579
582
  }
580
583
 
581
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
+
582
635
 
583
636
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capacitor-camera-module",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "Plugin to request permissiones view camera take phots",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",