0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙開發(fā)接口媒體:【@ohos.multimedia.image (圖片處理)】

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-05-31 16:58 ? 次閱讀

圖片處理

說明: 本模塊首批接口從API version 6開始支持。后續(xù)版本的新增接口,采用上角標單獨標記接口的起始版本。 開發(fā)前請熟悉鴻蒙開發(fā)指導文檔 :[gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md]

導入模塊

import image from '@ohos.multimedia.image';

image.createPixelMap8+

createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise

通過屬性創(chuàng)建PixelMap,通過Promise返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù)

名稱類型必填說明
colorsArrayBufferBGRA_8888格式的顏色數(shù)組。
options[InitializationOptions]創(chuàng)建像素的屬性,包括透明度,尺寸,縮略值,像素格式和是否可編輯。

返回值:

類型說明
Promise<[PixelMap]>返回Pixelmap。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
    .then((pixelmap) = > {
        })

image.createPixelMap8+

createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback): void

通過屬性創(chuàng)建PixelMap,通過回調(diào)函數(shù)返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

名稱類型必填說明
colorsArrayBufferBGRA_8888格式的顏色數(shù)組。
options[InitializationOptions]屬性。
callbackAsyncCallback<[PixelMap]>通過回調(diào)返回PixelMap對象。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (pixelmap) = > {
        })

PixelMap7+

圖像像素類,用于讀取或?qū)懭雸D像數(shù)據(jù)以及獲取圖像信息。在調(diào)用PixelMap的方法前,需要先通過createPixelMap創(chuàng)建一個PixelMap實例。

屬性

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
isEditable7+boolean設定是否圖像像素可被編輯。

readPixelsToBuffer7+

readPixelsToBuffer(dst: ArrayBuffer): Promise

讀取圖像像素數(shù)據(jù),結(jié)果寫入ArrayBuffer里,使用Promise形式返回。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
dstArrayBuffer緩沖區(qū),函數(shù)執(zhí)行結(jié)束后獲取的圖像像素數(shù)據(jù)寫入到該內(nèi)存區(qū)域內(nèi)。

返回值:

類型說明
PromisePromise實例,用于獲取結(jié)果,失敗時返回錯誤信息。

示例:

const readBuffer = new ArrayBuffer(400);
pixelmap.readPixelsToBuffer(readBuffer).then(() = > {
    console.log('Succeeded in reading image pixel data.');  //符合條件則進入 
}).catch(error = > {
    console.log('Failed to read image pixel data.');  //不符合條件則進入
})

readPixelsToBuffer7+

readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback): void

讀取圖像像素數(shù)據(jù),結(jié)果寫入ArrayBuffer里,使用callback形式返回。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
dstArrayBuffer緩沖區(qū),函數(shù)執(zhí)行結(jié)束后獲取的圖像像素數(shù)據(jù)寫入到該內(nèi)存區(qū)域內(nèi)。
callbackAsyncCallback獲取回調(diào),失敗時返回錯誤信息。

示例:

const readBuffer = new ArrayBuffer(400);
pixelmap.readPixelsToBuffer(readBuffer, (err, res) = > {
    if(err) {
        console.log('Failed to read image pixel data.');  //不符合條件則進入
    } else {
        console.log('Succeeded in reading image pixel data.');  //符合條件則進入
    }
})

readPixels7+

readPixels(area: PositionArea): Promise

讀取區(qū)域內(nèi)的圖片數(shù)據(jù),使用Promise形式返回讀取結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
area[PositionArea]區(qū)域大小,根據(jù)區(qū)域讀取。

返回值:

類型說明
PromisePromise實例,用于獲取讀取結(jié)果,失敗時返回錯誤信息。

示例:

const area = new ArrayBuffer(400);
pixelmap.readPixels(area).then(() = > {
    console.log('Succeeded in reading the image data in the area.'); //符合條件則進入
}).catch(error = > {
    console.log('Failed to read the image data in the area.'); //不符合條件則進入
})

readPixels7+

readPixels(area: PositionArea, callback: AsyncCallback): void

讀取區(qū)域內(nèi)的圖片數(shù)據(jù),使用callback形式返回讀取結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
area[PositionArea]區(qū)域大小,根據(jù)區(qū)域讀取。
callbackAsyncCallback獲取回調(diào),失敗時返回錯誤信息。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) = > {
    if(pixelmap == undefined){
        console.info('createPixelMap failed.');
    } else {
        const area = { pixels: new ArrayBuffer(8),
            offset: 0,
            stride: 8,
            region: { size: { height: 1, width: 2 }, x: 0, y: 0 }};
        pixelmap.readPixels(area, () = > {
            console.info('readPixels success');
        })
    }
})

writePixels7+

writePixels(area: PositionArea): Promise

將PixelMap寫入指定區(qū)域內(nèi),使用Promise形式返回寫入結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
area[PositionArea]區(qū)域,根據(jù)區(qū)域?qū)懭搿?/td>

返回值:

類型說明
PromisePromise實例,用于獲取寫入結(jié)果,失敗時返回錯誤信息。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
    .then( pixelmap = > {
        if (pixelmap == undefined) {
            console.info('createPixelMap failed.');
        }
        const area = { pixels: new ArrayBuffer(8),
            offset: 0,
            stride: 8,
            region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
        }
        let bufferArr = new Uint8Array(area.pixels);
        for (var i = 0; i  bufferArr.length; i++) {
            bufferArr[i] = i + 1;
        }

        pixelmap.writePixels(area).then(() = > {
            const readArea = { pixels: new ArrayBuffer(8),
                offset: 0,
                stride: 8,
                // region.size.width + x  opts.width, region.size.height + y  opts.height
                region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
            }        
        })
    }).catch(error = > {
        console.log('error: ' + error);
    })

