13eaf1cc创建于 2025年3月20日历史提交

image_source_native.h

概述

图片解码API。

库: libimage_source.so

系统能力: SystemCapability.Multimedia.Image.ImageSource

起始版本: 12

相关模块:Image_NativeModule

汇总

类型定义

名称 描述
typedef struct OH_ImageSourceNative OH_ImageSourceNative ImageSource结构体类型,用于执行ImageSource相关操作。
typedef struct OH_ImageSource_Info OH_ImageSource_Info 图片源信息结构体 OH_ImageSourceInfo_Create
typedef struct OH_DecodingOptions OH_DecodingOptions 解码选项参数结构体,被用于OH_ImageSourceNative_CreatePixelmap

枚举

名称 描述
IMAGE_ALLOCATOR_TYPE {
IMAGE_ALLOCATOR_TYPE_AUTO = 0,
IMAGE_ALLOCATOR_TYPE_DMA = 1,
IMAGE_ALLOCATOR_TYPE_SHARE_MEMORY = 2 }
用于分配 PixelMap 内存的分配器类型。
IMAGE_DYNAMIC_RANGE {
IMAGE_DYNAMIC_RANGE_AUTO = 0,
IMAGE_DYNAMIC_RANGE_SDR = 1,
IMAGE_DYNAMIC_RANGE_HDR = 2
}
解码指定期望动态范围。

函数

