From 85bfbf3b06ea32ce248f5b8feb23724850692b2e Mon Sep 17 00:00:00 2001 From: linanxian Date: Wed, 15 Jan 2025 07:11:06 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20VideoProcessingEngine=20ts?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: linanxian --- ...ohos.multimedia.videoprocessingengine.d.ts | 219 ++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 api/@ohos.multimedia.videoprocessingengine.d.ts diff --git a/api/@ohos.multimedia.videoprocessingengine.d.ts b/api/@ohos.multimedia.videoprocessingengine.d.ts new file mode 100644 index 0000000000..b91d6e650f --- /dev/null +++ b/api/@ohos.multimedia.videoprocessingengine.d.ts @@ -0,0 +1,219 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file Provides the capability of image quality processing. + * @kit ImageKit + */ + +import image from './@ohos.multimedia.image'; + +/** + * This module provides the capability of content processing for images, including image scaling. + * @namespace videoprocessingengine + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ +declare namespace videoprocessingengine { + /** + * Levels of processing quality for detail enhancement. + * @enum {number} + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + enum QualityLevel { + /** + * No detail enhancement. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + NONE = 0, + /** + * A low level of detail enhancement quality but with a fast speed. It's the default level. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + LOW = 1, + /** + * A medium level of detail enhancement quality. Its speed is between the low setting and high setting. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + MEDIUM = 2, + /** + * A high level of detail enhancement quality but with a relatively slow speed. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + HIGH = 3 + } + + /** + * Provides the ImageProcessor type, including the processing function. + * @typedef ImageProcessor + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + interface ImageProcessor { + /** + * The function generate the destinationImage from sourceImage with necessary scaling operation + *
according to width and height. Different levels of scaling methonds are provided to + *
balance performance and image quality. This method uses a promise to return the result. + * @param { image.PixelMap } sourceImage - The source pixelmap. + * @param { number } width - The zoom value of width. + * @param { number } height - The zoom value of height. + * @param { QualityLevel } [level] - The quality level. + * @returns { Promise } A Promise instance used to return the PixelMap object. + * @throws { BusinessError } 29200007 - Out of memory. + * @throws { BusinessError } 29200009 - Input value is invalid. This error is returned for + *
all of the following error conditions: + *
1 - Invalid input or output image buffer - The image buffer width(height) + *
is too large or colorspace is incorrect. + *
2 - Invalid parameter - The parameter does not contain valid information, + *
such as detail enhancer level is incorrect. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + enhanceDetail(sourceImage: image.PixelMap, width: number, height: number, level?: QualityLevel): Promise; + + /** + * The function generate the destinationImage from sourceImage with necessary scaling operation + *
according to width and height. Different levels of scaling methonds are provided to + *
balance performance and image quality. + * @param { image.PixelMap } sourceImage - The source pixelmap. + * @param { number } width - The zoom value of width. + * @param { number } height - The zoom value of height. + * @param { QualityLevel } [level] - The quality level. + * @returns { image.PixelMap } Returns the destination pixelmap instance . + *
if the operation is successful; Otherwise, return undefined. + * @throws { BusinessError } 29200004 - Failed to process image buffer. For example, the processing times out. + * @throws { BusinessError } 29200007 - Out of memory. + * @throws { BusinessError } 29200009 - Input value is invalid. This error is returned for + *
all of the following error conditions: + *
1 - Invalid input or output image buffer - The image buffer width(height) + *
is too large or colorspace is incorrect. + *
2 - Invalid parameter - The parameter does not contain valid information, + *
such as detail enhancer level is incorrect. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + enhanceDetailSync(sourceImage: image.PixelMap, width: number, height: number, level?: QualityLevel): image.PixelMap; + + /** + * The function generate the destinationImage from sourceImage with necessary scaling operation + *
according to the zoom ratio. Different levels of scaling methonds are provided to + *
balance performance and image quality. This method uses a promise to return the result. + * @param { image.PixelMap } sourceImage - The source pixelmap. + * @param { number } scale - The zoom ratio. + * @param { QualityLevel } [level] - The quality level. + * @returns { Promise } A Promise instance used to return the PixelMap object. + * @throws { BusinessError } 29200007 - Out of memory. + * @throws { BusinessError } 29200009 - Input value is invalid. This error is returned for + *
all of the following error conditions: + *
1 - Invalid input or output image buffer - The image buffer width(height) + *
is too large or colorspace is incorrect. + *
2 - Invalid parameter - The parameter does not contain valid information, + *
such as detail enhancer level is incorrect. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + enhanceDetail(sourceImage: image.PixelMap, scale: number, level?: QualityLevel): Promise; + + /** + * The function generate the destinationImage from sourceImage with necessary scaling operation + *
according to the zoom ratio. Different levels of scaling methonds are provided to + *
balance performance and image quality. + * @param { image.PixelMap } sourceImage - The source pixelmap. + * @param { number } scale - The zoom ratio. + * @param { QualityLevel } [level] - The quality level. + * @returns { image.PixelMap } Returns the destination pixelmap instance + *
if the operation is successful; Otherwise, return undefined. + * @throws { BusinessError } 29200004 - Failed to process image buffer. For example, the processing times out. + * @throws { BusinessError } 29200007 - Out of memory. + * @throws { BusinessError } 29200009 - Input value is invalid. This error is returned for + *
all of the following error conditions: + *
1 - Invalid input or output image buffer - The image buffer width(height) + *
is too large or colorspace is incorrect. + *
2 - Invalid parameter - The parameter does not contain valid information, + *
such as detail enhancer level is incorrect. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + enhanceDetailSync(sourceImage: image.PixelMap, scale: number, level?: QualityLevel): image.PixelMap; + } + + /** + * Initialize global environment for image processing. + * @returns { Promise } A Promise instance used to return the operation result. + * If the operation fails, an error message is returned. + * @throws { BusinessError } 29200002 - The global environment initialization for image processing failed, + *
such as failure to initialize the GPU environment. + * @throws { BusinessError } 29200006 - The operation is not permitted. This may be caused by incorrect status. + * @throws { BusinessError } 29200007 - Out of memory. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + function initializeEnvironment(): Promise; + /** + * Deinitialize global environment for image processing. + * @returns { Promise } A Promise instance used to return the operation result. + * If the operation fails, an error message is returned. + * @throws { BusinessError } 29200006 - The operation is not permitted. This may be caused by incorrect status. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + function deinitializeEnvironment(): Promise; + /** + * Create an image processing instance. + * @returns { ImageProcessor } Returns the ImageProcessor instance if + *
the operation is successful; returns null otherwise. + * @throws { BusinessError } 29200003 - Failed to create image processing instance. For example, + *
the number of instances exceeds the upper limit. + * @throws { BusinessError } 29200007 - Out of memory. + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @crossplatform + * @form + * @since 14 + */ + function create(): ImageProcessor; +} + +export default videoprocessingengine; -- Gitee