writePixels7+

writePixels(area: PositionArea, callback: AsyncCallback): void

將PixelMap寫入指定區(qū)域內(nèi),使用callback形式返回寫入結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
area[PositionArea]區(qū)域,根據(jù)區(qū)域?qū)懭搿?/td>
callback:AsyncCallback獲取回調(diào),失敗時返回錯誤信息。

示例:

const area = new ArrayBuffer(400);
pixelmap.writePixels(area, (error) = > {
    if (error!=undefined) {
		console.info('Failed to write pixelmap into the specified area.');
	} else {
	    const readArea = {
            pixels: new ArrayBuffer(20),
            offset: 0,
            stride: 8,
            region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
        }
	}
})

writeBufferToPixels7+

writeBufferToPixels(src: ArrayBuffer): Promise

讀取緩沖區(qū)中的圖片數(shù)據(jù),結(jié)果寫入PixelMap中,使用Promise形式返回。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
srcArrayBuffer圖像像素數(shù)據(jù)。

返回值:

類型說明
PromisePromise實例,用于獲取結(jié)果,失敗時返回錯誤信息。

示例:

const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color);
pixelMap.writeBufferToPixels(color).then(() = > {
    console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) = > {
    console.error("Failed to write data from a buffer to a PixelMap.");
})

writeBufferToPixels7+

writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback): void

讀取緩沖區(qū)中的圖片數(shù)據(jù),結(jié)果寫入PixelMap中,使用callback形式返回。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
srcArrayBuffer圖像像素數(shù)據(jù)。
callbackAsyncCallback獲取回調(diào),失敗時返回錯誤信息。

示例:

const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
let bufferArr = new Unit8Array(color);
pixelMap.writeBufferToPixels(color, function(err) {
    if (err) {
        console.error("Failed to write data from a buffer to a PixelMap.");
        return;
    } else {
		console.log("Succeeded in writing data from a buffer to a PixelMap.");
	}
});

getImageInfo7+

getImageInfo(): Promise

獲取圖像像素信息,使用Promise形式返回獲取的圖像像素信息。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

返回值:

類型說明
Promise<[ImageInfo]>Promise實例,用于異步獲取圖像像素信息,失敗時返回錯誤信息。

示例:

const pixelMap = new ArrayBuffer(400);
pixelMap.getImageInfo().then(function(info) {
    console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) = > {
    console.error("Failed to obtain the image pixel map information.");
});

getImageInfo7+

getImageInfo(callback: AsyncCallback): void

獲取圖像像素信息,使用callback形式返回獲取的圖像像素信息。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

參數(shù)名類型必填說明
callbackAsyncCallback<[ImageInfo]>獲取圖像像素信息回調(diào),異步返回圖像像素信息,失敗時返回錯誤信息。

示例:

pixelmap.getImageInfo((imageInfo) = > { 
    console.log("Succeeded in obtaining the image pixel map information..");
})

getBytesNumberPerRow7+

getBytesNumberPerRow(): number

獲取圖像像素每行字節(jié)數(shù)。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

返回值:

類型說明
number圖像像素的行字節(jié)數(shù)。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap) = > {
    let rowCount = pixelmap.getBytesNumberPerRow();
})

getPixelBytesNumber7+

getPixelBytesNumber(): number

獲取圖像像素的總字節(jié)數(shù)。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

返回值:

類型說明
number圖像像素的總字節(jié)數(shù)。

示例:

let pixelBytesNumber = pixelmap.getPixelBytesNumber();

release7+

release():Promise

釋放PixelMap對象,使用Promise形式返回釋放結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

返回值:

類型說明
Promise異步返回釋放結(jié)果。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
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.');
    }).catch(error = > {
	    console.log('Failed to release pixelmap object.');
    })
})

release7+

release(callback: AsyncCallback): void

釋放PixelMap對象,使用callback形式返回釋放結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

名稱類型必填說明
callbackAsyncCallback異步返回釋放結(jié)果。

示例:

const color = new ArrayBuffer(96);
let bufferArr = new Unit8Array(color);
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.');
    }).catch(error = > {
	    console.log('Failed to release pixelmap object.');
    })
})

image.createImageSource

createImageSource(uri: string): ImageSource

通過傳入的uri創(chuàng)建圖片源實例。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
uristring圖片路徑,當前僅支持應用沙箱路徑。

返回值:

類型說明
[ImageSource]返回ImageSource類實例,失敗時返回undefined。

示例:

let path = this.context.getApplicationContext().fileDirs + "test.jpg";
const imageSourceApi = image.createImageSource(path);

image.createImageSource7+

createImageSource(fd: number): ImageSource

通過傳入文件描述符來創(chuàng)建圖片源實例。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
fdnumber文件描述符fd。

返回值:

類型說明
[ImageSource]返回ImageSource類實例,失敗時返回undefined。

示例:

const imageSourceApi = image.createImageSource(0)

image.createImageSource9+

createImageSource(buf: ArrayBuffer): ImageSource

