From ed7f282277807c35442be60d605fb2c3d1fadd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=85=B3=E9=B9=8F?= Date: Mon, 4 Sep 2023 11:14:11 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/apis/js-apis-image.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘关鹏 --- .../reference/apis/js-apis-image.md | 246 +++++++++--------- 1 file changed, 123 insertions(+), 123 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 145ac36d23..e95f99ce40 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -36,13 +36,13 @@ createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\ { - 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\ **示例:** ```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 **示例:** ```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\ **示例:** ```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 **示例:** ```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\ **示例:** ```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 **示例:** ```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\ **示例:** ```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 **示例:** ```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\ **示例:** ```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\): 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(); ``` ### getDensity9+ @@ -503,7 +503,7 @@ getDensity():number **示例:** ```js -let getDensity = pixelmap.getDensity(); +let getDensity : number = pixelmap.getDensity(); ``` ### opacity9+ @@ -602,7 +602,7 @@ createAlphaPixelmap(callback: AsyncCallback\): 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.createImageSource9+ @@ -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.createImageSource7+ @@ -1192,7 +1192,7 @@ createImageSource(fd: number): ImageSource **示例:** ```js -const imageSourceApi = image.createImageSource(0); +const imageSourceApi : image.ImageSource = image.createImageSource(0); ``` ## image.createImageSource9+ @@ -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.createImageSource9+ @@ -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.createImageSource9+ @@ -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.CreateIncrementalSource9+ @@ -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.CreateIncrementalSource9+ @@ -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\): 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\): 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\ ```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\): 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\ **示例:** ```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\): 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\): 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>; **示例:** ```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 {}) +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\ **示例:** ```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\ { - 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\ **示例:** ```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); ``` ## ImageReceiver9+ @@ -2278,7 +2278,7 @@ getReceivingSurfaceId(callback: AsyncCallback\): void **示例:** ```js -receiver.getReceivingSurfaceId((err, id) => { +receiver.getReceivingSurfaceId((err, id : string) => { if(err) { console.log('getReceivingSurfaceId failed.'); } else { @@ -2304,7 +2304,7 @@ getReceivingSurfaceId(): Promise\ **示例:** ```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\): 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\ **示例:** ```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\): 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\ **示例:** ```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); ``` ## ImageCreator9+ @@ -2536,7 +2536,7 @@ dequeueImage(callback: AsyncCallback\): void **示例:** ```js -creator.dequeueImage((err, img) => { +creator.dequeueImage((err, img : image.Image) => { if (err) { console.info('dequeueImage failed.'); } @@ -2561,7 +2561,7 @@ dequeueImage(): Promise\ **示例:** ```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 **示例:** ```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\ **示例:** ```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\): **示例:** ```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\ **示例:** ```js -img.getComponent(4).then(component => { }) +img.getComponent(4).then((component : image.Component) => { }) ``` ### release9+ -- GitLab