Skip to content

Commit

Permalink
add notes about reflection in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xulihang committed Dec 8, 2023
1 parent a390b7c commit f66cce8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ npm install capacitor-plugin-dynamsoft-camera-preview
npx cap sync
```

## Get Bitmap/UIImage via Reflection

If you are developing a plugin, you can use reflection to get the camera frames as Bitmap or UIImage on the native side.

Java:

```java
Class cls = Class.forName("com.dynamsoft.capacitor.dce.CameraPreviewPlugin");
Method m = cls.getMethod("getBitmap",null);
Bitmap bitmap = (Bitmap) m.invoke(null, null);
```

Objective-C:

```objc
- (UIImage*)getUIImage{
UIImage *image = ((UIImage* (*)(id, SEL))objc_msgSend)(objc_getClass("CameraPreviewPlugin"), sel_registerName("getBitmap"));
return image;
}
```

## API

<docgen-index>
Expand Down Expand Up @@ -354,7 +375,7 @@ measuredByPercentage: 0 in pixel, 1 in percent

#### Uint8Array

A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.

| Prop | Type | Description |
Expand Down Expand Up @@ -413,9 +434,9 @@ Allowed <a href="#arraybuffer">ArrayBuffer</a> types for the buffer of an ArrayB

#### ArrayBuffer

Represents a raw buffer of binary data, which is used to store data for the
different typed arrays. ArrayBuffers cannot be read from or written to directly,
but can be passed to a typed array or DataView Object to interpret the raw
Represents a raw buffer of binary data, which is used to store data for the
different typed arrays. ArrayBuffers cannot be read from or written to directly,
but can be passed to a typed array or DataView Object to interpret the raw
buffer as needed.

| Prop | Type | Description |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "capacitor-plugin-dynamsoft-camera-preview",
"version": "2.0.0",
"version": "2.1.0",
"description": "A Capacitor plugin for camera preview",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit f66cce8

Please sign in to comment.