通過緩沖區(qū)創(chuàng)建圖片源實例。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
bufArrayBuffer圖像緩沖區(qū)數(shù)組。

示例:

const buf = new ArrayBuffer(96);
image.createImageSource(buf, () = > { })

image.CreateIncrementalSource9+

function CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource

通過緩沖區(qū)以增量的方式創(chuàng)建圖片源實例。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
bufArrayBuffer增量數(shù)據(jù)。
options[SourceOptions]圖片屬性,包括圖片序號與默認屬性值。

返回值:

類型說明
[ImageSource]返回圖片源,失敗時返回undefined。

示例:

const buf = new ArrayBuffer(96);
const imageSourceApi = image.createIncrementalSource(buf);

ImageSource

圖片源類,用于獲取圖片相關信息。在調(diào)用ImageSource的方法前,需要先通過createImageSource構(gòu)建一個ImageSource實例。

屬性

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

名稱類型可讀可寫說明
supportedFormatsArray支持的圖片格式,包括:png,jpeg,wbmp,bmp,gif,webp,heif等。

getImageInfo

getImageInfo(index: number, callback: AsyncCallback): void

獲取指定序號的圖片信息,使用callback形式返回圖片信息。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
indexnumber創(chuàng)建圖片源時的序號。
callbackAsyncCallback<[ImageInfo]>獲取圖片信息回調(diào),異步返回圖片信息對象。

示例:

imageSourceApi.getImageInfo(0,(error, imageInfo) = > { 
    if(error) {
        console.log('getImageInfo failed.');
    } else {
        console.log('getImageInfo succeeded.');
    }
})

getImageInfo

getImageInfo(callback: AsyncCallback): void

獲取圖片信息,使用callback形式返回圖片信息。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
callbackAsyncCallback<[ImageInfo]>獲取圖片信息回調(diào),異步返回圖片信息對象。

示例:

imageSourceApi.getImageInfo(imageInfo = > { 
    console.log('Succeeded in obtaining the image information.');
})

getImageInfo

getImageInfo(index?: number): Promise

獲取圖片信息,使用Promise形式返回圖片信息。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
indexnumber創(chuàng)建圖片源時的序號,不選擇時默認為0。

返回值:

類型說明
Promise<[ImageInfo]>返回獲取到的圖片信息。

示例:

imageSourceApi.getImageInfo(0)
    .then(imageInfo = > {
		console.log('Succeeded in obtaining the image information.');
	}).catch(error = > {
		console.log('Failed to obtain the image information.');
	})

getImageProperty7+

getImageProperty(key:string, options?: GetImagePropertyOptions): Promise

獲取圖片中給定索引處圖像的指定屬性鍵的值,用Promise形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
keystring圖片屬性名。
options[GetImagePropertyOptions]圖片屬性,包括圖片序號與默認屬性值。

返回值:

類型說明
PromisePromise實例,用于異步獲取圖片屬性值,如獲取失敗則返回屬性默認值。

示例:

imageSourceApi.getImageProperty("BitsPerSample")
    .then(data = > {
		console.log('Succeeded in getting the value of the specified attribute key of the image.');
	})

getImageProperty7+

getImageProperty(key:string, callback: AsyncCallback): void

獲取圖片中給定索引處圖像的指定屬性鍵的值,用callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
keystring圖片屬性名。
callbackAsyncCallback獲取圖片屬性回調(diào),返回圖片屬性值,如獲取失敗則返回屬性默認值。

示例:

imageSourceApi.getImageProperty("BitsPerSample",(error,data) = > { 
    if(error) {
        console.log('Failed to get the value of the specified attribute key of the image.');
    } else {
        console.log('Succeeded in getting the value of the specified attribute key of the image.');
    }
})

getImageProperty7+

getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback): void

獲取圖片指定屬性鍵的值,callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
keystring圖片屬性名。
options[GetImagePropertyOptions]圖片屬性,包括圖片序號與默認屬性值。
callbackAsyncCallback獲取圖片屬性回調(diào),返回圖片屬性值,如獲取失敗則返回屬性默認值。

示例:

const property = new ArrayBuffer(400);
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) = > { 
    if(error) {
        console.log('Failed to get the value of the specified attribute key of the image.');
    } else {
        console.log('Succeeded in getting the value of the specified attribute key of the image.');
    }
})

modifyImageProperty9+

modifyImageProperty(key: string, value: string): Promise

通過指定的鍵修改圖片屬性的值,使用Promise形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
keystring圖片屬性名。
valuestring屬性值。

返回值:

類型說明
PromisePromise實例,異步返回結(jié)果。

示例:

imageSourceApi.modifyImageProperty("ImageWidth", "abc")
            .then(() = > {
                const w = imageSourceApi.getImageProperty("ImageWidth")
                console.info('w', w);
            })

modifyImageProperty9+

modifyImageProperty(key: string, value: string, callback: AsyncCallback): void

通過指定的鍵修改圖片屬性的值,callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

參數(shù)名類型必填說明
keystring圖片屬性名。
valuestring屬性值。
callbackAsyncCallback修改屬性值,callback返回結(jié)果。

示例:

imageSourceApi.modifyImageProperty("ImageWidth", "abc",() = > {})

updateData9+

updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise

更新增量數(shù)據(jù),使用Promise形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
bufArrayBuffer增量數(shù)據(jù)。
isFinishedboolean是否更新完。
valuenumber偏移量。
lengthnumber數(shù)組長。

