diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h
index 67d972adf0b506d2c1961fcad25b835fd64e85c6..3f0070aba5684533975149550535b5c075a191ac 100644
--- a/multimedia/image_framework/include/image/image_common.h
+++ b/multimedia/image_framework/include/image/image_common.h
@@ -179,6 +179,12 @@ typedef enum {
* @since 15
*/
IMAGE_LOCK_UNLOCK_FAILED = 7600303,
+ /**
+ * @error unsupported allocator mode, e.g., use share memory to create a HDR image as only
+ * DMA supported hdr metadata.
+ * @since 20
+ */
+ IMAGE_ALLOCATOR_MODE_UNSUPPROTED = 7600501,
/** unknown error */
IMAGE_UNKNOWN_ERROR = 7600901,
/** decode data source exception */
@@ -230,6 +236,32 @@ typedef enum {
FRAGMENT_METADATA = 2,
} Image_MetadataType;
+/**
+ * @brief Type of allocator used to allocate memory of a PixelMap.
+ *
+ * @since 20
+ */
+typedef enum {
+ /**
+ * The system determines which memory to use to create the PixelMap.
+ *
+ * @since 20
+ */
+ IMAGE_ALLOCATOR_MODE_AUTO = 0,
+ /**
+ * Use DMA buffer to create the PixelMap.
+ *
+ * @since 20
+ */
+ IMAGE_ALLOCATOR_MODE_DMA = 1,
+ /**
+ * Use share memory to create the PixelMap.
+ *
+ * @since 20
+ */
+ IMAGE_ALLOCATOR_MODE_SHARED_MEMORY = 2,
+} IMAGE_ALLOCATOR_MODE;
+
/**
* @brief Creates a PictureMetadata object.
*
diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h
index 1fa825babfacc4b023c3723d85738ea176de5e9f..503e48bb2764c176da6099e516f6c377f6cfefd0 100644
--- a/multimedia/image_framework/include/image/pixelmap_native.h
+++ b/multimedia/image_framework/include/image/pixelmap_native.h
@@ -576,6 +576,18 @@ Image_ErrorCode OH_PixelmapImageInfo_GetWidth(OH_Pixelmap_ImageInfo *info, uint3
*/
Image_ErrorCode OH_PixelmapImageInfo_GetHeight(OH_Pixelmap_ImageInfo *info, uint32_t *height);
+/**
+ * @brief Get alphaMode number for imageinfo struct.
+ *
+ * @param info The imageinfo pointer will be operated.
+ * @param alphaMode The number of imageinfo alphaMode.
+ * @return Image functions result code.
+ * {@link IMAGE_SUCCESS} if the execution is successful.
+ * {@link IMAGE_BAD_PARAMETER} pixelmapNative is nullptr, or pixelmapNapi is not a pixelmap.
+ * @since 20
+ */
+Image_ErrorCode OH_PixelmapImageInfo_GetAlphaMode(OH_Pixelmap_ImageInfo *info, int32_t *alphaMode);
+
/**
* @brief Get rowStride number for imageinfo struct.
*
@@ -639,6 +651,30 @@ Image_ErrorCode OH_PixelmapImageInfo_Release(OH_Pixelmap_ImageInfo *info);
Image_ErrorCode OH_PixelmapNative_CreatePixelmap(uint8_t *data, size_t dataLength,
OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
+/**
+ * @brief Creates a pixelmap based on options {@link OH_Pixelmap_InitializationOptions}, the memory type used by the
+ * pixelmap can be specified by allocatorType {@link IMAGE_ALLOCATOR_MODE}. 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 data Input color buffer in BGRA_8888 format by default.
+ * @param dataLength Length of input buffer in bytes.
+ * @param options Pixelmap initialization properties including size, pixel format, alpha type, and editable flags.
+ * @param allocator Indicate which memory type will be used by the returned pixelmap.
+ * @param pixelmap Output parameter receiving the created pixelmap object pointer.
+ * @return Function result code:
+ * {@link IMAGE_SUCCESS} If the operation is successful.
+ * {@link IMAGE_BAD_PARAMETER} If the param is nullptr or invalid.
+ * {@link IMAGE_TOO_LARGE} too large data or image.
+ * {@link IMAGE_UNSUPPORTED_OPERATION} unsupported operations.
+ * {@link IMAGE_DMA_OPERATION_FAILED} DMA operation failed.
+ * {@link IMAGE_ALLOCATOR_MODE_UNSUPPROTED} unsupported allocator mode, e.g.,
+ * use share memory to create a HDR image as only DMA supported hdr metadata.
+ * @since 20
+ */
+Image_ErrorCode OH_PixelmapNative_CreatePixelmapUsingAllocator(uint8_t *data, size_t dataLength,
+ OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap);
+
/**
* @brief Convert a native PixelMap object to PixelMap napi object.
*
@@ -886,6 +922,27 @@ Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixel
Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(
OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
+/**
+ * @brief Creates a empty pixelmap based on options {@link OH_Pixelmap_InitializationOptions}, the memory type used by the
+ * pixelmap can be specified by allocatorType {@link IMAGE_ALLOCATOR_MODE}. 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 options Pixelmap initialization properties including size, pixel format, alpha type, and editable flags.
+ * @param allocator Indicate which memory type will be used by the returned pixelmap.
+ * @param pixelmap Output parameter receiving the created pixelmap object pointer.
+ * @return Function result code:
+ * {@link IMAGE_SUCCESS} If the operation is successful.
+ * {@link IMAGE_BAD_PARAMETER} If the param is nullptr or invalid.
+ * {@link IMAGE_TOO_LARGE} too large data or image.
+ * {@link IMAGE_UNSUPPORTED_OPERATION} unsupported operations.
+ * {@link IMAGE_ALLOCATOR_MODE_UNSUPPROTED} unsupported allocator mode, e.g., use
+ * share memory to create a HDR image as only DMA supported hdr metadata.
+ * @since 20
+ */
+Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator(
+ OH_Pixelmap_InitializationOptions *options, IMAGE_ALLOCATOR_MODE allocator, OH_PixelmapNative **pixelmap);
+
/**
* @brief Get metadata.
*
diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json
index 68d85046276151ae05e2923ec77bb88316355363..f52699ef6d0da891a2527337596a9dc8098f80ab 100644
--- a/multimedia/image_framework/libpixelmap.ndk.json
+++ b/multimedia/image_framework/libpixelmap.ndk.json
@@ -15,6 +15,10 @@
"first_introduced": "12",
"name": "OH_PixelmapInitializationOptions_GetHeight"
},
+ {
+ "first_introduced": "20",
+ "name": "OH_PixelmapImageInfo_GetAlphaMode"
+ },
{
"first_introduced": "12",
"name": "OH_PixelmapInitializationOptions_SetHeight"
@@ -99,6 +103,10 @@
"first_introduced": "12",
"name": "OH_PixelmapNative_CreatePixelmap"
},
+ {
+ "first_introduced": "20",
+ "name": "OH_PixelmapNative_CreatePixelmapUsingAllocator"
+ },
{
"first_introduced": "12",
"name": "OH_PixelmapNative_ReadPixels"
@@ -171,6 +179,10 @@
"first_introduced": "12",
"name": "OH_PixelmapNative_CreateEmptyPixelmap"
},
+ {
+ "first_introduced": "20",
+ "name": "OH_PixelmapNative_CreateEmptyPixelmapUsingAllocator"
+ },
{
"first_introduced": "12",
"name": "OH_PixelmapNative_GetMetadata"