提交 e68c87eb 编写于 作者: F fengzewu

codecheck

Signed-off-by: Nfengzewu <fengzewu@huawei.com>
上级 21a6a4a2
...@@ -39,9 +39,11 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<Pi ...@@ -39,9 +39,11 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<Pi
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let bufferArr = new Uint8Array(color); let bufferArr = new Uint8Array(color);
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) => { console.log('Succeeded in creating pixelmap.');
}) }).catch(error => {
console.log('Failed to create pixelmap.');
})
``` ```
## image.createPixelMap<sup>8+</sup> ## image.createPixelMap<sup>8+</sup>
...@@ -391,7 +393,6 @@ getImageInfo(): Promise\<ImageInfo> ...@@ -391,7 +393,6 @@ getImageInfo(): Promise\<ImageInfo>
const color = new ArrayBuffer(96); const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } } let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts).then(pixelmap => { image.createPixelMap(color, opts).then(pixelmap => {
globalpixelmap = pixelmap;
if (pixelmap == undefined) { if (pixelmap == undefined) {
console.error("Failed to obtain the image pixel map information."); console.error("Failed to obtain the image pixel map information.");
} }
...@@ -427,7 +428,6 @@ const color = new ArrayBuffer(96); ...@@ -427,7 +428,6 @@ 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, (err, pixelmap) => { image.createPixelMap(color, opts, (err, pixelmap) => {
if (pixelmap == undefined) { if (pixelmap == undefined) {
globalpixelmap = pixelmap;
console.error("Failed to obtain the image pixel map information."); console.error("Failed to obtain the image pixel map information.");
} }
pixelmap.getImageInfo((err, imageInfo) => { pixelmap.getImageInfo((err, imageInfo) => {
...@@ -558,9 +558,8 @@ opacity(rate: number): Promise\<void> ...@@ -558,9 +558,8 @@ opacity(rate: number): Promise\<void>
**示例:** **示例:**
```js ```js
async function () { async function A() {
var rate = 0.5; await pixelmap.opacity(0.5);
await pixelmap.opacity(rate);
} }
``` ```
...@@ -581,9 +580,9 @@ createAlphaPixelmap(): Promise\<PixelMap> ...@@ -581,9 +580,9 @@ createAlphaPixelmap(): Promise\<PixelMap>
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.createAlphaPixelmap(); await pixelmap.createAlphaPixelmap();
}) }
``` ```
### createAlphaPixelmap<sup>9+</sup> ### createAlphaPixelmap<sup>9+</sup>
...@@ -631,7 +630,7 @@ scale(x: number, y: number, callback: AsyncCallback\<void>): void ...@@ -631,7 +630,7 @@ scale(x: number, y: number, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.scale(2.0, 1.0); await pixelmap.scale(2.0, 1.0);
} }
``` ```
...@@ -660,7 +659,7 @@ scale(x: number, y: number): Promise\<void> ...@@ -660,7 +659,7 @@ scale(x: number, y: number): Promise\<void>
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.scale(2.0, 1.0); await pixelmap.scale(2.0, 1.0);
} }
``` ```
...@@ -684,7 +683,7 @@ translate(x: number, y: number, callback: AsyncCallback\<void>): void ...@@ -684,7 +683,7 @@ translate(x: number, y: number, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.translate(3.0, 1.0); await pixelmap.translate(3.0, 1.0);
} }
``` ```
...@@ -713,7 +712,7 @@ translate(x: number, y: number): Promise\<void> ...@@ -713,7 +712,7 @@ translate(x: number, y: number): Promise\<void>
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.translate(3.0, 1.0); await pixelmap.translate(3.0, 1.0);
} }
``` ```
...@@ -736,7 +735,7 @@ rotate(angle: number, callback: AsyncCallback\<void>): void ...@@ -736,7 +735,7 @@ rotate(angle: number, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.rotate(90.0); await pixelmap.rotate(90.0);
} }
``` ```
...@@ -764,7 +763,7 @@ rotate(angle: number): Promise\<void> ...@@ -764,7 +763,7 @@ rotate(angle: number): Promise\<void>
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.rotate(90.0); await pixelmap.rotate(90.0);
} }
``` ```
...@@ -788,7 +787,7 @@ flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): vo ...@@ -788,7 +787,7 @@ flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): vo
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.flip(false, true); await pixelmap.flip(false, true);
} }
``` ```
...@@ -817,7 +816,7 @@ flip(horizontal: boolean, vertical: boolean): Promise\<void> ...@@ -817,7 +816,7 @@ flip(horizontal: boolean, vertical: boolean): Promise\<void>
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.flip(false, true); await pixelmap.flip(false, true);
} }
``` ```
...@@ -840,7 +839,7 @@ crop(region: Region, callback: AsyncCallback\<void>): void ...@@ -840,7 +839,7 @@ crop(region: Region, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
} }
``` ```
...@@ -868,7 +867,7 @@ crop(region: Region): Promise\<void> ...@@ -868,7 +867,7 @@ crop(region: Region): Promise\<void>
**示例:** **示例:**
```js ```js
async function () { async function A() {
await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
} }
``` ```
...@@ -890,15 +889,10 @@ release():Promise\<void> ...@@ -890,15 +889,10 @@ release():Promise\<void>
**示例:** **示例:**
```js ```js
const color = new ArrayBuffer(96); pixelmap.release().then(() => {
let bufferArr = new Uint8Array(color); console.log('Succeeded in releasing pixelmap object.');
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } }).catch(error => {
image.createPixelMap(color, opts, (pixelmap) => { console.log('Failed to release pixelmap object.');
pixelmap.release().then(() => {
console.log('Succeeded in releasing pixelmap object.');
}).catch(error => {
console.log('Failed to release pixelmap object.');
})
}) })
``` ```
...@@ -919,13 +913,8 @@ release(callback: AsyncCallback\<void>): void ...@@ -919,13 +913,8 @@ release(callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
const color = new ArrayBuffer(96); pixelmap.release(() => {
let bufferArr = new Uint8Array(color); console.log('Succeeded in releasing pixelmap object.');
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) => {
pixelmap.release().then(() => {
console.log('Succeeded in releasing pixelmap object.');
})
}) })
``` ```
...@@ -1344,11 +1333,10 @@ modifyImageProperty(key: string, value: string): Promise\<void> ...@@ -1344,11 +1333,10 @@ modifyImageProperty(key: string, value: string): Promise\<void>
**示例:** **示例:**
```js ```js
imageSourceApi.modifyImageProperty("ImageWidth", "120") imageSourceApi.modifyImageProperty("ImageWidth", "120").then(() => {
.then(() => { const w = imageSourceApi.getImageProperty("ImageWidth")
const w = imageSourceApi.getImageProperty("ImageWidth") console.info('w', w);
console.info('w', w); })
})
``` ```
### modifyImageProperty<sup>9+</sup> ### modifyImageProperty<sup>9+</sup>
...@@ -1400,9 +1388,9 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number) ...@@ -1400,9 +1388,9 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number)
```js ```js
const array = new ArrayBuffer(100); const array = new ArrayBuffer(100);
imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data => { imageSourceApi.updateData(array, false, 0, 10).then(data => {
console.info('Succeeded in updating data.'); console.info('Succeeded in updating data.');
}) })
``` ```
...@@ -1428,11 +1416,11 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, ...@@ -1428,11 +1416,11 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number,
```js ```js
const array = new ArrayBuffer(100); const array = new ArrayBuffer(100);
imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> { imageSourceApi.updateData(array, false, 0, 10,(error,data )=> {
if(data !== undefined){ if(data !== undefined){
console.info('Succeeded in updating data.'); console.info('Succeeded in updating data.');
} }
}) })
``` ```
### createPixelMap<sup>7+</sup> ### createPixelMap<sup>7+</sup>
...@@ -1616,6 +1604,7 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr ...@@ -1616,6 +1604,7 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr
**示例:** **示例:**
```js ```js
const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 }; let packOpts = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data => {}) imagePackerApi.packing(imageSourceApi, packOpts, data => {})
``` ```
...@@ -1644,6 +1633,7 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer> ...@@ -1644,6 +1633,7 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
**示例:** **示例:**
```js ```js
const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 } let packOpts = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts) imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => { .then( data => {
...@@ -1672,10 +1662,14 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB ...@@ -1672,10 +1662,14 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB
**示例:** **示例:**
```js ```js
let packOpts = { format:"image/jpeg", quality:98 } const color = new ArrayBuffer(96);
const pixelMapApi = new ArrayBuffer(400); let bufferArr = new Uint8Array(color);
imagePackerApi.packing(pixelMapApi, packOpts, data => { let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
console.log('Succeeded in packing the image.'); image.createPixelMap(color, opts).then((pixelmap) => {
let packOpts = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(pixelMapApi, packOpts, data => {
console.log('Succeeded in packing the image.');
})
}) })
``` ```
...@@ -1703,14 +1697,18 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer> ...@@ -1703,14 +1697,18 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
**示例:** **示例:**
```js ```js
let packOpts = { format:"image/jpeg", quality:98 } const color = new ArrayBuffer(96);
const pixelMapApi = new ArrayBuffer(400); let bufferArr = new Uint8Array(color);
imagePackerApi.packing(pixelMapApi, packOpts) let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
.then( data => { image.createPixelMap(color, opts).then((pixelmap) => {
console.log('Succeeded in packing the image.'); let packOpts = { format:"image/jpeg", quality:98 }
}).catch(error => { imagePackerApi.packing(pixelMapApi, packOpts)
console.log('Failed to pack the image..'); .then( data => {
}) console.log('Succeeded in packing the image.');
}).catch(error => {
console.log('Failed to pack the image..');
})
})
``` ```
### release ### release
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册