返回值:

類型說明
PromisePromise實例,異步返回結(jié)果。

示例:

const array = new ArrayBuffer(100);
imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data = > {
            console.info('Succeeded in updating data.');
        })

updateData9+

updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback): void

更新增量數(shù)據(jù),callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
bufArrayBuffer增量數(shù)據(jù)。
isFinishedboolean是否更新完。
valuenumber偏移量。
lengthnumber數(shù)組長。
callbackAsyncCallback回調(diào)表示成功或失敗。

示例:

const array = new ArrayBuffer(100);
imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )= > {
            if(data !== undefined){
                console.info('Succeeded in updating data.');     
            }
		})

createPixelMap7+

createPixelMap(options?: DecodingOptions): Promise

通過圖片解碼參數(shù)創(chuàng)建PixelMap對象。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
options[DecodingOptions]解碼參數(shù)。

返回值:

類型說明
Promise<[PixelMap]>異步返回Promise對象。

示例:

imageSourceApi.createPixelMap().then(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.');
})

createPixelMap7+

createPixelMap(callback: AsyncCallback): void

通過默認參數(shù)創(chuàng)建PixelMap對象,使用callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
callbackAsyncCallback<[PixelMap]>通過回調(diào)返回PixelMap對象。

示例:

imageSourceApi.createPixelMap(pixelmap = > { 
    console.log('Succeeded in creating pixelmap object.');
}).catch(error = > {
    console.log('Failed to create pixelmap object.');
})

createPixelMap7+

createPixelMap(options: DecodingOptions, callback: AsyncCallback): void

通過圖片解碼參數(shù)創(chuàng)建PixelMap對象。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
options[DecodingOptions]解碼參數(shù)。
callbackAsyncCallback<[PixelMap]>通過回調(diào)返回PixelMap對象。

示例:

const decodingOptions = new ArrayBuffer(400);
imageSourceApi.createPixelMap(decodingOptions, pixelmap = > { 
    console.log('Succeeded in creating pixelmap object.');
})

release

release(callback: AsyncCallback): void

釋放圖片源實例,使用callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

參數(shù):

名稱類型必填說明
callbackAsyncCallback資源釋放回調(diào),失敗時返回錯誤信息。

示例:

imageSourceApi.release(() = > { 
    console.log('release succeeded.');
})

release

release(): Promise

釋放圖片源實例,使用Promise形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageSource

返回值:

類型說明
PromisePromise實例,異步返回結(jié)果。

示例:

imageSourceApi.release().then(()= >{
    console.log('Succeeded in releasing the image source instance.');
}).catch(error = > {
    console.log('Failed to release the image source instance.');
})

image.createImagePacker

createImagePacker(): ImagePacker

創(chuàng)建ImagePacker實例。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

返回值:

類型說明
[ImagePacker]返回ImagePacker實例。

示例:

const imagePackerApi = image.createImagePacker();

ImagePacker

圖片打包器類,用于圖片壓縮和打包。在調(diào)用ImagePacker的方法前,需要先通過createImagePacker構(gòu)建一個ImagePacker實例。

屬性

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

名稱類型可讀可寫說明
supportedFormatsArray圖片打包支持的格式,jpeg。

packing

packing(source: ImageSource, option: PackingOption, callback: AsyncCallback): void

圖片壓縮或重新打包,使用callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

參數(shù):

參數(shù)名類型必填說明
source[ImageSource]打包的圖片源。
option[PackingOption]設置打包參數(shù)。
callbackAsyncCallback獲取圖片打包回調(diào),返回打包后數(shù)據(jù)。

示例:

let packOpts = { format:"image/jpeg", quality:98 };
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts, data = > {})

packing

packing(source: ImageSource, option: PackingOption): Promise

圖片壓縮或重新打包,使用Promise形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

參數(shù):

參數(shù)名類型必填說明
source[ImageSource]打包的圖片源。
option[PackingOption]設置打包參數(shù)。

返回值:

類型說明
PromisePromise實例,用于異步獲取壓縮或打包后的數(shù)據(jù)。

示例:

let packOpts = { format:"image/jpeg", quality:98 }
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts)
    .then( data = > {
        console.log('packing succeeded.');
	}).catch(error = > {
	    console.log('packing failed.');
	})

packing8+

packing(source: PixelMap, option: PackingOption, callback: AsyncCallback): void

圖片壓縮或重新打包,使用callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

參數(shù):

參數(shù)名類型必填說明
source[PixelMap]打包的PixelMap資源。
option[PackingOption]設置打包參數(shù)。
callbackAsyncCallback獲取圖片打包回調(diào),返回打包后數(shù)據(jù)。

示例:

let packOpts = { format:"image/jpeg", quality:98 }
const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts, data = > { 
    console.log('Succeeded in packing the image.');
}).catch(error = > {
	console.log('Failed to pack the image.');
})

packing8+

packing(source: PixelMap, option: PackingOption): Promise

圖片壓縮或重新打包,使用Promise形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

參數(shù):

參數(shù)名類型必填說明
source[PixelMap]打包的PixelMap源。
option[PackingOption]設置打包參數(shù)。

返回值:

類型說明
PromisePromise實例,用于異步獲取壓縮或打包后的數(shù)據(jù)。

示例:

