未验证 提交 d26a14dd 编写于 作者: O openharmony_ci 提交者: Gitee

!9783 翻译完成:9597【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-effectKit.md.

Merge pull request !9783 from wusongqing/TR9597
...@@ -40,13 +40,14 @@ Creates a **Filter** instance based on the pixel map. ...@@ -40,13 +40,14 @@ Creates a **Filter** instance based on the pixel map.
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let bufferArr = new Uint8Array(color);
image.createPixelMap(color, opts) let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
.then((pixelMap) => { image.createPixelMap(color, opts).then((pixelMap) => {
let headFilter = effectKit.createEffect(pixelMap) let headFilter = effectKit.createEffect(pixelMap);
}) })
``` ```
## effectKit.createColorPicker ## effectKit.createColorPicker
...@@ -72,14 +73,15 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses a promi ...@@ -72,14 +73,15 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses a promi
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let bufferArr = new Uint8Array(color);
image.createPixelMap(color, opts, (pixelMap) => { let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
effectKit.createColorPicker(pixelMap).then(colorPicker => { image.createPixelMap(color, opts).then((pixelMap) => {
console.info("color picker=" + colorPicker); effectKit.createColorPicker(pixelMap).then(colorPicker => {
}) console.info("color picker=" + colorPicker);
.catch(ex => console.error(".error=" + ex.toString())) }).catch(ex => console.error(".error=" + ex.toString()))
}) })
``` ```
...@@ -101,17 +103,19 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses an asyn ...@@ -101,17 +103,19 @@ Creates a **ColorPicker** instance based on the pixel map. This API uses an asyn
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let bufferArr = new Uint8Array(color);
image.createPixelMap(color, opts, (pixelMap) => { let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
effectKit.createColorPicker(pixelMap, (error, colorPicker) => { image.createPixelMap(color, opts).then((pixelMap) => {
if(error) { effectKit.createColorPicker(pixelMap, (error, colorPicker) => {
console.log('Failed to create color picker.'); if (error) {
} else { console.log('Failed to create color picker.');
console.log('Succeeded in creating color picker.'); } else {
} console.log('Succeeded in creating color picker.');
}) }
})
}) })
``` ```
...@@ -150,7 +154,7 @@ Obtains the main color of the image and writes the result to a **[Color](#color) ...@@ -150,7 +154,7 @@ Obtains the main color of the image and writes the result to a **[Color](#color)
```js ```js
colorPicker.getMainColor().then(color => { colorPicker.getMainColor().then(color => {
console.log('Succeeded in getting main color.') console.log('Succeeded in getting main color.');
console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue); console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue);
}).catch(error => { }).catch(error => {
console.log('Failed to get main color.'); console.log('Failed to get main color.');
...@@ -205,17 +209,17 @@ Adds the blur effect to the filter linked list, and returns the head node of the ...@@ -205,17 +209,17 @@ Adds the blur effect to the filter linked list, and returns the head node of the
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts) image.createPixelMap(color, opts).then((pixelMap) => {
.then((pixelMap) => { let radius = 5;
let radius = 5; let headFilter = effectKit.createEffect(pixelMap);
let headFilter = effectKit.createEffect(pixelMap) if (headFilter != null) {
if (headFilter != null) { headFilter.blur(radius);
headFilter.blur(radius) }
} })
})
``` ```
### brightness ### brightness
...@@ -241,17 +245,17 @@ Adds the brightness effect to the filter linked list, and returns the head node ...@@ -241,17 +245,17 @@ Adds the brightness effect to the filter linked list, and returns the head node
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts) image.createPixelMap(color, opts).then((pixelMap) => {
.then((pixelMap) => { let bright = 0.5;
let bright = 0.5; let headFilter = effectKit.createEffect(pixelMap);
let headFilter = effectKit.createEffect(pixelMap) if (headFilter != null) {
if (headFilter != null) { headFilter.brightness(bright);
headFilter.brightness(bright) }
} })
})
``` ```
### grayscale ### grayscale
...@@ -271,16 +275,16 @@ Adds the grayscale effect to the filter linked list, and returns the head node o ...@@ -271,16 +275,16 @@ Adds the grayscale effect to the filter linked list, and returns the head node o
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts) image.createPixelMap(color, opts).then((pixelMap) => {
.then((pixelMap) => { let headFilter = effectKit.createEffect(pixelMap);
let headFilter = effectKit.createEffect(pixelMap) if (headFilter != null) {
if (headFilter != null) { headFilter.grayscale();
headFilter.grayscale() }
} })
})
``` ```
### getPixelMap ### getPixelMap
...@@ -300,11 +304,11 @@ Obtains **image.PixelMap** of the source image to which the filter linked list i ...@@ -300,11 +304,11 @@ Obtains **image.PixelMap** of the source image to which the filter linked list i
**Example** **Example**
```js ```js
import image from "@ohos.multimedia.image" import image from "@ohos.multimedia.image";
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } };
image.createPixelMap(color, opts) image.createPixelMap(color, opts).then((pixelMap) => {
.then((pixelMap) => { let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap();
let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap() })
})
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册