harmony 鸿蒙pixelmap_native.h

  • 2025-06-12
  • 浏览 (5)

pixelmap_native.h

Overview

The pixelmap_native.h file declares the APIs for accessing a PixelMap.

Library: libpixelmap.so

File to include: <multimedia/image_framework/image/pixelmap_native.h>

System capability: SystemCapability.Multimedia.Image.Core

Since: 12

Related module: Image_NativeModule

Summary

Structs

Name Description
struct OH_Pixelmap_HdrStaticMetadata Describes the static metadata values available for the key HDR_STATIC_METADATA.
struct OH_Pixelmap_HdrDynamicMetadata Describes the dynamic metadata values available for the key DR_DYNAMIC_METADATA.
struct OH_Pixelmap_HdrGainmapMetadata Describes the gain map metadata values available for the key HDR_GAINMAP_METADATA. For details, see ISO 21496-1.
struct OH_Pixelmap_HdrMetadataValue Describes the HDR metadata values used by the PixelMap and available for the key OH_Pixelmap_HdrMetadataKey.

Types

Name Description
typedef struct OH_PixelmapNative OH_PixelmapNative Defines a struct for the PixelMap, which is used to perform operations related to a PixelMap.
typedef struct OH_NativeBuffer OH_NativeBuffer Defines a struct for the native buffer, which is used to perform operations related to the native buffer.
typedef struct OH_NativeColorSpaceManager OH_NativeColorSpaceManager Defines a struct for the native color space manager, which is used to perform operations related to the native color space manager.
typedef struct OH_Pixelmap_HdrStaticMetadata OH_Pixelmap_HdrStaticMetadata Defines a struct for the static metadata values available for the key HDR_STATIC_METADATA.
typedef struct OH_Pixelmap_HdrDynamicMetadata OH_Pixelmap_HdrDynamicMetadata Defines a struct for the dynamic metadata values available for the key DR_DYNAMIC_METADATA.
typedef struct OH_Pixelmap_HdrGainmapMetadata OH_Pixelmap_HdrGainmapMetadata Defines a struct for the gain map metadata values available for the key HDR_GAINMAP_METADATA. For details, see ISO 21496-1.
typedef struct OH_Pixelmap_HdrMetadataValue OH_Pixelmap_HdrMetadataValue Defines a struct for the HDR metadata values used by the PixelMap and available for the key OH_Pixelmap_HdrMetadataKey.
typedef struct OH_Pixelmap_InitializationOptions OH_Pixelmap_InitializationOptions Defines a struct for the initialization parameters.
typedef struct OH_Pixelmap_ImageInfo OH_Pixelmap_ImageInfo Defines a struct for the image information.

Enums

Name Description
PIXELMAP_ALPHA_TYPE {
PIXELMAP_ALPHA_TYPE_UNKNOWN = 0,
PIXELMAP_ALPHA_TYPE_OPAQUE = 1,
PIXELMAP_ALPHA_TYPE_PREMULTIPLIED = 2,
PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED = 3 }
Enumerates the alpha types of a PixelMap.
PIXEL_FORMAT {
PIXEL_FORMAT_UNKNOWN = 0, PIXEL_FORMAT_ARGB_8888 = 1,
PIXEL_FORMAT_RGB_565 = 2, PIXEL_FORMAT_RGBA_8888 = 3,
PIXEL_FORMAT_BGRA_8888 = 4, PIXEL_FORMAT_RGB_888 = 5,
PIXEL_FORMAT_ALPHA_8 = 6, PIXEL_FORMAT_RGBA_F16 = 7,
PIXEL_FORMAT_NV21 = 8, PIXEL_FORMAT_NV12 = 9,
PIXEL_FORMAT_RGBA_1010102 = 10, PIXEL_FORMAT_YCBCR_P010 = 11,
PIXEL_FORMAT_YCRCB_P010 = 12
}
Enumerates the image pixel formats.
OH_PixelmapNative_AntiAliasingLevel {
OH_PixelmapNative_AntiAliasing_NONE = 0,
OH_PixelmapNative_AntiAliasing_LOW = 1,
OH_PixelmapNative_AntiAliasing_MEDIUM = 2,
OH_PixelmapNative_AntiAliasing_HIGH = 3
}
Enumerates the antialiasing levels used for scaling PixelMaps.
OH_Pixelmap_HdrMetadataKey {
HDR_METADATA_TYPE = 0,
HDR_STATIC_METADATA = 1,
HDR_DYNAMIC_METADATA = 2,
HDR_GAINMAP_METADATA = 3
}
Enumerates the keys of the HDR related metadata information used by the PixelMap. It is used in OH_PixelmapNative_SetMetadata and OH_PixelmapNative_GetMetadata.
OH_Pixelmap_HdrMetadataType {
HDR_METADATA_TYPE_NONE = 0,
HDR_METADATA_TYPE_BASE = 1,
HDR_METADATA_TYPE_GAINMAP = 2,
HDR_METADATA_TYPE_ALTERNATE = 3
}
Enumerates the HDR metadata types, which are the values of HDR_METADATA_TYPE.