let packOpts = { format:"image/jpeg", quality:98 }
const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts)
    .then( data = > {
	    console.log('Succeeded in packing the image.');
	}).catch(error = > {
	    console.log('Failed to pack the image..');
	})

release

release(callback: AsyncCallback): void

釋放圖片打包實例,使用callback形式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

參數(shù):

參數(shù)名類型必填說明
callbackAsyncCallback釋放回調(diào),失敗時返回錯誤信息。

示例:

imagePackerApi.release(()= >{ 
    console.log('Succeeded in releasing image packaging.');
})

release

release(): Promise

釋放圖片打包實例,使用Promise形式返回釋放結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImagePacker

返回值:

類型說明
PromisePromise實例,用于異步獲取釋放結(jié)果,失敗時返回錯誤信息。

示例:

imagePackerApi.release().then(()= >{
    console.log('Succeeded in releasing image packaging.');
}).catch((error)= >{ 
    console.log('Failed to release image packaging.'); 
})

image.createImageReceiver9+

createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver

通過寬、高、圖片格式、容量創(chuàng)建ImageReceiver實例。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

參數(shù):

名稱類型必填說明
widthnumber圖像的默認寬度。
heightnumber圖像的默認高度。
formatnumber圖像格式。
capacitynumber同時訪問的最大圖像數(shù)。

返回值:

類型說明
[ImageReceiver]如果操作成功,則返回ImageReceiver實例。

示例:

var receiver = image.createImageReceiver(8192, 8, 4, 8);

ImageReceiver9+

圖像接收類,用于獲取組件surface id,接收最新的圖片和讀取下一張圖片,以及釋放ImageReceiver實例。

在調(diào)用以下方法前需要先創(chuàng)建ImageReceiver實例。

屬性

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.ImageReceiver

名稱類型可讀可寫說明
size9+[Size]圖片大小。
capacity9+number同時訪問的圖像數(shù)。
format9+[ImageFormat]圖像格式。

getReceivingSurfaceId9+

getReceivingSurfaceId(callback: AsyncCallback): void

用于獲取一個surface id供Camera或其他組件使用。使用callback返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

參數(shù):

名稱類型必填說明
callbackAsyncCallback回調(diào)函數(shù),返回surface id。

示例:

receiver.getReceivingSurfaceId((err, id) = > { 
    if(err) {
        console.log('getReceivingSurfaceId failed.');
    } else {
        console.log('getReceivingSurfaceId succeeded.');
    }
});

getReceivingSurfaceId9+

getReceivingSurfaceId(): Promise

用于獲取一個surface id供Camera或其他組件使用。使用promise返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

返回值:

類型說明
Promise異步返回surface id。

示例:

receiver.getReceivingSurfaceId().then( id = > { 
    console.log('getReceivingSurfaceId succeeded.');
}).catch(error = > {
    console.log('getReceivingSurfaceId failed.');
})

readLatestImage9+

readLatestImage(callback: AsyncCallback): void

從ImageReceiver讀取最新的圖片,并使用callback返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

參數(shù):

名稱類型必填說明
callbackAsyncCallback<[Image]>回調(diào)函數(shù),返回最新圖像。

示例:

receiver.readLatestImage((err, img) = > { 
    if(err) {
        console.log('readLatestImage failed.');
    } else {
        console.log('readLatestImage succeeded.');
    }
});

readLatestImage9+

readLatestImage(): Promise

從ImageReceiver讀取最新的圖片,并使用promise返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

返回值:

類型說明
Promise<[Image]>異步返回最新圖片。

示例:

receiver.readLatestImage().then(img = > {
    console.log('readLatestImage succeeded.');
}).catch(error = > {
    console.log('readLatestImage failed.');
})

readNextImage9+

readNextImage(callback: AsyncCallback): void

從ImageReceiver讀取下一張圖片,并使用callback返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

參數(shù):

名稱類型必填說明
callbackAsyncCallback<[Image]>回調(diào)函數(shù),返回下一張圖片。

示例:

receiver.readNextImage((err, img) = > { 
    if(err) {
        console.log('readNextImage failed.');
    } else {
        console.log('readNextImage succeeded.');
    }
});

readNextImage9+

readNextImage(): Promise

從ImageReceiver讀取下一張圖片,并使用promise返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

返回值:

類型說明
Promise<[Image]>異步返回下一張圖片。

示例:

receiver.readNextImage().then(img = > {
    console.log('readNextImage succeeded.');
}).catch(error = > {
    console.log('readNextImage failed.');
})

on('imageArrival')9+

on(type: 'imageArrival', callback: AsyncCallback): void

接收圖片時注冊回調(diào)。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

參數(shù):

名稱類型必填說明
typestring注冊事件的類型,固定為'imageArrival',接收圖片時觸發(fā)。
callbackAsyncCallback注冊的事件回調(diào)。

示例:

receiver.on('imageArrival', () = > {})

release9+

release(callback: AsyncCallback): void

釋放ImageReceiver實例并使用回調(diào)返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

參數(shù):

名稱類型必填說明
callbackAsyncCallback回調(diào)函數(shù),返回操作結(jié)果。

示例:

receiver.release(() = > {})

release9+

release(): Promise

釋放ImageReceiver實例并使用promise返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.ImageReceiver

返回值:

類型說明
Promise異步返回操作結(jié)果。

示例:

receiver.release().then(() = > {
    console.log('release succeeded.');
}).catch(error = > {
    console.log('release failed.');
})

Image9+

