image_source_native.h
Overview
The file declares the APIs for image decoding.
File to include: <multimedia/image_framework/image/image_source_native.h>
Library: libimage_source.so
System capability: SystemCapability.Multimedia.Image.ImageSource
Since: 12
Related module: Image_NativeModule
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| OH_ImageSourceNative | OH_ImageSourceNative | Describes the image source, which is encapsulated at the native layer and is used to create image data. |
| OH_ImageSource_Info | OH_ImageSource_Info | Describes the image source information, which is 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. |
| OH_DecodingOptionsForPicture | OH_DecodingOptionsForPicture | Describes the decoding options for pictures. They are obtained by calling OH_DecodingOptionsForPicture_Create. |
| OH_DecodingOptions | OH_DecodingOptions | Describes the decoding options, which are encapsulated at the native layer. The 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. |
| OH_ImageRawData | OH_ImageRawData | Describes the raw data in an image, which is obtained through OH_ImageSourceNative_CreateImageRawData. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| IMAGE_DYNAMIC_RANGE | IMAGE_DYNAMIC_RANGE | Enumerates the desired dynamic range for decoding. |
| IMAGE_ALLOCATOR_TYPE | IMAGE_ALLOCATOR_TYPE | Enumerates the types of allocators used to allocate PixelMap memory. |
| Image_CropAndScaleStrategy | Image_CropAndScaleStrategy | Enumerates the cropping and scaling strategies when desiredSize and desiredRegion are both specified. |
Functions
Enum Description
IMAGE_DYNAMIC_RANGE
enum IMAGE_DYNAMIC_RANGE
Description
Enumerates the desired dynamic range for decoding.
Since: 12
| Enum Item | Description |
|---|---|
| IMAGE_DYNAMIC_RANGE_AUTO = 0 | Adaptive processing. |
| IMAGE_DYNAMIC_RANGE_SDR = 1 | Standard dynamic range (SDR). |
| IMAGE_DYNAMIC_RANGE_HDR = 2 | High dynamic range (HDR). |
IMAGE_ALLOCATOR_TYPE
enum IMAGE_ALLOCATOR_TYPE
Description
Enumerates the types of allocators used to allocate PixelMap memory.
Since: 15
| Enum Item | Description |
|---|---|
| IMAGE_ALLOCATOR_TYPE_AUTO = 0 | The system determines whether to use DMA memory or shared memory to create a PixelMap. |
| IMAGE_ALLOCATOR_TYPE_DMA = 1 | DMA memory is used to create a PixelMap. |
| IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY = 2 | Shared memory is used to create a PixelMap. |
Image_CropAndScaleStrategy
enum Image_CropAndScaleStrategy
Description
Enumerates the cropping and scaling strategies when desiredSize and desiredRegion are both specified.
If Image_CropAndScaleStrategy is not specified in OH_DecodingOptions and both desiredRegion and desiredSize are set, the final decoding result may vary slightly due to differences in decoding algorithms used for different image formats.
For example, if the original image size is 200x200, and you specify desiredSize:{width: 150, height: 150}, desiredRegion:{x: 0, y: 0, width: 100, height: 100}, the expectation is to decode the top-left 1/4 region of the original image and then scale the pixelMap size to 150x150.
For JPEG and WebP images (as well as some DNG images that decode a JPEG preview within the file and therefore are treated as JPEG format), the system first performs downsampling. For instance, it might downsample by 7/8 and then crop the region based on a 175x175 image size. As a result, the final cropped region will be slightly larger than the top-left 1/4 of the original image.
For SVG images, since they are vector graphics, they can be scaled arbitrarily without loss of clarity. During decoding, the scaling ratio is determined based on the proportion between desiredSize and the original image size. Cropping is then performed on the scaled image. As a result, the actual decoded region returned may vary.
To ensure consistent results when both desiredRegion and desiredSize are set, set Image_CropAndScaleStrategy to CROP_FIRST.
Since: 18
| Enum Item | Description |
|---|---|
| IMAGE_CROP_AND_SCALE_STRATEGY_SCALE_FIRST = 1 | Scales and then crops the image. |
| IMAGE_CROP_AND_SCALE_STRATEGY_CROP_FIRST = 2 | Crops and then scales the image. |
Function Description
OH_ImageSourceInfo_Create()
Image_ErrorCode OH_ImageSourceInfo_Create(OH_ImageSource_Info **info)
Description
Creates the pointer to an OH_ImageSource_Info object.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSource_Info **info | Double pointer to an OH_ImageSource_Info object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceInfo_GetWidth()
Image_ErrorCode OH_ImageSourceInfo_GetWidth(OH_ImageSource_Info *info, uint32_t *width)
Description
Obtains the image width. For an SVG image without the width property, the default value 0 is returned.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSource_Info *info | Pointer to an OH_ImageSource_Info object. |
| uint32_t *width | Pointer to the image width, in px. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceInfo_GetHeight()
Image_ErrorCode OH_ImageSourceInfo_GetHeight(OH_ImageSource_Info *info, uint32_t *height)
Description
Obtains the image height. For an SVG image without the height property, the default value 0 is returned.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSource_Info *info | Pointer to an OH_ImageSource_Info object. |
| uint32_t *height | Pointer to the image height, in px. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceInfo_GetDynamicRange()
Image_ErrorCode OH_ImageSourceInfo_GetDynamicRange(OH_ImageSource_Info *info, bool *isHdr)
Description
Check whether an image is HDR.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSource_Info *info | Pointer to an OH_ImageSource_Info object. |
| bool *isHdr | Whether the image is HDR. The value true indicates yes, and the value false indicates no. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceInfo_GetMimeType()
Image_ErrorCode OH_ImageSourceInfo_GetMimeType(OH_ImageSource_Info *info, Image_MimeType *mimeType)
Description
Obtains the MIME type of an image.
NOTE
- The member variable data of the mimeType struct is a char pointer that points to the mimeType address held within the info struct. Release info will result in this memory being deallocated.
- To avoid garbled characters, you can either make a deep copy of mimeType.data, or release info when mimeType is no longer needed.
- mimeType.data does not end with \0 and must be used together with mimeType.size.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_ImageSource_Info *info | Pointer to an OH_ImageSource_Info object. |
| Image_MimeType *mimeType | Pointer to the MIME type. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: A parameter is incorrect. The info or mimetype parameter is a null pointer. |
OH_ImageSourceInfo_Release()
Image_ErrorCode OH_ImageSourceInfo_Release(OH_ImageSource_Info *info)
Description
Releases the pointer to an OH_ImageSource_Info object. After this API is called, all properties related to the OH_ImageSource_Info struct are released. Therefore, before calling this API, ensure that the relevant properties are no longer needed or that a deep copy of these properties has been completed.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSource_Info *info | Pointer to an OH_ImageSource_Info object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_Create()
Image_ErrorCode OH_DecodingOptions_Create(OH_DecodingOptions **options)
Description
Creates the pointer to an OH_DecodingOptions object.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions **options | Double pointer to an OH_DecodingOptions object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetPixelFormat()
Image_ErrorCode OH_DecodingOptions_GetPixelFormat(OH_DecodingOptions *options, int32_t *pixelFormat)
Description
Obtains the pixel format.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| int32_t *pixelFormat | Pixel format. The default value is RGBA_8888. For details about pixel formats, see PIXEL_FORMAT. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_SetPixelFormat()
Image_ErrorCode OH_DecodingOptions_SetPixelFormat(OH_DecodingOptions *options,int32_t pixelFormat)
Description
Sets the pixel format.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| int32_t pixelFormat | Pixel format. The default value is RGBA_8888. For details about pixel formats, see PIXEL_FORMAT. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetIndex()
Image_ErrorCode OH_DecodingOptions_GetIndex(OH_DecodingOptions *options, uint32_t *index)
Description
Obtains the index of an image.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| uint32_t *index | Pointer to the image index. The default value is 0. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_SetIndex()
Image_ErrorCode OH_DecodingOptions_SetIndex(OH_DecodingOptions *options, uint32_t index)
Description
Sets the index for an image.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| uint32_t index | Image index. The default value is 0. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetRotate()
Image_ErrorCode OH_DecodingOptions_GetRotate(OH_DecodingOptions *options, float *rotate)
Description
Obtains the rotation degree.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| float *rotate | Pointer to the rotation degree, in deg. The default value is 0. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_SetRotate()
Image_ErrorCode OH_DecodingOptions_SetRotate(OH_DecodingOptions *options, float rotate)
Description
Sets the rotation angle.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| float rotate | Rotation degree, in deg. The default value is 0. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetDesiredSize()
Image_ErrorCode OH_DecodingOptions_GetDesiredSize(OH_DecodingOptions *options, Image_Size *desiredSize)
Description
Obtains the desired output dimensions.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| Image_Size *desiredSize | Expected output dimensions. The default value is the original image dimensions. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_SetDesiredSize()
Image_ErrorCode OH_DecodingOptions_SetDesiredSize(OH_DecodingOptions *options, Image_Size *desiredSize)
Description
Sets the desired output dimensions. The desiredSize parameter determines the dimensions of the PixelMap obtained after decoding, where both the width and height must be positive integers. If the aspect ratio is different from the original, the PixelMap will be stretched or scaled to the specified dimensions. The original dimensions are used by default.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| Image_Size *desiredSize | Expected output dimensions. The default value is the original image dimensions. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetDesiredRegion()
Image_ErrorCode OH_DecodingOptions_GetDesiredRegion(OH_DecodingOptions *options, Image_Region *desiredRegion)
Description
Obtains the region to decode.
Since the corresponding SetDesiredRegion function cannot meet the regional decoding requirements, starting from API version 19, you are advised to use OH_DecodingOptions_GetCropRegion instead.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| Image_Region *desiredRegion | Region to decode. By default, the full image area is used. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_SetDesiredRegion()
Image_ErrorCode OH_DecodingOptions_SetDesiredRegion(OH_DecodingOptions *options, Image_Region *desiredRegion)
Description
Sets the region to decode.
The actual decoding will process the entire original image, without any regional decoding effect. Starting from API version 19, you are advised to use OH_DecodingOptions_SetCropRegion instead.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| Image_Region *desiredRegion | Region to decode. By default, the full image area is used. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetDesiredDynamicRange()
Image_ErrorCode OH_DecodingOptions_GetDesiredDynamicRange(OH_DecodingOptions *options, int32_t *desiredDynamicRange)
Description
Obtains the desired dynamic range configured during decoding.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| int32_t *desiredDynamicRange | Pointer to the expected dynamic range. The default value is SDR. For details, see IMAGE_DYNAMIC_RANGE. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_SetDesiredDynamicRange()
Image_ErrorCode OH_DecodingOptions_SetDesiredDynamicRange(OH_DecodingOptions *options, int32_t desiredDynamicRange)
Description
Sets the desired dynamic range during decoding.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| int32_t desiredDynamicRange | Expected dynamic range. The default value is SDR. For details, see IMAGE_DYNAMIC_RANGE. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptions_GetDesiredColorSpace()
Image_ErrorCode OH_DecodingOptions_GetDesiredColorSpace(OH_DecodingOptions *options, int32_t *colorSpace)
Description
Obtains the color space set in the decoding options.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to the decoding options. |
| int32_t *colorSpace | Pointer to the color space. For details, see ColorSpaceName. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: A parameter is incorrect. The options or colorSpace parameter is a null pointer. |
OH_DecodingOptions_SetDesiredColorSpace()
Image_ErrorCode OH_DecodingOptions_SetDesiredColorSpace(OH_DecodingOptions *options, int32_t colorSpace)
Description
Sets the desired color space for the decoding options.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to the decoding options. |
| int32_t colorSpace | Color space. For details, see ColorSpaceName. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: A parameter is incorrect. The options parameter is a null pointer or the value of colorSpace is not supported. |
OH_DecodingOptions_SetCropAndScaleStrategy()
Image_ErrorCode OH_DecodingOptions_SetCropAndScaleStrategy(OH_DecodingOptions *options, int32_t cropAndScaleStrategy)
Description
Sets the cropping and scaling strategy used during decoding.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| int32_t cropAndScaleStrategy | Cropping and scaling strategy that is executed when desiredSize and desiredRegion are both specified. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: The options parameter is a null pointer or the value of cropAndScaleStrategy is not within an enumerated value defined by Image_CropAndScaleStrategy. |
OH_DecodingOptions_GetCropAndScaleStrategy()
Image_ErrorCode OH_DecodingOptions_GetCropAndScaleStrategy(OH_DecodingOptions *options, int32_t *cropAndScaleStrategy)
Description
Obtains the cropping and scaling strategy used during decoding.
Since: 18
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
| int32_t *cropAndScaleStrategy | Pointer to the cropping and scaling strategy that is executed when desiredSize and desiredRegion are both specified. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: The options or cropAndScaleStrategy parameter is a null pointer. |
OH_DecodingOptions_GetCropRegion()
Image_ErrorCode OH_DecodingOptions_GetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion)
Description
Obtains the cropping region in the decoding options.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to the decoding options. |
| Image_Region *cropRegion | Pointer to the cropping region. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The options or cropRegion parameter is a null pointer. |
OH_DecodingOptions_SetCropRegion()
Image_ErrorCode OH_DecodingOptions_SetCropRegion(OH_DecodingOptions *options, Image_Region *cropRegion)
Description
Sets the cropping region in the decoding options.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to the decoding options. |
| Image_Region *cropRegion | Pointer to the cropping region. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The options or cropRegion parameter is a null pointer. |
OH_DecodingOptions_Release()
Image_ErrorCode OH_DecodingOptions_Release(OH_DecodingOptions *options)
Description
Releases the pointer to an OH_DecodingOptions object.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptions *options | Pointer to an OH_DecodingOptions object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_CreateFromUri()
Image_ErrorCode OH_ImageSourceNative_CreateFromUri(char *uri, size_t uriSize, OH_ImageSourceNative **res)
Description
Creates the pointer to an OH_ImageSourceNative object based on a URI.
Since: 12
Parameters
| Name | Description |
|---|---|
| char *uri | Pointer to the URI of the image source. Only file URIs or Base64 URIs are accepted. Currently, only absolute paths are supported. |
| size_t uriSize | URI length. |
| OH_ImageSourceNative **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. IMAGE_BAD_SOURCE: The decoding data source is abnormal. |
OH_ImageSourceNative_CreateFromFd()
Image_ErrorCode OH_ImageSourceNative_CreateFromFd(int32_t fd, OH_ImageSourceNative **res)
Description
Creates the pointer to an OH_ImageSourceNative object based on a file descriptor.
Since: 12
Parameters
| Name | Description |
|---|---|
| int32_t fd | File descriptor. |
| OH_ImageSourceNative **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_CreateFromData()
Image_ErrorCode OH_ImageSourceNative_CreateFromData(uint8_t *data, size_t dataSize, OH_ImageSourceNative **res)
Description
Creates the pointer to an OH_ImageSourceNative object based on buffer data.
The passed data must be undecoded. Do not pass the pixel buffer data such as RGBA and YUV.
If you want to create a PixelMap based on the pixel buffer data, call OH_PixelmapNative_CreatePixelmap.
Since: 12
Parameters
| Name | Description |
|---|---|
| uint8_t *data | Pointer to the buffer data. |
| size_t dataSize | Size of the buffer. |
| OH_ImageSourceNative **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. IMAGE_BAD_SOURCE: The decoding data source is abnormal. |
OH_ImageSourceNative_CreateFromDataWithUserBuffer()
Image_ErrorCode OH_ImageSourceNative_CreateFromDataWithUserBuffer(uint8_t *data, size_t datalength, OH_ImageSourceNative **imageSource)
Description
Creates an image source from data buffer. The data buffer is directly accessed by the image source object, and therefore the data buffer must remain accessible within the lifecycle of the image source object.
Since: 20
Parameters
| Name | Description |
|---|---|
| uint8_t *data | Pointer to the data buffer. |
| size_t datalength | Size of the data buffer. |
| OH_ImageSourceNative **imageSource | Double pointer to the image source. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The data or imageSource parameter is a null pointer or the datalength parameter is 0. |
OH_ImageSourceNative_CreateFromRawFile()
Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile(RawFileDescriptor *rawFile, OH_ImageSourceNative **res)
Description
Creates the pointer to an OH_ImageSourceNative object by using the raw file descriptor of an image resource file.
Since: 12
Parameters
| Name | Description |
|---|---|
| RawFileDescriptor *rawFile | Pointer to the file descriptor of the raw file. |
| OH_ImageSourceNative **res | Double pointer to the OH_ImageSourceNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_CreatePixelmap()
Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative **pixelmap)
Description
Creates the pointer to an OH_PixelmapNative object based on decoding options.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| OH_DecodingOptions *options | Pointer to the decoding options. |
| OH_PixelmapNative **pixelmap | Double pointer to the OH_PixelmapNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_CreatePixelmapUsingAllocator()
Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator(OH_ImageSourceNative *source, OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap)
Description
Creates an OH_PixelmapNative object based on decoding options and memory type, where allocatorType specifies the memory type of the PixelMap.
By default, the system selects an appropriate memory type based on the image type, image size, and platform capability. When processing the returned PixelMap object, consider the impact of stride.
Since: 15
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| OH_DecodingOptions *options | Pointer to the decoding options. |
| IMAGE_ALLOCATOR_TYPE allocator | Memory type used by the returned PixelMap. |
| OH_PixelmapNative **pixelmap | Double pointer to the OH_PixelmapNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. IMAGE_BAD_SOURCE: The data source is abnormal. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: The MIME type is not supported. IMAGE_SOURCE_TOO_LARGE: The image is too large. IMAGE_SOURCE_UNSUPPORTED_ALLOCATOR_TYPE: The allocator type is not supported. For example, decoding HDR images using shared memory is not supported because only DMA supports HDR metadata. IMAGE_SOURCE_UNSUPPORTED_OPTIONS: The options are not supported. For example, an image cannot be converted into the required pixel format. IMAGE_DECODE_FAILED: Decoding fails. IMAGE_SOURCE_ALLOC_FAILED: The memory allocation fails. |
OH_ImageSourceNative_CreatePixelmapList()
Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative *resVecPixMap[], size_t size)
Description
Creates an array of OH_PixelmapNative objects based on decoding options.
This function decodes all frames at once. If the number of frames is high or the size of individual frames is large, it can lead to significant memory usage. In these cases, you are advised to use the Image component for displaying animations. The Image component decodes frames one by one, which uses less memory than this function.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| OH_DecodingOptions *options | Pointer to the decoding options. |
| OH_PixelmapNative *resVecPixMap[] | Pointer to an array of OH_PixelmapNative objects created at the C++ local layer. |
| size_t size | Size of the array. You can use OH_ImageSourceNative_GetFrameCount to obtain the size. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. IMAGE_UNSUPPORTED_OPERATION: The operation is not supported. |
OH_ImageSourceNative_CreatePicture()
Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options, OH_PictureNative **picture)
Description
Creates the pointer to an OH_PictureNative object based on decoding options.
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| OH_DecodingOptionsForPicture *options | Pointer to the decoding options. |
| OH_PictureNative **picture | Double pointer to the OH_PictureNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. IMAGE_DECODE_FAILED: Decoding fails. |
OH_ImageSourceNative_CreatePictureAtIndex()
Image_ErrorCode OH_ImageSourceNative_CreatePictureAtIndex(OH_ImageSourceNative *source, uint32_t index, OH_PictureNative **picture)
Description
Creates the pointer to an OH_PictureNative object at the specified index.
Since: 20
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| uint32_t index | Index of the image. |
| OH_PictureNative **picture | Double pointer to the OH_PictureNative object created at the C++ local layer. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_SOURCE: The data source is abnormal. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: The MIME type is not supported. IMAGE_SOURCE_TOO_LARGE: The image is too large. IMAGE_SOURCE_UNSUPPORTED_OPTIONS: The options are not supported. For example, an invalid image ID. IMAGE_DECODE_FAILED: Decoding fails. |
OH_ImageSourceNative_GetDelayTimeList()
Image_ErrorCode OH_ImageSourceNative_GetDelayTimeList(OH_ImageSourceNative *source, int32_t *delayTimeList, size_t size)
Description
Obtains the image delay time list.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| int32_t *delayTimeList | Pointer to the delay time list obtained. It cannot be a null pointer. |
| size_t size | Size of the delay time list. You can use OH_ImageSourceNative_GetFrameCount to obtain the size. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_GetImageInfo()
Image_ErrorCode OH_ImageSourceNative_GetImageInfo(OH_ImageSourceNative *source, int32_t index, OH_ImageSource_Info *info)
Description
Obtains the information about an image with a given index.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| int32_t index | Index of an image. For a GIF image, the value range is [0, N-1], where N indicates the number of GIF frames. For an image with only one frame, you can pass in 0. |
| OH_ImageSource_Info *info | Pointer to the image information obtained, which is an OH_ImageSource_Info struct. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_GetImageProperty()
Image_ErrorCode OH_ImageSourceNative_GetImageProperty(OH_ImageSourceNative *source, Image_String *key, Image_String *value)
Description
Obtains the value of an image property.
value.data obtained through this API lacks the string terminator \0. Please use it with caution.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. OH_ImageSourceNative must be actively released after use. For details, see OH_ImageSourceNative_Release. |
| Image_String *key | Pointer to the property. For details about the value range, see OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables of image_common.h. |
| Image_String *value | Pointer to the obtained value (output parameter). Before calling this API, set value->data to a null pointer and value->size to 0. The API will automatically allocate the required memory for value->data and assign a value to value->size. After finishing using this memory, release the memory pointed to by value->data using the free() function provided by the C standard library. Otherwise, a memory leak will occur. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_GetImagePropertyShort()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyShort(OH_ImageSourceNative *source, Image_String *key, uint16_t *value)
Description
Obtains an image property value of the short integer type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| uint16_t *value | Pointer to the obtained property value. This is the output parameter. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the short integer type. |
OH_ImageSourceNative_GetImagePropertyLong()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyLong(OH_ImageSourceNative *source, Image_String *key, uint32_t *value)
Description
Obtains an image property value of the long integer type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| uint32_t *value | Pointer to the obtained property value. This is the output parameter. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the long integer type. |
OH_ImageSourceNative_GetImagePropertyDouble()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyDouble(OH_ImageSourceNative *source, Image_String *key, double *value)
Description
Obtains an image property value of the floating-point type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| double *value | Pointer to the obtained property value. This is the output parameter. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the floating-point type. |
OH_ImageSourceNative_GetImagePropertyArraySize()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyArraySize(OH_ImageSourceNative *source, Image_String *key, size_t *size)
Description
Obtains the length of a property array or a string property.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| size_t *size | Pointer to the length of the property array or string property. This is the output parameter. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the array or string type. |
OH_ImageSourceNative_GetImagePropertyString()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyString(OH_ImageSourceNative *source, Image_String *key, char *value, size_t size)
Description
Obtains an image property value of the string type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| char *value | Pointer to the obtained property value. This is the output parameter. The caller is responsible for memory management and deallocation. |
| size_t size | String length. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the string type. |
OH_ImageSourceNative_GetImagePropertyIntArray()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyIntArray(OH_ImageSourceNative *source, Image_String *key, int32_t *value, size_t size)
Description
Obtains an image property value of the integer array type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| int32_t *value | Pointer to the obtained property value. This is the output parameter. The caller is responsible for memory management and deallocation. |
| size_t size | String length. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the integer array type. |
OH_ImageSourceNative_GetImagePropertyDoubleArray()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyDoubleArray(OH_ImageSourceNative *source, Image_String *key, double *value, size_t size)
Description
Obtains an image property value of the floating-point array type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| double *value | Pointer to the obtained property value. This is the output parameter. The caller is responsible for memory management and deallocation. |
| size_t size | Size of the array. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the floating-point array type. |
OH_ImageSourceNative_GetImagePropertyBlob()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyBlob(OH_ImageSourceNative *source, Image_String *key, void *value, size_t size)
Description
Obtains an image property value of the binary object type.
NOTE
When reading a DNG image, this API applies special handling to some keys. Refer to the OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables for the string values of the following fields:
- NewSubfileType, ImageWidth, ImageLength, DefaultCropSize, Orientation, Compression, PhotometricInterpretation, PlanarConfiguration, RowsPerStrip, StripOffsets, StripByteCounts, SamplesPerPixel, BitsPerSample, YCbCrCoefficients, YCbCrSubSampling, YCbCrPositioning, ReferenceBlackWhite, XResolution, YResolution, and ResolutionUnit: For these properties, values related to the main image are returned.
- ImageUniqueID: The value is verified based on the specifications. If the value fails to comply with the specifications, an empty string is returned.
- ExifVersion, FlashpixVersion, and ColorSpace: If the image does not contain these properties, an error code is returned.
- DNGVersion: If the value is earlier than 1.0.0.0, 1.0.0.0 is returned.
- GPSVersionID: If there is no valid GPS data, the GPS version number is cleared and 0 is returned.
- GPSAltitudeRef: If GPSAltitude is not set, this property is set to 0xFFFFFFFF.
- ISOSpeedRatings: If its value is 0 or 65535, the recommended exposure index is used first. If the recommended exposure index does not exist, the standard output sensitivity, ISO speed, and exposure index are used in sequence.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property is to be queried. |
| Image_String *key | Pointer to the property to be queried. |
| void *value | Pointer to the obtained property value. This is the output parameter. The caller is responsible for memory management and deallocation. |
| size_t size | Size of the array. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the binary object type. |
OH_ImageSourceNative_ModifyImagePropertyShort()
Image_ErrorCode OH_ImageSourceNative_ModifyImagePropertyShort(OH_ImageSourceNative *source, Image_String *key, uint16_t value)
Description
Changes an image property value of the short integer type.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property value is to be changed. |
| Image_String *key | Pointer to the property whose value is to be changed. |
| uint16_t value | Property value. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the short integer type. |
OH_ImageSourceNative_ModifyImagePropertyLong()
Image_ErrorCode OH_ImageSourceNative_ModifyImagePropertyLong(OH_ImageSourceNative *source, Image_String *key, uint32_t value)
Description
Changes an image property value of the long integer type.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property value is to be changed. |
| Image_String *key | Pointer to the property whose value is to be changed. |
| uint32_t value | Property value. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the long integer type. |
OH_ImageSourceNative_ModifyImagePropertyDouble()
Image_ErrorCode OH_ImageSourceNative_ModifyImagePropertyDouble(OH_ImageSourceNative *source, Image_String *key, double value)
Description
Changes an image property value of the floating-point type.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property value is to be changed. |
| Image_String *key | Pointer to the property whose value is to be changed. |
| double value | Property value. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the floating-point type. |
OH_ImageSourceNative_ModifyImagePropertyIntArray()
Image_ErrorCode OH_ImageSourceNative_ModifyImagePropertyIntArray(OH_ImageSourceNative *source, Image_String *key, int32_t *value, size_t size)
Description
Changes an image property value of the integer array type.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property value is to be changed. |
| Image_String *key | Pointer to the property whose value is to be changed. |
| int32_t *value | Pointer to the property value. |
| size_t size | Size of the array. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the integer array type. |
OH_ImageSourceNative_ModifyImagePropertyDoubleArray()
Image_ErrorCode OH_ImageSourceNative_ModifyImagePropertyDoubleArray(OH_ImageSourceNative *source, Image_String *key, double *value, size_t size)
Description
Changes an image property value of the floating-point array type.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property value is to be changed. |
| Image_String *key | Pointer to the property whose value is to be changed. |
| double *value | Pointer to the property value. |
| size_t size | Size of the array. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the floating-point array type. |
OH_ImageSourceNative_ModifyImagePropertyBlob()
Image_ErrorCode OH_ImageSourceNative_ModifyImagePropertyBlob(OH_ImageSourceNative *source, Image_String *key, void *value, size_t size)
Description
Changes an image property value of the binary object type.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to ImageSource whose property value is to be changed. |
| Image_String *key | Pointer to the property whose value is to be changed. |
| void *value | Pointer to the property value. |
| size_t size | Size of the array. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: source, key, or value is nullptr. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: Image properties for the current MIME type are not supported for querying. IMAGE_SOURCE_UNSUPPORTED_METADATA: The specified metadata does not exist or is not of the binary object type. |
OH_ImageSourceNative_GetImagePropertyWithNull()
Image_ErrorCode OH_ImageSourceNative_GetImagePropertyWithNull(OH_ImageSourceNative *source, Image_String *key, Image_String *value)
Description
Obtains the value of an image property. The output value.data ends with the string terminator \0.
Since: 19
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. OH_ImageSourceNative must be actively released after use. For details, see OH_ImageSourceNative_Release. |
| Image_String *key | Pointer to the property key. For details about the value range, see OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables of image_common.h. |
| Image_String *value | Pointer to the value obtained. Before calling this API, set value->data to a null pointer and value->size to 0. The API will automatically allocate the required memory for value->data and assign a value to value->size. After finishing using this memory, release the memory pointed to by value->data using the free() function provided by the C standard library. Otherwise, a memory leak may occur. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The source, key, or value parameter is a null pointer. |
OH_ImageSourceNative_ModifyImageProperty()
Image_ErrorCode OH_ImageSourceNative_ModifyImageProperty(OH_ImageSourceNative *source, Image_String *key, Image_String *value)
Description
Modifies the value of an image property.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. OH_ImageSourceNative must be actively released after use. For details, see OH_ImageSourceNative_Release. |
| Image_String *key | Pointer to the property key. For details about the value range, see OHOS_IMAGE_PROPERTY_XXX series constants defined in Variables of image_common.h. |
| Image_String *value | Pointer to the new value. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_GetFrameCount()
Image_ErrorCode OH_ImageSourceNative_GetFrameCount(OH_ImageSourceNative *source, uint32_t *frameCount)
Description
Obtains the number of image frames.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
| uint32_t *frameCount | Pointer to the number of frames obtained. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_GetSupportedFormats()
Image_ErrorCode OH_ImageSourceNative_GetSupportedFormats(Image_MimeType **supportedFormats, size_t *length)
Description
Obtains the supported image formats that can be decoded.
Since: 20
Parameters
| Name | Description |
|---|---|
| Image_MimeType **supportedFormats | Double pointer to the supported image formats. |
| size_t *length | Pointer to the size of the array. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The supportedFormats or length parameter is a null pointer. |
OH_ImageSourceNative_Release()
Image_ErrorCode OH_ImageSourceNative_Release(OH_ImageSourceNative *source)
Description
Releases the pointer to an OH_ImageSourceNative object.
Since: 12
Parameters
| Name | Description |
|---|---|
| OH_ImageSourceNative *source | Pointer to an OH_ImageSourceNative object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptionsForPicture_Create()
Image_ErrorCode OH_DecodingOptionsForPicture_Create(OH_DecodingOptionsForPicture **options)
Description
Creates the pointer to an OH_DecodingOptionsForPicture object.
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptionsForPicture **options | Double pointer to an OH_DecodingOptionsForPicture object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures()
Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length)
Description
Obtains desired auxiliary pictures in the decoding options (auxiliary pictures contained in picture expected to be decoded.)
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptionsForPicture *options | Pointer to an OH_DecodingOptionsForPicture object. |
| Image_AuxiliaryPictureType **desiredAuxiliaryPictures | Double pointer to the desired auxiliary pictures. |
| size_t *length | Length of the desired auxiliary pictures. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures()
Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length)
Description
Sets desired auxiliary pictures in the decoding options.
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptionsForPicture *options | Pointer to an OH_DecodingOptionsForPicture object. |
| Image_AuxiliaryPictureType *desiredAuxiliaryPictures | Pointer to the desired auxiliary pictures. |
| size_t length | Length of the desired auxiliary pictures. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_DecodingOptionsForPicture_Release()
Image_ErrorCode OH_DecodingOptionsForPicture_Release(OH_DecodingOptionsForPicture *options)
Description
Releases the pointer to an OH_DecodingOptionsForPicture object.
Since: 13
Parameters
| Name | Description |
|---|---|
| OH_DecodingOptionsForPicture *options | Pointer to an OH_DecodingOptionsForPicture object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_PARAMETER: A parameter is incorrect. |
OH_ImageSourceNative_CreateImageRawData()
Image_ErrorCode OH_ImageSourceNative_CreateImageRawData(const OH_ImageSourceNative *source, OH_ImageRawData **rawData)
Description
Obtains the rawData object from an image. The rawData object usually occupies a large amount of memory because it contains raw data from the camera.
When the rawData object is no longer needed, call the OH_ImageSourceNative_DestroyImageRawData method to destroy it in a timely manner to deallocate memory resources.
Since: 24
Parameters
| Name | Description |
|---|---|
| const OH_ImageSourceNative *source | Pointer to the image source. |
| OH_ImageRawData **rawData | Double pointer to the rawData object obtained after decoding. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_BAD_SOURCE: The source is incorrect. IMAGE_SOURCE_INVALID_PARAMETER: The rawData object is invalid. IMAGE_SOURCE_UNSUPPORTED_MIME_TYPE: The MIME type is not supported. |
OH_ImageSourceNative_GetBufferFromRawData()
Image_ErrorCode OH_ImageSourceNative_GetBufferFromRawData(const OH_ImageRawData *rawData, uint8_t **data, size_t *length)
Description
Obtains binary data from a rawData object.
Since: 24
Parameters
| Name | Description |
|---|---|
| const OH_ImageRawData *rawData | Pointer to the rawData object. |
| uint8_t **data | Pointer to the binary buffer data. |
| size_t *length | Pointer to the length of the obtained data. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The rawData object is invalid. |
OH_ImageSourceNative_GetBitsPerPixelFromRawData()
Image_ErrorCode OH_ImageSourceNative_GetBitsPerPixelFromRawData(const OH_ImageRawData *rawData, uint8_t *bitsPerPixel)
Description
Obtains the number of bits occupied by each pixel in the buffer data.
Since: 24
Parameters
| Name | Description |
|---|---|
| const OH_ImageRawData *rawData | Pointer to the rawData object. |
| uint8_t *bitsPerPixel | Pointer to the number of bits per pixel. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The rawData object is invalid. |
OH_ImageSourceNative_DestroyImageRawData()
Image_ErrorCode OH_ImageSourceNative_DestroyImageRawData(OH_ImageRawData *rawData)
Description
Destroys a rawData object.
Since: 24
Parameters
| Name | Description |
|---|---|
| OH_ImageRawData *rawData | Pointer to the rawData object. |
Returns
| Type | Description |
|---|---|
| Image_ErrorCode | IMAGE_SUCCESS: The operation is successful. IMAGE_SOURCE_INVALID_PARAMETER: The rawData object is invalid. |