未验证 提交 ed7f2822 编写于 作者: 刘关鹏 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-image.md.

Signed-off-by: N刘关鹏 <liuguanpeng1@huawei.com>
上级 68aa708d
......@@ -36,13 +36,13 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<Pi
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap) => {
console.log('Succeeded in creating pixelmap.');
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => {
console.log('Succeeded in creating pixelmap.');
}).catch(error => {
console.log('Failed to create pixelmap.');
console.log('Failed to create pixelmap.');
})
```
......@@ -65,10 +65,10 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: As
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (error, pixelmap) => {
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (error, pixelmap : image.PixelMap) => {
if(error) {
console.log('Failed to create pixelmap.');
} else {
......@@ -112,7 +112,7 @@ readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>
**示例:**
```js
const readBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const readBuffer : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
console.log('Succeeded in reading image pixel data.'); //符合条件则进入
}).catch(error => {
......@@ -138,7 +138,7 @@ readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void
**示例:**
```js
const readBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const readBuffer : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
pixelmap.readPixelsToBuffer(readBuffer, (err, res) => {
if(err) {
console.log('Failed to read image pixel data.'); //不符合条件则进入
......@@ -171,7 +171,7 @@ readPixels(area: PositionArea): Promise\<void>
**示例:**
```js
const area = {
const area image.PositionArea = {
pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
......@@ -202,14 +202,14 @@ readPixels(area: PositionArea, callback: AsyncCallback\<void>): void
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap : image.PixelMap) => {
if(pixelmap == undefined){
console.info('createPixelMap failed.');
} else {
const area = { pixels: new ArrayBuffer(8),
const area : image.PositionArea = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }};
......@@ -243,20 +243,20 @@ writePixels(area: PositionArea): Promise\<void>
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
.then( (pixelmap : image.PixelMap) => {
if (pixelmap == undefined) {
console.info('createPixelMap failed.');
}
const area = { pixels: new ArrayBuffer(8),
const area : image.PositionArea = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
let bufferArr = new Uint8Array(area.pixels);
let bufferArr : Uint8Array = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
......@@ -287,12 +287,12 @@ writePixels(area: PositionArea, callback: AsyncCallback\<void>): void
**示例:**
```js
const area = { pixels: new ArrayBuffer(8),
const area : image.PositionArea = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
let bufferArr = new Uint8Array(area.pixels);
let bufferArr : Uint8Array = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
......@@ -328,8 +328,8 @@ writeBufferToPixels(src: ArrayBuffer): Promise\<void>
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
......@@ -358,8 +358,8 @@ writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
......@@ -390,13 +390,13 @@ getImageInfo(): Promise\<ImageInfo>
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts).then(pixelmap => {
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let opts : image.InitializationOptions = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } }
image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => {
if (pixelmap == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
pixelmap.getImageInfo().then(imageInfo => {
pixelmap.getImageInfo().then((imageInfo : image.ImageInfo) => {
if (imageInfo == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
......@@ -424,13 +424,13 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap : image.PixelMap) => {
if (pixelmap == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
pixelmap.getImageInfo((err, imageInfo) => {
pixelmap.getImageInfo((err, imageInfo : image.ImageInfo) => {
if (imageInfo == undefined) {
console.error("Failed to obtain the image pixel map information.");
}
......@@ -458,11 +458,11 @@ getBytesNumberPerRow(): number
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap) => {
let rowCount = pixelmap.getBytesNumberPerRow();
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap : image.PixelMap) => {
let rowCount : number = pixelmap.getBytesNumberPerRow();
})
```
......@@ -483,7 +483,7 @@ getPixelBytesNumber(): number
**示例:**
```js
let pixelBytesNumber = pixelmap.getPixelBytesNumber();
let pixelBytesNumber : number = pixelmap.getPixelBytesNumber();
```
### getDensity<sup>9+</sup>
......@@ -503,7 +503,7 @@ getDensity():number
**示例:**
```js
let getDensity = pixelmap.getDensity();
let getDensity : number = pixelmap.getDensity();
```
### opacity<sup>9+</sup>
......@@ -602,7 +602,7 @@ createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void
**示例:**
```js
pixelmap.createAlphaPixelmap((err, alphaPixelMap) => {
pixelmap.createAlphaPixelmap((err, alphaPixelMap : image.PixelMap) => {
if (alphaPixelMap == undefined) {
console.info('Failed to obtain new pixel map.');
} else {
......@@ -983,16 +983,16 @@ class MySequence {
return true;
}
async unmarshalling(messageSequence) {
let pixelParcel = await image.createPixelMap(new ArrayBuffer(96), {size: { height:4, width: 6}});
await pixelParcel.unmarshalling(messageSequence).then(async (pixelMap) => {
let pixelParcel : image.PixelMap = await image.createPixelMap(new ArrayBuffer(96), {size: { height:4, width: 6}});
await pixelParcel.unmarshalling(messageSequence).then(async (pixelMap : image.PixelMap) => {
this.pixel_map = pixelMap;
})
return true;
}
}
async function Demo() {
let parcelable = new MySequence(pixelmap);
let data = rpc.MessageSequence.create();
let parcelable : MySequence = new MySequence(pixelmap);
let data : rpc.MessageSequence = rpc.MessageSequence.create();
data.writeParcelable(parcelable);
}
```
......@@ -1042,8 +1042,8 @@ class MySequence {
return true;
}
async unmarshalling(messageSequence) {
let pixelParcel = await image.createPixelMap(new ArrayBuffer(96), {size: { height:4, width: 6}});
await pixelParcel.unmarshalling(messageSequence).then(async (pixelMap) => {
let pixelParcel : image.PixelMap = await image.createPixelMap(new ArrayBuffer(96), {size: { height:4, width: 6}});
await pixelParcel.unmarshalling(messageSequence).then(async (pixelMap : image.PixelMap) => {
this.pixel_map = pixelMap;
})
return true;
......@@ -1051,8 +1051,8 @@ class MySequence {
}
async function Demo() {
let pixel_map = undefined;
let ret = new MySequence(pixel_map);
let data = rpc.MessageSequence.create();
let ret : MySequence = new MySequence(pixel_map);
let data : rpc.MessageSequence = rpc.MessageSequence.create();
await data.readParcelable(ret);
}
```
......@@ -1127,18 +1127,18 @@ createImageSource(uri: string): ImageSource
```js
//Stage模型
const context = getContext(this);
const path = context.cacheDir + "/test.jpg";
const imageSourceApi = image.createImageSource(path);
const context : Context = getContext(this);
const path : string= context.cacheDir + "/test.jpg";
const imageSourceApi : image.ImageSource = image.createImageSource(path);
```
```js
//FA模型
import featureAbility from '@ohos.ability.featureAbility';
const context = featureAbility.getContext();
const path = context.getCacheDir() + "/test.jpg";
const imageSourceApi = image.createImageSource(path);
const context : Context = featureAbility.getContext();
const path : string= context.getCacheDir() + "/test.jpg";
const imageSourceApi : image.ImageSource = image.createImageSource(path);
```
## image.createImageSource<sup>9+</sup>
......@@ -1165,8 +1165,8 @@ createImageSource(uri: string, options: SourceOptions): ImageSource
**示例:**
```js
var sourceOptions = { sourceDensity: 120 };
let imageSource = image.createImageSource('test.png', sourceOptions);
var sourceOptions : image.SourceOptions = { sourceDensity: 120 };
let imageSource : image.ImageSource = image.createImageSource('test.png', sourceOptions);
```
## image.createImageSource<sup>7+</sup>
......@@ -1192,7 +1192,7 @@ createImageSource(fd: number): ImageSource
**示例:**
```js
const imageSourceApi = image.createImageSource(0);
const imageSourceApi : image.ImageSource = image.createImageSource(0);
```
## image.createImageSource<sup>9+</sup>
......@@ -1219,8 +1219,8 @@ createImageSource(fd: number, options: SourceOptions): ImageSource
**示例:**
```js
var sourceOptions = { sourceDensity: 120 };
const imageSourceApi = image.createImageSource(0, sourceOptions);
var sourceOptions : image.SourceOptions = { sourceDensity: 120 };
const imageSourceApi : image.ImageSource = image.createImageSource(0, sourceOptions);
```
## image.createImageSource<sup>9+</sup>
......@@ -1240,8 +1240,8 @@ createImageSource(buf: ArrayBuffer): ImageSource
**示例:**
```js
const buf = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const imageSourceApi = image.createImageSource(buf);
const buf : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const imageSourceApi : image.ImageSource = image.createImageSource(buf);
```
## image.createImageSource<sup>9+</sup>
......@@ -1268,8 +1268,8 @@ createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource
**示例:**
```js
const data = new ArrayBuffer(112);
const imageSourceApi = image.createImageSource(data);
const data : ArrayBuffer= new ArrayBuffer(112);
const imageSourceApi : image.ImageSource = image.createImageSource(data);
```
## image.CreateIncrementalSource<sup>9+</sup>
......@@ -1295,8 +1295,8 @@ CreateIncrementalSource(buf: ArrayBuffer): ImageSource
**示例:**
```js
const buf = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf);
const buf : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const imageSourceIncrementalSApi : image.ImageSource = image.CreateIncrementalSource(buf);
```
## image.CreateIncrementalSource<sup>9+</sup>
......@@ -1323,8 +1323,8 @@ CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
**示例:**
```js
const buf = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf);
const buf : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
const imageSourceIncrementalSApi : image.ImageSource = image.CreateIncrementalSource(buf);
```
## ImageSource
......@@ -1357,7 +1357,7 @@ getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void
**示例:**
```js
imageSourceApi.getImageInfo(0,(error, imageInfo) => {
imageSourceApi.getImageInfo(0,(error, imageInfo : image.ImageInfo) => {
if(error) {
console.log('getImageInfo failed.');
} else {
......@@ -1383,7 +1383,7 @@ getImageInfo(callback: AsyncCallback\<ImageInfo>): void
**示例:**
```js
imageSourceApi.getImageInfo(imageInfo => {
imageSourceApi.getImageInfo((imageInfo : image.ImageInfo) => {
console.log('Succeeded in obtaining the image information.');
})
```
......@@ -1412,7 +1412,7 @@ getImageInfo(index?: number): Promise\<ImageInfo>
```js
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
.then((imageInfo : image.ImageInfo) => {
console.log('Succeeded in obtaining the image information.');
}).catch(error => {
console.log('Failed to obtain the image information.');
......@@ -1467,7 +1467,7 @@ getImageProperty(key:string, callback: AsyncCallback\<string>): void
**示例:**
```js
imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {
imageSourceApi.getImageProperty("BitsPerSample",(error,data : string) => {
if(error) {
console.log('Failed to get the value of the specified attribute key of the image.');
} else {
......@@ -1495,7 +1495,7 @@ getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCa
**示例:**
```js
let property = { index: 0, defaultValue: '9999' }
let property : image.GetImagePropertyOptions = { index: 0, defaultValue: '9999' }
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {
if(error) {
console.log('Failed to get the value of the specified attribute key of the image.');
......@@ -1583,7 +1583,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number)
**示例:**
```js
const array = new ArrayBuffer(100);
const array : ArrayBuffer = new ArrayBuffer(100);
imageSourceApi.updateData(array, false, 0, 10).then(data => {
console.info('Succeeded in updating data.');
})
......@@ -1611,7 +1611,7 @@ updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number,
**示例:**
```js
const array = new ArrayBuffer(100);
const array : ArrayBuffer = new ArrayBuffer(100);
imageSourceApi.updateData(array, false, 0, 10,(error,data )=> {
if(data !== undefined){
console.info('Succeeded in updating data.');
......@@ -1642,7 +1642,7 @@ createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
**示例:**
```js
imageSourceApi.createPixelMap().then(pixelmap => {
imageSourceApi.createPixelMap().then((pixelmap : image.PixelMap) => {
console.log('Succeeded in creating pixelmap object through image decoding parameters.');
}).catch(error => {
console.log('Failed to create pixelmap object through image decoding parameters.');
......@@ -1666,7 +1666,7 @@ createPixelMap(callback: AsyncCallback\<PixelMap>): void
**示例:**
```js
imageSourceApi.createPixelMap((err, pixelmap) => {
imageSourceApi.createPixelMap((err, pixelmap : image.PixelMap) => {
console.info('Succeeded in creating pixelmap object.');
})
```
......@@ -1689,7 +1689,7 @@ createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): vo
**示例:**
```js
let decodingOptions = {
let decodingOptions : image.DecodingOptions = {
sampleSize: 1,
editable: true,
desiredSize: { width: 1, height: 2 },
......@@ -1698,7 +1698,7 @@ let decodingOptions = {
desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 },
index: 0
};
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
imageSourceApi.createPixelMap(decodingOptions, pixelmap : image.PixelMap => {
console.log('Succeeded in creating pixelmap object.');
})
```
......@@ -1738,7 +1738,7 @@ createPixelMapList(options?: DecodingOptions): Promise<Array\<PixelMap>>;
**示例:**
```js
let decodeOpts = {
let decodeOpts : image.DecodingOptions = {
sampleSize: 1,
editable: true,
desiredSize: { width: 198, height: 202 },
......@@ -1813,7 +1813,7 @@ createPixelMapList(options: DecodingOptions, callback: AsyncCallback<Array\<Pixe
**示例:**
```js
let decodeOpts = {
let decodeOpts : image.DecodingOptions = {
sampleSize: 1,
editable: true,
desiredSize: { width: 198, height: 202 },
......@@ -2029,7 +2029,7 @@ createImagePacker(): ImagePacker
**示例:**
```js
const imagePackerApi = image.createImagePacker();
const imagePackerApi : image.ImagePacker = image.createImagePacker();
```
## ImagePacker
......@@ -2063,9 +2063,9 @@ packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<Arr
**示例:**
```js
const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data => {})
const imageSourceApi : image.ImageSource = image.createImageSource(0);
let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 };
imagePackerApi.packing(imageSourceApi, packOpts, data : ArrayBuffer => {})
```
### packing
......@@ -2092,10 +2092,10 @@ packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
**示例:**
```js
const imageSourceApi = image.createImageSource(0);
let packOpts = { format:"image/jpeg", quality:98 }
const imageSourceApi : image.ImageSource = image.createImageSource(0);
let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => {
.then( data : ArrayBuffer => {
console.log('packing succeeded.');
}).catch(error => {
console.log('packing failed.');
......@@ -2121,12 +2121,12 @@ packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayB
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap) => {
let packOpts = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(pixelmap, packOpts, data => {
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap : image.image.PixelMap) => {
let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(pixelmap, packOpts, data : ArrayBuffer => {
console.log('Succeeded in packing the image.');
})
})
......@@ -2156,13 +2156,13 @@ packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
**示例:**
```js
const color = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr = new Uint8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap) => {
let packOpts = { format:"image/jpeg", quality:98 }
const color : ArrayBuffer = new ArrayBuffer(96); //96为需要创建的像素buffer大小,取值为:height * width *4
let bufferArr : Uint8Array = new Uint8Array(color);
let opts : image.InitializationOptions = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts).then((pixelmap : image.PixelMap) => {
let packOpts : image.PackingOption = { format:"image/jpeg", quality:98 }
imagePackerApi.packing(pixelmap, packOpts)
.then( data => {
.then( data : ArrayBuffer => {
console.log('Succeeded in packing the image.');
}).catch(error => {
console.log('Failed to pack the image..');
......@@ -2242,7 +2242,7 @@ createImageReceiver(width: number, height: number, format: number, capacity: num
**示例:**
```js
var receiver = image.createImageReceiver(8192, 8, 2000, 8);
var receiver image.ImageReceiver = image.createImageReceiver(8192, 8, 2000, 8);
```
## ImageReceiver<sup>9+</sup>
......@@ -2278,7 +2278,7 @@ getReceivingSurfaceId(callback: AsyncCallback\<string>): void
**示例:**
```js
receiver.getReceivingSurfaceId((err, id) => {
receiver.getReceivingSurfaceId((err, id : string) => {
if(err) {
console.log('getReceivingSurfaceId failed.');
} else {
......@@ -2304,7 +2304,7 @@ getReceivingSurfaceId(): Promise\<string>
**示例:**
```js
receiver.getReceivingSurfaceId().then( id => {
receiver.getReceivingSurfaceId().then( (id : string) => {
console.log('getReceivingSurfaceId succeeded.');
}).catch(error => {
console.log('getReceivingSurfaceId failed.');
......@@ -2328,7 +2328,7 @@ readLatestImage(callback: AsyncCallback\<Image>): void
**示例:**
```js
receiver.readLatestImage((err, img) => {
receiver.readLatestImage((err, img : image.Image) => {
if(err) {
console.log('readLatestImage failed.');
} else {
......@@ -2354,7 +2354,7 @@ readLatestImage(): Promise\<Image>
**示例:**
```js
receiver.readLatestImage().then(img => {
receiver.readLatestImage().then((img : image.Image) => {
console.log('readLatestImage succeeded.');
}).catch(error => {
console.log('readLatestImage failed.');
......@@ -2378,7 +2378,7 @@ readNextImage(callback: AsyncCallback\<Image>): void
**示例:**
```js
receiver.readNextImage((err, img) => {
receiver.readNextImage((err, img : image.Image) => {
if(err) {
console.log('readNextImage failed.');
} else {
......@@ -2404,7 +2404,7 @@ readNextImage(): Promise\<Image>
**示例:**
```js
receiver.readNextImage().then(img => {
receiver.readNextImage().then((img : image.Image) => {
console.log('readNextImage succeeded.');
}).catch(error => {
console.log('readNextImage failed.');
......@@ -2502,7 +2502,7 @@ createImageCreator(width: number, height: number, format: number, capacity: numb
**示例:**
```js
var creator = image.createImageCreator(8192, 8, 4, 8);
var creator : image.ImageCreator = image.createImageCreator(8192, 8, 4, 8);
```
## ImageCreator<sup>9+</sup>
......@@ -2536,7 +2536,7 @@ dequeueImage(callback: AsyncCallback\<Image>): void
**示例:**
```js
creator.dequeueImage((err, img) => {
creator.dequeueImage((err, img : image.Image) => {
if (err) {
console.info('dequeueImage failed.');
}
......@@ -2561,7 +2561,7 @@ dequeueImage(): Promise\<Image>
**示例:**
```js
creator.dequeueImage().then(img => {
creator.dequeueImage().then((img : image.Image) => {
console.info('dequeueImage succeeded.');
}).catch(error => {
console.log('dequeueImage failed: ' + error);
......@@ -2586,10 +2586,10 @@ queueImage(interface: Image, callback: AsyncCallback\<void>): void
**示例:**
```js
creator.dequeueImage().then(img => {
creator.dequeueImage().then((img : image.Image) => {
//绘制图片
img.getComponent(4).then(component => {
var bufferArr = new Uint8Array(component.byteBuffer);
img.getComponent(4).then(component : image.Component => {
var bufferArr : Uint8Array = new Uint8Array(component.byteBuffer);
for (var i = 0; i < bufferArr.length; i += 4) {
bufferArr[i] = 0; //B
bufferArr[i + 1] = 0; //G
......@@ -2630,10 +2630,10 @@ queueImage(interface: Image): Promise\<void>
**示例:**
```js
creator.dequeueImage().then(img => {
creator.dequeueImage().then((img : image.Image) => {
//绘制图片
img.getComponent(4).then(component => {
var bufferArr = new Uint8Array(component.byteBuffer);
img.getComponent(4).then(component : image.Component => {
var bufferArr : Uint8Array = new Uint8Array(component.byteBuffer);
for (var i = 0; i < bufferArr.length; i += 4) {
bufferArr[i] = 0; //B
bufferArr[i + 1] = 0; //G
......@@ -2756,7 +2756,7 @@ getComponent(componentType: ComponentType, callback: AsyncCallback\<Component>):
**示例:**
```js
img.getComponent(4, (err, component) => {
img.getComponent(4, (err, component : image.Component) => {
if(err) {
console.log('getComponent failed.');
} else {
......@@ -2788,7 +2788,7 @@ getComponent(componentType: ComponentType): Promise\<Component>
**示例:**
```js
img.getComponent(4).then(component => { })
img.getComponent(4).then((component : image.Component) => { })
```
### release<sup>9+</sup>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册