提供基本的圖像操作,包括獲取圖像信息、讀寫圖像數(shù)據(jù)。調(diào)用[readNextImage]和[readLatestImage]接口時會返回image。

屬性

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
clipRect9+[Region]要裁剪的圖像區(qū)域。
size9+[Size]圖像大小。
format9+number圖像格式,參考[PixelMapFormat]。

getComponent9+

getComponent(componentType: ComponentType, callback: AsyncCallback): void

根據(jù)圖像的組件類型從圖像中獲取組件緩存并使用callback返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

名稱類型必填說明
componentType[ComponentType]圖像的組件類型。
callbackAsyncCallback<[Component]>用于返回組件緩沖區(qū)。

示例:

img.getComponent(4, (err, component) = > {
    if(err) {
        console.log('getComponent failed.');
    } else {
        console.log('getComponent succeeded.');
    }
})

getComponent9+

getComponent(componentType: ComponentType): Promise

根據(jù)圖像的組件類型從圖像中獲取組件緩存并使用Promise方式返回結(jié)果。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

名稱類型必填說明
componentType[ComponentType]圖像的組件類型。

返回值:

類型說明
Promise<[Component]>用于返回組件緩沖區(qū)的promise實例。

示例:

img.getComponent(4).then(component = > { })

release9+

release(callback: AsyncCallback): void

釋放當前圖像并使用callback返回結(jié)果。

在接收另一個圖像前必須先釋放對應資源。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

參數(shù):

名稱類型必填說明
callbackAsyncCallback返回操作結(jié)果。

示例:

img.release(() = >{ 
    console.log('release succeeded.');
}).catch(error = > {
    console.log('release failed.');
})

release9+

release(): Promise

釋放當前圖像并使用Promise方式返回結(jié)果。

在接收另一個圖像前必須先釋放對應資源。

系統(tǒng)能力: SystemCapability.Multimedia.Image.Core

返回值:

類型說明
Promisepromise返回操作結(jié)果。

示例:

img.release().then(() = >{
    console.log('release succeeded.');
}).catch(error = > {
    console.log('release failed.');
})

PositionArea7+

表示圖片指定區(qū)域內(nèi)的數(shù)據(jù)。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
pixelsArrayBuffer像素。
offsetnumber偏移量。
stridenumber像素間距,stride >= region.size.width*4。
region[Region]區(qū)域,按照區(qū)域讀寫。寫入的區(qū)域?qū)挾燃覺坐標不能大于原圖的寬度,寫入的區(qū)域高度加Y坐標不能大于原圖的高度

ImageInfo

表示圖片信息。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
size[Size]圖片大小。

Size

表示圖片尺寸。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
heightnumber輸出圖片的高。
widthnumber輸出圖片的寬。

PixelMapFormat7+

枚舉,圖片像素格式。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱默認值描述
UNKNOWN0未知格式。
RGBA_88883格式為RGBA_8888。
RGB_5652格式為RGB_565。

AlphaType9+

枚舉,圖像的透明度類型。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱默認值描述
UNKNOWN0未知透明度。
OPAQUE1沒有alpha或圖片全透明。
PREMUL2RGB前乘alpha。
UNPREMUL3RGB不前乘alpha。

ScaleMode9+

枚舉,圖像的縮放模式。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱默認值描述
CENTER_CROP1縮放圖像以填充目標圖像區(qū)域并居中裁剪區(qū)域外的效果。
FIT_TARGET_SIZE2圖像適合目標尺寸的效果。

InitializationOptions8+

PixelMap的初始化選項。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Code

名稱類型可讀可寫說明
alphaType9+[AlphaType]透明度。
editableboolean是否可編輯。
pixelFormat[PixelMapFormat]像素格式。
scaleMode9+[ScaleMode]縮略值。
size[Size]創(chuàng)建圖片大小。

DecodingOptions7+

圖像解碼設置選項。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.ImageSource

名稱類型可讀可寫說明
sampleSizenumber縮略圖采樣大小。
rotatenumber旋轉(zhuǎn)角度。
editableboolean是否可編輯。
desiredSize[Size]期望輸出大小。
desiredRegion[Region]解碼區(qū)域。
desiredPixelFormat[PixelMapFormat]解碼的像素格式。
indexnumber解碼圖片序號。

Region7+

表示區(qū)域信息。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
size[Size]區(qū)域大小。
xnumber區(qū)域橫坐標。
ynumber區(qū)域縱坐標。

PackingOption

表示圖片打包選項。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.ImagePacker

名稱類型可讀可寫說明
formatstring目標格式。
qualitynumberJPEG編碼中設定輸出圖片質(zhì)量的參數(shù),取值范圍為1-100。

GetImagePropertyOptions7+

表示查詢圖片屬性的索引。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.ImageSource

名稱類型可讀可寫說明
indexnumber圖片序號。
defaultValuestring默認屬性值。

PropertyKey7+

枚舉,Exif(Exchangeable image file format)圖片信息。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱默認值說明
BITS_PER_SAMPLE"BitsPerSample"每個像素比特數(shù)。
ORIENTATION"Orientation"圖片方向。
IMAGE_LENGTH"ImageLength"圖片長度。
IMAGE_WIDTH"ImageWidth"圖片寬度。
GPS_LATITUDE"GPSLatitude"圖片緯度。
GPS_LONGITUDE"GPSLongitude"圖片經(jīng)度。
GPS_LATITUDE_REF"GPSLatitudeRef"緯度引用,例如N或S。
GPS_LONGITUDE_REF"GPSLongitudeRef"經(jīng)度引用,例如W或E。

