Introduction to the Image_NativeModule Structs
This topic describes certain structs provided by the Image_NativeModule module. For details about other structs, see the API Reference.
OH_ImageNative Struct
OH_ImageNative is the image object struct encapsulated at the native layer. The struct cannot be directly operated. Instead, its fields must be operated by calling functions. The table below describes the content and operation mode of the OH_ImageNative struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| Image_Size | imageSize | Image size. | OH_ImageNative_GetImageSize | Obtains the image size of an OH_ImageNative object. |
| uint32_t | types | Component type, which is used to describe the image's color component. | OH_ImageNative_GetComponentTypes | Obtains the component types of an OH_ImageNative object. |
| OH_NativeBuffer | nativeBuffer | Component buffer. | OH_ImageNative_GetByteBuffer | Obtains the buffer corresponding to a component type in an OH_ImageNative object. |
| size_t | bufferSize | Buffer size. | OH_ImageNative_GetBufferSize | Obtains the size of the buffer corresponding to a component type in an OH_ImageNative object. |
| int32_t | rowStride | Row stride. | OH_ImageNative_GetRowStride | Obtains the row stride corresponding to a component type in an OH_ImageNative object. |
| int32_t | pixelStride | Pixel stride. | OH_ImageNative_GetPixelStride | Obtains the pixel stride corresponding to a component type in an OH_ImageNative object. |
You can run OH_ImageNative_Release to release an OH_ImageNative object.
OH_ImagePackerNative Struct
OH_ImagePackerNative is the image packer struct encapsulated at the native layer. The struct cannot be directly operated. Instead, its fields must be operated by calling functions. The table below describes the content and operation mode of the OH_ImagePackerNative struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| OH_ImageSourceNative | imageSource | Image source. | OH_ImagePackerNative_PackToDataFromImageSource | Encodes an image source into data in a given format. |
| OH_PixelmapNative | pixelmap | PixelMap at the native layer. | OH_ImagePackerNative_PackToDataFromPixelmap | Encodes a PixelMap into data in a given format. |
| int32_t | imagesourceFd | File descriptor of an image source. | OH_ImagePackerNative_PackToFileFromImageSource | Encodes an image source into a file. |
| int32_t | pixelmapFd | File descriptor of a PixelMap. | OH_ImagePackerNative_PackToFileFromPixelmap | Encodes a PixelMap into a file. |
You can run OH_ImagePackerNative_Create to create an OH_ImagePackerNative object.
You can run OH_ImagePackerNative_Release to release an OH_ImagePackerNative object.
OH_PackingOptions Struct
OH_PackingOptions is the image packing option struct encapsulated at the native layer. The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.
You can run OH_PackingOptions_Create to create an OH_PackingOptions object.
You can run OH_PackingOptions_Release to release an OH_PackingOptions object.
The table below describes the content and operation mode of the OH_PackingOptions struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| Image_MimeType | mimeType | MIME type. | OH_PackingOptions_GetMimeType | Obtains the MIME type. |
| Image_MimeType | mimeType | MIME type. | OH_PackingOptions_SetMimeType | Sets the MIME type. |
| uint32_t | quality | Encoding quality. | OH_PackingOptions_GetQuality | Obtains the encoding quality. |
| uint32_t | quality | Encoding quality. | OH_PackingOptions_SetQuality | Sets the encoding quality. |
| int32_t | desiredDynamicRange | Desired dynamic range. | OH_PackingOptions_GetDesiredDynamicRange | Obtains the desired dynamic range during encoding. |
| int32_t | desiredDynamicRange | Desired dynamic range. | OH_PackingOptions_SetDesiredDynamicRange | Sets the desired dynamic range during encoding. |
OH_ImageReceiverNative Struct
OH_ImageReceiverNative is the image receiver struct encapsulated at the native layer. The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.
You can run OH_ImageReceiverNative_Create to create an OH_ImageReceiverNative object.
You can run OH_ImageReceiverNative_Release to release an OH_ImageReceiverNative object.
The table below describes the content and operation mode of the OH_ImageReceiverNative struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| uint64_t | surfaceId | Surface ID of the receiver. | OH_ImageReceiverNative_GetReceivingSurfaceId | Obtains the receiver ID of an OH_ImageReceiverNative object. |
| OH_ImageNative | image | Image at the native layer. | OH_ImageReceiverNative_ReadLatestImage | Obtains the latest image through an OH_ImageReceiverNative object. |
| OH_ImageNative | image | Image at the native layer. | OH_ImageReceiverNative_ReadNextImage | Obtains the next image through an OH_ImageReceiverNative object. |
| OH_ImageReceiver_OnCallback | callback | Callback function of the image receiver. | OH_ImageReceiverNative_On | Registers an OH_ImageReceiver_OnCallback. |
| OH_ImageReceiver_OnCallback | callback | Callback function of the image receiver. | OH_ImageReceiverNative_Off | Unregisters an OH_ImageReceiver_OnCallback. |
| Image_Size | size | Size of an image receiver. | OH_ImageReceiverNative_GetSize | Obtains the size of an OH_ImageReceiverNative. |
| int32_t | capacity | Capacity of an image receiver. | OH_ImageReceiverNative_GetCapacity | Obtains the capacity of an OH_ImageReceiverNative. |
OH_ImageReceiverOptions Struct
OH_ImageReceiverOptions is the image receiver option setter struct encapsulated at the native layer. It is used to pass parameters during the creation of an OH_ImageReceiverNative object. The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.
You can run OH_ImageReceiverOptions_Create to create an OH_ImageReceiverOptions object.
You can run OH_ImageReceiverOptions_Release to release an OH_ImageReceiverOptions object.
The table below describes the content and operation mode of the OH_ImageReceiverOptions struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| Image_Size | size | Image size. | OH_ImageReceiverOptions_GetSize | Obtains the image size of an OH_ImageReceiverOptions object. |
| Image_Size | size | Image size. | OH_ImageReceiverOptions_SetSize | Sets the image size for an OH_ImageReceiverOptions object. |
| int32_t | capacity | Capacity of the image buffer. | OH_ImageReceiverOptions_GetCapacity | Obtains the capacity of an OH_ImageReceiverOptions object. |
| int32_t | capacity | Capacity of the image buffer. | OH_ImageReceiverOptions_SetCapacity | Sets the capacity for an OH_ImageReceiverOptions object. |
OH_ImageSourceNative Struct
OH_ImageSourceNative is the image source struct encapsulated at the native layer and is used to create image data. The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.
You can create an OH_ImageSourceNative object in multiple ways, as described below.
| Function | Description |
|---|---|
| OH_ImageSourceNative_CreateFromUri | Creates an OH_ImageSourceNative object based on a URI. |
| OH_ImageSourceNative_CreateFromFd | Creates an OH_ImageSourceNative object based on a file descriptor. |
| OH_ImageSourceNative_CreateFromData | Creates an OH_ImageSourceNative object based on buffer data. |
| OH_ImageSourceNative_CreateFromRawFile | Creates an OH_ImageSourceNative object by using the raw file descriptor of an image resource file. |
| OH_ImageSourceNative_CreatePixelmap | Creates an OH_PixelmapNative object based on image decoding parameters. |
| OH_ImageSourceNative_CreatePixelmapList | Creates an array of OH_PixelmapNative objects based on image decoding parameters. |
You can run OH_ImageSourceNative_Release to release an OH_ImageSourceNative object.
The table below describes the content and operation mode of the OH_ImageSourceNative struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| int32_t | delayTimeList | Image delay time list. | OH_ImageSourceNative_GetDelayTimeList | Obtains the image delay time list. |
| OH_ImageSource_Info | info | Image source information. | OH_ImageSourceNative_GetImageInfo | Obtains the information about an image with a given index. |
| Image_String | value | Configuration item. | OH_ImageSourceNative_GetImageProperty | Obtains the value of an image property. |
| Image_String | value | Configuration item. | OH_ImageSourceNative_ModifyImageProperty | Modifies the value of an image property. |
| uint32_t | frameCount | Number of frames | OH_ImageSourceNative_GetFrameCount | Obtains the number of image frames. |
OH_ImageSource_Info Struct
OH_ImageSource_Info is the image source information struct encapsulated at the native layer. The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.
You can run OH_ImageSourceInfo_Create to create an OH_ImageSource_Info object.
You can run OH_ImageSourceInfo_Release to release an OH_ImageSource_Info object.
The table below describes the content and operation mode of the OH_ImageSource_Info struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| uint32_t | width | Image width. | OH_ImageSourceInfo_GetWidth | Obtains the image width. |
| uint32_t | height | Image height. | OH_ImageSourceInfo_GetHeight | Obtains the image height. |
| bool | isHdr | Dynamic range. | OH_ImageSourceInfo_GetDynamicRange | Obtains the dynamic range of an image. |
OH_DecodingOptions Struct
OH_DecodingOptions is the decoding options struct encapsulated at the native layer. This struct is used to set decoding options and is passed in as an input parameter for creating a PixelMap. For details, see OH_ImageSourceNative_CreatePixelmap.
The struct cannot be directly operated. Instead, functions must be called to create and release the struct and operate the fields in the struct.
You can run OH_DecodingOptions_Create to create an OH_DecodingOptions object.
You can run OH_DecodingOptions_Release to release an OH_DecodingOptions object.
The table below describes the content and operation mode of the OH_DecodingOptions struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| int32_t | pixelFormat | Pixel format. | OH_DecodingOptions_GetPixelFormat | Obtains the pixel format. |
| int32_t | pixelFormat | Pixel format. | OH_DecodingOptions_SetPixelFormat | Sets the pixel format. |
| uint32_t | index | Index of the image to decode. | OH_DecodingOptions_GetIndex | Obtains the index of an image. |
| uint32_t | index | Index of the image to decode. | OH_DecodingOptions_SetIndex | Sets the index for an image. |
| float | rotate | Rotation angle. | OH_DecodingOptions_GetRotate | Obtains the rotation degree. |
| float | rotate | Rotation angle. | OH_DecodingOptions_SetRotate | Sets the rotation angle. |
| Image_Size | desiredSize | Desired output size. | OH_DecodingOptions_GetDesiredSize | Obtains the desired output size. |
| Image_Size | desiredSize | Desired output size. | OH_DecodingOptions_SetDesiredSize | Sets the desired output size. |
| Image_Region | desiredRegion | Region to decode. | OH_DecodingOptions_GetDesiredRegion | Obtains the region to decode. |
| Image_Region | desiredRegion | Region to decode. | OH_DecodingOptions_SetDesiredRegion | Sets the region to decode. |
| int32_t | desiredDynamicRange | Desired dynamic range. | OH_DecodingOptions_GetDesiredDynamicRange | Obtains the desired dynamic range configured during decoding. |
| int32_t | desiredDynamicRange | Desired dynamic range. | OH_DecodingOptions_SetDesiredDynamicRange | Sets the desired dynamic range during decoding. |
OH_PixelmapNative Struct
OH_PixelmapNative is an uncompressed PixelMap format struct encapsulated at the native layer after images are decoded.
You can run OH_PixelmapNative_CreatePixelmap to create an OH_PixelmapNative object. By default, the BGRA_8888 format is used to process data.
You can run OH_PixelmapNative_Release to release an OH_PixelmapNative object.
The table below describes the content and operation mode of the OH_PixelmapNative struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| uint8_t | data | Image pixel data. | OH_PixelmapNative_ReadPixels | Reads the image pixel data and writes the data to an ArrayBuffer. |
| uint8_t | data | Image pixel data. | OH_PixelmapNative_WritePixels | Reads the image pixel data in the buffer and writes the data to a PixelMap. |
| OH_Pixelmap_ImageInfo | imageInfo | Image information. | OH_PixelmapNative_GetImageInfo | Obtains the image information. |
| float | alphaRate | Opacity rate. | OH_PixelmapNative_Opacity | Sets the opacity rate to enable the PixelMap to achieve the corresponding opacity effect. |
| float, float, | scaleX, scaleY | Scale ratios along the X axis and Y axis, respectively. | OH_PixelmapNative_Scale | Scales an image based on a given width and height. |
| float, float | x, y | Distances to translate along the X axis and Y axis, respectively. | OH_PixelmapNative_Translate | Translates an image based on given coordinates. |
| float | angle | Rotation angle. | OH_PixelmapNative_Rotate | Rotates an image based on a given angle. |
| bool, bool | shouldFilpHorizontally, shouldFilpVertically | Whether to flip horizontally or vertically | OH_PixelmapNative_Flip | Flips an image based on a given angle. |
| Image_Region | region | Cropping region. | OH_PixelmapNative_Crop | Crops a PixelMap based on a given size. |
OH_Pixelmap_InitializationOptions Struct
OH_Pixelmap_InitializationOptions is the initialization option struct encapsulated at the native layer. It is used to set the initialization parameters for a PixelMap.
You can run OH_PixelmapInitializationOptions_Create to create an OH_Pixelmap_InitializationOptions object.
You can run OH_PixelmapInitializationOptions_Release to release an OH_Pixelmap_InitializationOptions object.
The table below describes the content and operation mode of the OH_Pixelmap_InitializationOptions struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| uint32_t | width | Image width. | OH_PixelmapInitializationOptions_GetWidth | Obtains the image width. |
| uint32_t | width | Image width. | OH_PixelmapInitializationOptions_SetWidth | Sets the image width. |
| uint32_t | height | Image height. | OH_PixelmapInitializationOptions_GetHeight | Obtains the image height. |
| uint32_t | height | Image height. | OH_PixelmapInitializationOptions_SetHeight | Sets the image height. |
| int32_t | pixelFormat | Pixel format. | OH_PixelmapInitializationOptions_GetPixelFormat | Obtains the pixel format. |
| int32_t | pixelFormat | Pixel format. | OH_PixelmapInitializationOptions_SetPixelFormat | Sets the pixel format. |
| int32_t | alphaType | Alpha type. | OH_PixelmapInitializationOptions_GetAlphaType | Obtains the alpha type. |
| int32_t | alphaType | Alpha type. | OH_PixelmapInitializationOptions_SetAlphaType | Sets the alpha type. |
OH_Pixelmap_ImageInfo Struct
OH_Pixelmap_ImageInfo is the image information struct encapsulated at the native layer. It stores the width, height, row stride, pixel format, and HDR of an image.
You can run OH_PixelmapImageInfo_Create to create an OH_Pixelmap_ImageInfo object.
You can run OH_PixelmapImageInfo_Release to release an OH_Pixelmap_ImageInfo object.
The table below describes the content and operation mode of the OH_Pixelmap_ImageInfo struct.
| Field Type | Field Name | Field Description | Operation Function | Function Description |
|---|---|---|---|---|
| uint32_t | width | Image width. | OH_PixelmapImageInfo_GetWidth | Obtains the image width. |
| uint32_t | height | Image height. | OH_PixelmapImageInfo_GetHeight | Obtains the image height. |
| uint32_t | rowStride | Row stride. | OH_PixelmapImageInfo_GetRowStride | Obtains the row stride. |
| int32_t | pixelFormat | Pixel format. | OH_PixelmapImageInfo_GetPixelFormat | Obtains the pixel format. |
| int32_t | alphaType | Alpha type. | OH_PixelmapImageInfo_GetAlphaType | Obtains the alpha type. |
| bool | isHdr | Dynamic range. | OH_PixelmapImageInfo_GetDynamicRange | Obtains the dynamic range of a PixelMap. |