名称 描述
Image_ErrorCode OH_ImageSourceInfo_Create (OH_ImageSource_Info **info) 创建OH_ImageSource_Info指针。
Image_ErrorCode OH_ImageSourceInfo_GetWidth (OH_ImageSource_Info *info, uint32_t *width) 获取图片的宽。
Image_ErrorCode OH_ImageSourceInfo_GetHeight (OH_ImageSource_Info *info, uint32_t *height) 获取图片的高。
Image_ErrorCode OH_ImageSourceInfo_GetDynamicRange (OH_ImageSource_Info *info, bool *isHdr) 获取图片是否为高动态范围的信息。
Image_ErrorCode OH_ImageSourceInfo_Release (OH_ImageSource_Info *info) 释放OH_ImageSource_Info指针。
Image_ErrorCode OH_DecodingOptions_Create (OH_DecodingOptions **options) 创建OH_DecodingOptions指针。
Image_ErrorCode OH_DecodingOptions_GetPixelFormat (OH_DecodingOptions *options, int32_t *pixelFormat) 获取pixel格式。
Image_ErrorCode OH_DecodingOptions_SetPixelFormat (OH_DecodingOptions *options, int32_t pixelFormat) 设置pixel格式。
Image_ErrorCode OH_DecodingOptions_GetIndex (OH_DecodingOptions *options, uint32_t *index) 获取解码图片序号。
Image_ErrorCode OH_DecodingOptions_SetIndex (OH_DecodingOptions *options, uint32_t index) 设置解码图片序号。
Image_ErrorCode OH_DecodingOptions_GetRotate (OH_DecodingOptions *options, float *rotate) 获取旋转角度。
Image_ErrorCode OH_DecodingOptions_SetRotate (OH_DecodingOptions *options, float rotate) 设置旋转角度。
Image_ErrorCode OH_DecodingOptions_GetDesiredSize (OH_DecodingOptions *options, Image_Size *desiredSize) 获取期望输出大小。
Image_ErrorCode OH_DecodingOptions_SetDesiredSize (OH_DecodingOptions *options, Image_Size *desiredSize) 设置期望输出大小。
Image_ErrorCode OH_DecodingOptions_GetDesiredRegion (OH_DecodingOptions *options, Image_Region *desiredRegion) 获取解码区域。
Image_ErrorCode OH_DecodingOptions_SetDesiredRegion (OH_DecodingOptions *options, Image_Region *desiredRegion) 设置解码区域。
Image_ErrorCode OH_DecodingOptions_GetDesiredDynamicRange (OH_DecodingOptions *options, int32_t *desiredDynamicRange) 获取解码时设置的期望动态范围。
Image_ErrorCode OH_DecodingOptions_SetDesiredDynamicRange (OH_DecodingOptions *options, int32_t desiredDynamicRange) 设置解码时的期望动态范围。
Image_ErrorCode OH_DecodingOptions_Release (OH_DecodingOptions *options) 释放OH_DecodingOptions指针。
Image_ErrorCode OH_ImageSourceNative_CreateFromUri (char *uri, size_t uriSize, OH_ImageSourceNative **res) 通过uri创建OH_ImageSourceNative指针。
Image_ErrorCode OH_ImageSourceNative_CreateFromFd (int32_t fd, OH_ImageSourceNative **res) 通过fd创建OH_ImageSourceNative指针。
Image_ErrorCode OH_ImageSourceNative_CreateFromData (uint8_t *data, size_t dataSize, OH_ImageSourceNative **res) 通过缓冲区数据创建OH_ImageSourceNative指针。
Image_ErrorCode OH_ImageSourceNative_CreateFromRawFile (RawFileDescriptor *rawFile, OH_ImageSourceNative **res) 通过图像资源文件的RawFileDescriptor创建OH_ImageSourceNative指针。
Image_ErrorCode OH_ImageSourceNative_CreatePixelmap (OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative **pixelmap) 通过图片解码参数创建OH_PixelmapNative指针。
Image_ErrorCode OH_ImageSourceNative_CreatePixelmapUsingAllocator (OH_ImageSourceNative *source, OH_DecodingOptions *options, IMAGE_ALLOCATOR_TYPE allocator, OH_PixelmapNative **pixelmap) 根据解码参数创建一个PixelMap,PixelMap使用的内存类型可以通过allocatorType来指定。
默认情况下,系统会根据图像类型、图像大小、平台能力等选择内存类型。在处理通过此接口返回的PixelMap时,请始终考虑步幅(stride)的影响。
Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList (OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative *resVecPixMap[], size_t size) 通过图片解码参数创建OH_PixelmapNative数组。
Image_ErrorCode OH_ImageSourceNative_CreatePicture (OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options, OH_PictureNative **picture) 通过图片解码创建OH_PictureNative指针。
Image_ErrorCode OH_ImageSourceNative_GetDelayTimeList (OH_ImageSourceNative *source, int32_t *delayTimeList, size_t size) 获取图像延迟时间数组。
Image_ErrorCode OH_ImageSourceNative_GetImageInfo (OH_ImageSourceNative *source, int32_t index, OH_ImageSource_Info *info) 获取指定序号的图片信息。
Image_ErrorCode OH_ImageSourceNative_GetImageProperty (OH_ImageSourceNative *source, Image_String *key, Image_String *value) 获取图片指定属性键的值。
Image_ErrorCode OH_ImageSourceNative_ModifyImageProperty (OH_ImageSourceNative *source, Image_String *key, Image_String *value) 通过指定的键修改图片属性的值。
Image_ErrorCode OH_ImageSourceNative_GetFrameCount (OH_ImageSourceNative *source, uint32_t *frameCount) 获取图像帧数。
Image_ErrorCode OH_ImageSourceNative_Release (OH_ImageSourceNative *source) 释放OH_ImageSourceNative指针。
Image_ErrorCode OH_DecodingOptionsForPicture_Create (OH_DecodingOptionsForPicture **options) 创建OH_DecodingOptionsForPicture指针。
Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures (OH_DecodingOptionsForPicture *options, Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length) 获取解码时设置的期望辅助图(期望解码出的picture包含的辅助图)。
Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures (OH_DecodingOptionsForPicture *options, Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length) 设置解码选项中的期望辅助图。
Image_ErrorCode OH_DecodingOptionsForPicture_Release (OH_DecodingOptionsForPicture *options) 释放OH_DecodingOptionsForPicture指针。