ImageFormat9+

枚舉,圖片格式。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱默認值描述
YCBCR_422_SP1000YCBCR422半平面格式。
JPEG2000JPEG編碼格式。

ComponentType9+

枚舉,圖像的組件類型。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.ImageReceiver

名稱默認值描述
YUV_Y1亮度信息。
YUV_U2色度信息。
YUV_V3色度信息。
JPEG4Jpeg 類型。

Component9+

描述圖像顏色分量。

系統(tǒng)能力: 以下各項對應的系統(tǒng)能力均為SystemCapability.Multimedia.Image.Core

名稱類型可讀可寫說明
componentType[ComponentType]組件類型。
rowStridenumber行距。
pixelStridenumber像素間距。
byteBufferArrayBuffer組件緩沖區(qū)。

ResponseCode

編譯錯誤返回的響應碼。

搜狗高速瀏覽器截圖20240326151344.png

名稱HarmonyOSOpenHarmony鴻蒙文檔籽料:mau123789是v直接拿說明
ERR_MEDIA_INVALID_VALUE-1無效大小。
SUCCESS0操作成功。
ERROR62980096操作失敗。
ERR_IPC62980097ipc錯誤。
ERR_SHAMEM_NOT_EXIST62980098共享內(nèi)存錯誤。
ERR_SHAMEM_DATA_ABNORMAL62980099共享內(nèi)存錯誤。
ERR_IMAGE_DECODE_ABNORMAL62980100圖像解碼錯誤。
ERR_IMAGE_DATA_ABNORMAL62980101圖像輸入數(shù)據(jù)錯誤。
ERR_IMAGE_MALLOC_ABNORMAL62980102圖像malloc錯誤。
ERR_IMAGE_DATA_UNSUPPORT62980103不支持圖像類型。
ERR_IMAGE_INIT_ABNORMAL62980104圖像初始化錯誤。
ERR_IMAGE_GET_DATA_ABNORMAL62980105圖像獲取數(shù)據(jù)錯誤。
ERR_IMAGE_TOO_LARGE62980106圖像數(shù)據(jù)太大。
ERR_IMAGE_TRANSFORM62980107圖像轉(zhuǎn)換錯誤。
ERR_IMAGE_COLOR_CONVERT62980108圖像顏色轉(zhuǎn)換錯誤。
ERR_IMAGE_CROP62980109裁剪錯誤。
ERR_IMAGE_SOURCE_DATA62980110圖像源數(shù)據(jù)錯誤。
ERR_IMAGE_SOURCE_DATA_INCOMPLETE62980111圖像源數(shù)據(jù)不完整。
ERR_IMAGE_MISMATCHED_FORMAT62980112圖像格式不匹配。
ERR_IMAGE_UNKNOWN_FORMAT62980113圖像未知格式。
ERR_IMAGE_SOURCE_UNRESOLVED62980114圖像源未解析。
ERR_IMAGE_INVALID_PARAMETER62980115圖像無效參數(shù)。
ERR_IMAGE_DECODE_FAILED62980116解碼失敗。
ERR_IMAGE_PLUGIN_REGISTER_FAILED62980117注冊插件失敗。
ERR_IMAGE_PLUGIN_CREATE_FAILED62980118創(chuàng)建插件失敗。
ERR_IMAGE_ENCODE_FAILED62980119圖像編碼失敗。
ERR_IMAGE_ADD_PIXEL_MAP_FAILED62980120圖像添加像素映射失敗。
ERR_IMAGE_HW_DECODE_UNSUPPORT62980121不支持圖像硬件解碼。
ERR_IMAGE_DECODE_HEAD_ABNORMAL62980122圖像解碼頭錯誤。
ERR_IMAGE_DECODE_EXIF_UNSUPPORT62980123圖像解碼exif取消支持。
ERR_IMAGE_PROPERTY_NOT_EXIST62980124圖像屬性不存在;錯誤代碼被媒體占用,圖像從150開始。
ERR_IMAGE_READ_PIXELMAP_FAILED62980246讀取像素地圖失敗。
ERR_IMAGE_WRITE_PIXELMAP_FAILED62980247寫入像素映射失敗。
ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY62980248pixelmap不允許修改。
ERR_IMAGE_CONFIG_FAILED62980259配置錯誤。
審核編輯 黃宇
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 接口
    +關注

    關注

    33

    文章

    8257

    瀏覽量

    149960
  • 圖片處理
    +關注

    關注

    0

    文章

    16

    瀏覽量

    6817
  • 鴻蒙
    +關注

    關注

    56

    文章

    2267

    瀏覽量

    42489