Functions

Name Description
Image_ErrorCode OH_PixelmapInitializationOptions_Create (OH_Pixelmap_InitializationOptions **options) Creates the pointer to an OH_Pixelmap_InitializationOptions struct.
Image_ErrorCode OH_PixelmapInitializationOptions_GetWidth (OH_Pixelmap_InitializationOptions *options, uint32_t *width) Obtains the image width.
Image_ErrorCode OH_PixelmapInitializationOptions_SetWidth (OH_Pixelmap_InitializationOptions *options, uint32_t width) Sets the image width.
Image_ErrorCode OH_PixelmapInitializationOptions_GetHeight (OH_Pixelmap_InitializationOptions *options, uint32_t *height) Obtains the image height.
Image_ErrorCode OH_PixelmapInitializationOptions_SetHeight (OH_Pixelmap_InitializationOptions *options, uint32_t height) Sets the image height.
Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat (OH_Pixelmap_InitializationOptions *options, int32_t *pixelFormat) Obtains the pixel format.
Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat (OH_Pixelmap_InitializationOptions *options, int32_t pixelFormat) Sets the pixel format.
Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat (OH_Pixelmap_InitializationOptions *options, int32_t *srcpixelFormat) Obtains the source pixel format.
Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat (OH_Pixelmap_InitializationOptions *options, int32_t srcpixelFormat) Sets the source pixel format.
Image_ErrorCode OH_PixelmapInitializationOptions_GetRowStride (OH_Pixelmap_InitializationOptions *options, int32_t *rowStride) Obtains the row stride. The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width *Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes.
Image_ErrorCode OH_PixelmapInitializationOptions_SetRowStride (OH_Pixelmap_InitializationOptions *options, int32_t rowStride) Sets the row stride. The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width *Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes.
Image_ErrorCode OH_PixelmapInitializationOptions_GetAlphaType (OH_Pixelmap_InitializationOptions *options, int32_t *alphaType) Obtains the alpha type.
Image_ErrorCode OH_PixelmapInitializationOptions_SetAlphaType (OH_Pixelmap_InitializationOptions *options, int32_t alphaType) Sets the alpha type.
Image_ErrorCode OH_PixelmapInitializationOptions_GetEditable (OH_Pixelmap_InitializationOptions *options, bool *editable) Obtains the editable flag.
Image_ErrorCode OH_PixelmapInitializationOptions_SetEditable (OH_Pixelmap_InitializationOptions *options, bool editable) Sets the editable flag.
Image_ErrorCode OH_PixelmapInitializationOptions_Release (OH_Pixelmap_InitializationOptions *options) Releases the pointer to an OH_Pixelmap_InitializationOptions struct.
Image_ErrorCode OH_PixelmapImageInfo_Create (OH_Pixelmap_ImageInfo **info) Creates the pointer to an OH_Pixelmap_ImageInfo struct.
Image_ErrorCode OH_PixelmapImageInfo_GetWidth (OH_Pixelmap_ImageInfo *info, uint32_t *width) Obtains the image width.
Image_ErrorCode OH_PixelmapImageInfo_GetHeight (OH_Pixelmap_ImageInfo *info, uint32_t *height) Obtains the image height.
Image_ErrorCode OH_PixelmapImageInfo_GetRowStride (OH_Pixelmap_ImageInfo *info, uint32_t *rowStride) Obtains the row stride.
Image_ErrorCode OH_PixelmapImageInfo_GetPixelFormat (OH_Pixelmap_ImageInfo *info, int32_t *pixelFormat) Obtains the pixel format.
Image_ErrorCode OH_PixelmapImageInfo_GetAlphaType (OH_Pixelmap_ImageInfo *info, int32_t *alphaType) Obtains the alpha type.
Image_ErrorCode OH_PixelmapImageInfo_GetDynamicRange (OH_Pixelmap_ImageInfo *info, bool *isHdr) Obtains the dynamic range of a PixelMap.
Image_ErrorCode OH_PixelmapImageInfo_Release (OH_Pixelmap_ImageInfo *info) Releases the pointer to an OH_Pixelmap_ImageInfo struct.
Image_ErrorCode OH_PixelmapNative_CreatePixelmap (uint8_t *data, size_t dataLength, OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap) Creates a PixelMap based on properties. By default, the BGRA_8888 format is used for data processing.
Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeToNapi (napi_env env, OH_PixelmapNative *pixelmapNative, napi_value *pixelmapNapi) Converts a nativePixelMap object to a PixelMapnapi object.
Image_ErrorCode OH_PixelmapNative_ConvertPixelmapNativeFromNapi (napi_env env, napi_value pixelmapNapi, OH_PixelmapNative **pixelmapNative) Converts a PixelMapnapi object to a nativePixelMap object.
Image_ErrorCode OH_PixelmapNative_ReadPixels (OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize) Reads the pixels of a PixelMap and writes the result to an ArrayBuffer.
Image_ErrorCode OH_PixelmapNative_WritePixels (OH_PixelmapNative *pixelmap, uint8_t *source, size_t bufferSize) Reads the pixels in the buffer and writes the result to a PixelMap.
Image_ErrorCode OH_PixelmapNative_GetArgbPixels (OH_PixelmapNative *pixelmap, uint8_t *destination, size_t *bufferSize) Reads data in ARGB format from a PixelMap.
Image_ErrorCode OH_PixelmapNative_ToSdr (OH_PixelmapNative *pixelmap) Converts a PixelMap from the HDR format to the SDR format.
Image_ErrorCode OH_PixelmapNative_GetImageInfo (OH_PixelmapNative *pixelmap, OH_Pixelmap_ImageInfo *imageInfo) Obtains the image information of a PixelMap.
Image_ErrorCode OH_PixelmapNative_Opacity (OH_PixelmapNative *pixelmap, float rate) Sets the opacity rate to enable the PixelMap to achieve the corresponding opacity effect.
Image_ErrorCode OH_PixelmapNative_Scale (OH_PixelmapNative *pixelmap, float scaleX, float scaleY) Scales a PixelMap based on a given width and height.
Image_ErrorCode OH_PixelmapNative_ScaleWithAntiAliasing (OH_PixelmapNative *pixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level) Scales a PixelMap based on the specified antialiasing level, width, and height.
Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMap (OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY) Creates a PixelMap that has been resized based on the specified scale factors of the width and height.
Image_ErrorCode OH_PixelmapNative_CreateScaledPixelMapWithAntiAliasing (OH_PixelmapNative *srcPixelmap, OH_PixelmapNative **dstPixelmap, float scaleX, float scaleY, OH_PixelmapNative_AntiAliasingLevel level) Creates a PixelMap that has been resized based on the specified antialiasing level and the scale factors of the width and height.
Image_ErrorCode OH_PixelmapNative_Translate (OH_PixelmapNative *pixelmap, float x, float y) Translates a PixelMap based on given coordinates.
Image_ErrorCode OH_PixelmapNative_Rotate (OH_PixelmapNative *pixelmap, float angle) Rotates a PixelMap based on a given angle.
Image_ErrorCode OH_PixelmapNative_Flip (OH_PixelmapNative *pixelmap, bool shouldFilpHorizontally, bool shouldFilpVertically) Flips a PixelMap based on a given angle.
Image_ErrorCode OH_PixelmapNative_Crop (OH_PixelmapNative *pixelmap, Image_Region *region) Crops a PixelMap based on a given size.
Image_ErrorCode OH_PixelmapNative_Release (OH_PixelmapNative *pixelmap) Releases the pointer to an OH_PixelmapNative object. OH_PixelmapNative_Destroy is recommended.
Image_ErrorCode OH_PixelmapNative_Destroy (OH_PixelmapNative **pixelmap) Releases the pointer to an OH_PixelmapNative object.
Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat (OH_PixelmapNative *srcpixelmap, OH_PixelmapNative *dstpixelmap, const bool isPremul) Converts pixel data of a PixelMap from premultiplied alpha to non-premultiplied alpha, or vice versa.
Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap (OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap) Creates an empty PixelMap using OH_Pixelmap_InitializationOptions. The memory data is 0.
Image_ErrorCode OH_PixelmapNative_GetNativeBuffer (OH_PixelmapNative *pixelmap, OH_NativeBuffer **nativeBuffer) Obtains the NativeBuffer object from a PixelMap in the DMA memory.
Image_ErrorCode OH_PixelmapNative_GetMetadata (OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, OH_Pixelmap_HdrMetadataValue **value) Obtains the metadata.
Image_ErrorCode OH_PixelmapNative_SetMetadata (OH_PixelmapNative *pixelmap, OH_Pixelmap_HdrMetadataKey key, OH_Pixelmap_HdrMetadataValue *value) Sets the metadata.
Image_ErrorCode OH_PixelmapNative_SetColorSpaceNative (OH_PixelmapNative *pixelmap, OH_NativeColorSpaceManager *colorSpaceNative) Sets a NativeColorSpaceManager object.
Image_ErrorCode OH_PixelmapNative_GetColorSpaceNative (OH_PixelmapNative *pixelmap, OH_NativeColorSpaceManager **colorSpaceNative) Obtains a NativeColorSpaceManager object.
Image_ErrorCode OH_PixelmapNative_SetMemoryName (OH_PixelmapNative *pixelmap, char *name, size_t *size) Sets the memory name of a PixelMap.
Image_ErrorCode OH_PixelmapNative_GetByteCount (OH_PixelmapNative *pixelmap, uint32_t *byteCount) Obtains the total number of bytes occupied by all pixels in a PixelMap, excluding any memory padding.
Image_ErrorCode OH_PixelmapNative_GetAllocationByteCount (OH_PixelmapNative *pixelmap, uint32_t *allocationByteCount) Obtains the number of bytes in the memory allocated by a PixelMap to store pixels.
Image_ErrorCode OH_PixelmapNative_AccessPixels (OH_PixelmapNative *pixelmap, void **addr) Obtains the memory address where the pixels of a PixelMap are stored and locks the memory.
When the memory is locked, any attempts to alter or free the pixel data of the PixelMap will fail or be ineffective.
Image_ErrorCode OH_PixelmapNative_UnaccessPixels (OH_PixelmapNative *pixelmap) Unlocks the memory allocated to store the pixels of a PixelMap.
This function must be used together with OH_PixelmapNative_AccessPixels.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Image Kit

harmony 鸿蒙_image___native_module

harmony 鸿蒙Image_Region

harmony 鸿蒙Image_Size

harmony 鸿蒙Image_String

harmony 鸿蒙ImageEffect

harmony 鸿蒙ImageEffect_Any

harmony 鸿蒙ImageEffect_FilterDelegate

harmony 鸿蒙ImageEffect_FilterNames

harmony 鸿蒙ImageEffect_Region

0  赞