diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index a4f599be8f4e636d07925697eea905935e1738b5..9edfea08393ad4370fe19995cf296f33dcf58619 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -184,8 +184,33 @@ typedef enum { IMAGE_UNKNOWN_ERROR = 7600901, /** decode data source exception */ IMAGE_BAD_SOURCE = 7700101, + /** + * @error unsupported mime type + * @since 15 + */ + IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE = 7700102, + /** + * @error image to large + * @since 15 + */ + IMAGE_SOURCE_TOO_LARGE = 7700103, + /** + * @error unsupported allocator type, e.g., use share memory to decode a HDR image as only + * DMA supported hdr metadata. + * @since 15 + */ + IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE = 7700201, + /* @error unsupported options, e.g, cannot convert image into desired pixel format. + * @since 15 + */ + IMAGE_SOURCE_UNSUPPORTED_OPTIONS = 7700203, /** decode failed */ IMAGE_DECODE_FAILED = 7700301, + /** + * @error memory allocation failed + * @since 15 + */ + IMAGE_SOURCE_ALLOC_FAILED = 7700302, /** encode failed */ IMAGE_ENCODE_FAILED = 7800301, } Image_ErrorCode; diff --git a/multimedia/image_framework/include/image/image_source_native.h b/multimedia/image_framework/include/image/image_source_native.h index 7e54b94ef5f383016d0166855b7eb20ffd07396e..8c40a0413da53595582772996642050a1dc2be8e 100644 --- a/multimedia/image_framework/include/image/image_source_native.h +++ b/multimedia/image_framework/include/image/image_source_native.h @@ -14,7 +14,7 @@ */ /** - * @addtogroup image + * @addtogroup ImageSourceNative * @{ * * @brief Provides APIs for access to the image interface. @@ -98,6 +98,26 @@ typedef enum { IMAGE_DYNAMIC_RANGE_HDR = 2, } IMAGE_DYNAMIC_RANGE; +/** + * @brief Type of allocator used to allocate memory of a PixelMap.. + * + * @since 16 + */ +typedef enum { + /* + * The system determines which memory to use to create the PixelMap. + */ + IMAGE_ALLOCATOR_TYPE_AUTO = 0, + /* + * Use DMA buffer to create the PixelMap. + */ + IMAGE_ALLOCATOR_TYPE_DMA = 1, + /* + * Use share memory to create the PixelMap. + */ + IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY = 2, +} IMAGE_ALLOCATOR_TYPE; + /** * @brief Create a pointer for OH_ImageSource_Info struct. * @@ -360,6 +380,35 @@ Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile(RawFileDescriptor *rawFil Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative **pixelmap); +/** + * @brief Creates a PixelMap based on decoding parameters {@link OH_DecodingOptions}, the memory type used by the + * PixelMap can be specified by allocatorType {@link IMAGE_ALLOCATOR_TYPE}. By default, the system selects the memory + * type based on the image type, image size, platform capability, etc. When processing the PixelMap returned by this + * interface, please always consider the impact of stride. + * + * @param source Image Source. + * @param options Decoding parameters, such as the size, pixel format, and color space of the pixelMap. + * For details, see {@link OH_DecodingOptions}. + * @param allocator Indicate which memory type will be used by the returned PixelMap. + * @param pixelmap Decoded Pixelmap object. + * @return Error code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. + * {@link IMAGE_BAD_SOURCE} data source exception. + * {@link IMAGE_SOURCE_UNSUPPORTED_MIMETYPE} unsupported mime type. + * {@link IMAGE_SOURCE_TOO_LARGE} image to large. + * {@link IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE} unsupported allocator type, + * e.g., use share memory to decode a HDR image as only DMA supported hdr metadata. + * {@link IMAGE_SOURCE_UNSUPPORTED_OPTIONS} unsupported options, + * e.g, cannot convert image into desired pixel format. + * {@link IMAGE_DECODE_FAILED} decode failed. + * {@link IMAGE_SOURCE_ALLOC_FAILED} memory allocation failed. + * @since 16 + */ +Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator(OH_ImageSourceNative *source, + OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap); + + /** * @brief Decodes an void pointer * the Pixelmap objects at the C++ native layer diff --git a/multimedia/image_framework/libimage_source.ndk.json b/multimedia/image_framework/libimage_source.ndk.json index 37312763efbe5c189c070d93a8d3e90281c6eea7..fd5d4e30aae77419941437b12e4c577937e12429 100644 --- a/multimedia/image_framework/libimage_source.ndk.json +++ b/multimedia/image_framework/libimage_source.ndk.json @@ -95,6 +95,10 @@ "first_introduced": "12", "name": "OH_ImageSourceNative_CreatePixelmap" }, + { + "first_introduced": "16", + "name": "OH_ImageSourceNative_CreatePixelmapUsingAllocator" + }, { "first_introduced": "12", "name": "OH_ImageSourceNative_CreatePixelmapList"