收藏 人收藏

    評論

    相關推薦

    鴻蒙開發(fā)接口媒體:【@ohos.multimedia.audio (音頻管理)】

    音頻管理提供管理音頻的一些基礎能力,包括對音頻音量、音頻設備的管理,以及對音頻數(shù)據(jù)的采集和渲染等。
    的頭像 發(fā)表于 05-31 09:53 ?1829次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>媒體</b>:【@<b class='flag-5'>ohos.multimedia</b>.audio (音頻管理)】

    鴻蒙開發(fā)接口媒體:【@ohos.multimedia.camera (相機管理)】

    本模塊首批接口從API version 9開始支持。后續(xù)版本的新增接口,采用上角標單獨標記接口的起始版本。
    的頭像 發(fā)表于 05-31 09:42 ?1274次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>媒體</b>:【@<b class='flag-5'>ohos.multimedia</b>.camera (相機管理)】

    鴻蒙媒體開發(fā)【簡述】

    ):提供音量管理、音頻路由管理、混音管理接口與服務。 視頻(media):提供音視頻解壓播放、壓縮錄制接口與服務。 圖片image):提供圖片
    發(fā)表于 02-28 17:53

    基于ArkTS語言的OpenHarmony APP應用開發(fā)圖片處理

    、@ohos.multimedia.image 本模塊提供圖片處理效果,包括通過屬性創(chuàng)建PixelMap、讀取圖像像素數(shù)據(jù)、讀取區(qū)域內(nèi)的圖片數(shù)據(jù)等。 詳細請參考:官方文檔 2.6、@
    發(fā)表于 09-19 14:23

    HarmonyOS API Version 7版本特性說明

    收藏、回收站等功能。@ohos.multimedia.image提供圖片的解碼、打包、位圖處理等功能。以上就是本期全部內(nèi)容,“JS API參考文檔”。
    發(fā)表于 11-30 15:19

    HarmonyOS API Version 7版本特性說明

    、回收站等功能。@ohos.multimedia.image提供圖片的解碼、打包、位圖處理等功能。以上就是本期全部內(nèi)容。
    發(fā)表于 12-01 10:35

    鴻蒙開源第三方組件資料合集

    1、鴻蒙開源第三方組件——日志工具組件Timber_ohosTimber_ohos是一個帶有小型可擴展API的日志工具組件,它可以給開發(fā)者提供統(tǒng)一的API接口,來記錄不同類型的日志,幫
    發(fā)表于 03-23 09:53

    ImageKnife組件,讓小白也能輕松搞定圖片開發(fā)

    \\\'@ohos.multimedia.image\\\'導入ArkUI開發(fā)框架的圖片能力,并調(diào)用createImageSource()方法獲取,實現(xiàn)代碼如下: import image
    發(fā)表于 04-28 11:05

    基于安卓平臺的圖片裁切組件已實現(xiàn)鴻蒙化遷移和重構(gòu)

    ? 基于安卓平臺的圖片裁切組件 crop_image_layout,實現(xiàn)了鴻蒙化遷移和重構(gòu),代碼已經(jīng)開源,目前已經(jīng)獲得了很多人的 Star 和 Fork ,歡迎各位下載使用并提出寶貴意見
    的頭像 發(fā)表于 11-10 09:22 ?1470次閱讀
    基于安卓平臺的<b class='flag-5'>圖片</b>裁切組件已實現(xiàn)<b class='flag-5'>鴻蒙</b>化遷移和重構(gòu)

    鴻蒙HarmonyOS引用圖片的方法

    前言 Image通過調(diào)用接口來創(chuàng)建,接口調(diào)用形式如下: ? Image(src: string | Resource | media.PixelMap) ? 該
    的頭像 發(fā)表于 02-01 14:35 ?779次閱讀
    <b class='flag-5'>鴻蒙</b>HarmonyOS引用<b class='flag-5'>圖片</b>的方法

    鴻蒙開發(fā)圖形圖像——@ohos.effectKit (圖像效果)

    ? ? import effectKit from '@ohos.effectKit'; ? ? effectKit.createEffect createEffect(source: image.Pix
    的頭像 發(fā)表于 02-22 16:08 ?284次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b>圖形圖像——@<b class='flag-5'>ohos</b>.effectKit (圖像效果)

    鴻蒙開發(fā)UI界面——@ohos.mediaquery (媒體查詢)

    導入模塊 ? import mediaquery from '@ohos.mediaquery' ? mediaquery.matchMediaSync matchMediaSync
    的頭像 發(fā)表于 02-22 16:46 ?620次閱讀

    鴻蒙開發(fā)實戰(zhàn):【文件管理】

    .fileio]?、[@ohos.file.fs]、[@ohos.app.ability.contextConstant] 等接口,實現(xiàn)了增添文件、刪除文件、查找指定類型文件文件、復制并移動文件、切換加密分區(qū)和預覽
    的頭像 發(fā)表于 03-20 21:57 ?507次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b>實戰(zhàn):【文件管理】

    鴻蒙開發(fā)接口媒體:【@ohos.multimedia.media (媒體服務)】

    媒體子系統(tǒng)為開發(fā)者提供一套簡單且易于理解的接口,使得開發(fā)者能夠方便接入系統(tǒng)并使用系統(tǒng)的媒體資源。
    的頭像 發(fā)表于 06-06 11:03 ?548次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>媒體</b>:【@<b class='flag-5'>ohos.multimedia</b>.media (<b class='flag-5'>媒體</b>服務)】

    鴻蒙開發(fā)接口媒體:【@ohos.multimedia.medialibrary (媒體庫管理)】

    獲取媒體庫的實例,用于訪問和修改用戶等個人媒體數(shù)據(jù)信息(如音頻、視頻、圖片、文檔等)。
    的頭像 發(fā)表于 06-03 11:52 ?935次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>接口</b><b class='flag-5'>媒體</b>:【@<b class='flag-5'>ohos.multimedia</b>.medialibrary (<b class='flag-5'>媒體</b>庫管理)】