1# native_buffer.h 2<!--Kit: ArkGraphics 2D--> 3<!--Subsystem: Graphics--> 4<!--Owner: @Flix-fangyang; @li_hui180; @ding-panyun--> 5<!--Designer: @conan13234--> 6<!--Tester: @nobuggers--> 7<!--Adviser: @ge-yafang--> 8## 概述 9 10定义获取和使用NativeBuffer的相关函数。 11 12**引用文件:** <native_buffer/native_buffer.h> 13 14**库:** libnative_buffer.so 15 16**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 17 18**起始版本:** 9 19 20**相关模块:** [OH_NativeBuffer](capi-oh-nativebuffer.md) 21 22## 汇总 23 24### 结构体 25 26| 名称 | typedef关键字 | 描述 | 27| -- | -- | -- | 28| [OH_NativeBuffer_Config](capi-oh-nativebuffer-oh-nativebuffer-config.md) | OH_NativeBuffer_Config | OH_NativeBuffer的属性配置,用于申请新的OH_NativeBuffer实例或查询现有实例的相关属性。 | 29| [OH_NativeBuffer_Plane](capi-oh-nativebuffer-oh-nativebuffer-plane.md) | OH_NativeBuffer_Plane | 单个图像平面格式信息。 | 30| [OH_NativeBuffer_Planes](capi-oh-nativebuffer-oh-nativebuffer-planes.md) | OH_NativeBuffer_Planes | OH_NativeBuffer的图像平面格式信息。 | 31| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) | OH_NativeBuffer | 提供OH_NativeBuffer结构体声明。 | 32 33### 枚举 34 35| 名称 | typedef关键字 | 描述 | 36| -- | -- | -- | 37| [OH_NativeBuffer_Usage](#oh_nativebuffer_usage) | OH_NativeBuffer_Usage | OH_NativeBuffer的用途。 | 38| [OH_NativeBuffer_Format](#oh_nativebuffer_format) | OH_NativeBuffer_Format | OH_NativeBuffer的格式。 | 39| [OH_NativeBuffer_TransformType](#oh_nativebuffer_transformtype) | OH_NativeBuffer_TransformType | OH_NativeBuffer的转换类型。 | 40| [OH_NativeBuffer_ColorGamut](#oh_nativebuffer_colorgamut) | OH_NativeBuffer_ColorGamut | OH_NativeBuffer的色域。 | 41 42### 函数 43 44| 名称 | 描述 | 45| -- | -- | 46| [OH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config)](#oh_nativebuffer_alloc) | 通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例。<br>本接口需要与[OH_NativeBuffer_Unreference](capi-native-buffer-h.md#oh_nativebuffer_unreference)接口配合使用,否则会存在内存泄露。<br>本接口为非线程安全类型接口。 | 47| [int32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer)](#oh_nativebuffer_reference) | 将OH_NativeBuffer对象的引用计数加1。<br>本接口需要与[OH_NativeBuffer_Unreference](capi-native-buffer-h.md#oh_nativebuffer_unreference)接口配合使用,否则会存在内存泄露。<br>本接口为非线程安全类型接口。 | 48| [int32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer)](#oh_nativebuffer_unreference) | 将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉。<br>本接口为非线程安全类型接口。 | 49| [void OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config)](#oh_nativebuffer_getconfig) | 用于获取OH_NativeBuffer的属性。<br>本接口为非线程安全类型接口。 | 50| [int32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr)](#oh_nativebuffer_map) | 将OH_NativeBuffer对应的ION内存映射到进程空间。<br>本接口需要与[OH_NativeBuffer_Unmap](capi-native-buffer-h.md#oh_nativebuffer_unmap)接口配合使用。<br>本接口为非线程安全类型接口。 | 51| [int32_t OH_NativeBuffer_Unmap(OH_NativeBuffer *buffer)](#oh_nativebuffer_unmap) | 将OH_NativeBuffer对应的ION内存从进程空间移除。<br>本接口为非线程安全类型接口。 | 52| [uint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer)](#oh_nativebuffer_getseqnum) | 获取OH_NativeBuffer的序列号。<br>本接口为非线程安全类型接口。 | 53| [int32_t OH_NativeBuffer_SetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace)](#oh_nativebuffer_setcolorspace) | 为OH_NativeBuffer设置颜色空间属性。<br>本接口为非线程安全类型接口。 | 54| [int32_t OH_NativeBuffer_MapPlanes(OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes)](#oh_nativebuffer_mapplanes) | 将OH_NativeBuffer对应的多通道ION内存映射到进程空间。<br>本接口为非线程安全类型接口。 | 55| [int32_t OH_NativeBuffer_FromNativeWindowBuffer(OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer)](#oh_nativebuffer_fromnativewindowbuffer) | 将OHNativeWindowBuffer实例转换为OH_NativeBuffer实例。<br>本接口为非线程安全类型接口。 | 56| [int32_t OH_NativeBuffer_GetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace)](#oh_nativebuffer_getcolorspace) | 获取OH_NativeBuffer颜色空间属性。<br>本接口为非线程安全类型接口。 | 57| [int32_t OH_NativeBuffer_SetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey,int32_t size, uint8_t *metadata)](#oh_nativebuffer_setmetadatavalue) | 为OH_NativeBuffer设置元数据属性值。<br>本接口为非线程安全类型接口。 | 58| [int32_t OH_NativeBuffer_GetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey,int32_t *size, uint8_t **metadata)](#oh_nativebuffer_getmetadatavalue) | 获取OH_NativeBuffer元数据属性值。<br>本接口为非线程安全类型接口。 | 59 60## 枚举类型说明 61 62### OH_NativeBuffer_Usage 63 64``` 65enum OH_NativeBuffer_Usage 66``` 67 68**描述** 69 70OH_NativeBuffer的用途。 71 72**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 73 74**起始版本:** 10 75 76| 枚举项 | 描述 | 77| -- | -- | 78| NATIVEBUFFER_USAGE_CPU_READ = (1ULL << 0) | CPU可读。 | 79| NATIVEBUFFER_USAGE_CPU_WRITE = (1ULL << 1) | CPU可写。 | 80| NATIVEBUFFER_USAGE_MEM_DMA = (1ULL << 3) | 直接内存访问缓冲区。 | 81| NATIVEBUFFER_USAGE_MEM_MMZ_CACHE = (1ULL << 5) | 媒体内存区域缓存。<br/>**起始版本:** 20 | 82| NATIVEBUFFER_USAGE_HW_RENDER = (1ULL << 8) | GPU可写。<br/>**起始版本:** 12 | 83| NATIVEBUFFER_USAGE_HW_TEXTURE = (1ULL << 9) | GPU可读。<br/>**起始版本:** 12 | 84| NATIVEBUFFER_USAGE_CPU_READ_OFTEN = (1ULL << 16) | CPU可直接映射。<br/>**起始版本:** 12 | 85| NATIVEBUFFER_USAGE_ALIGNMENT_512 = (1ULL << 18) | 512字节对齐。<br/>**起始版本:** 12 | 86 87### OH_NativeBuffer_Format 88 89``` 90enum OH_NativeBuffer_Format 91``` 92 93**描述** 94 95OH_NativeBuffer的格式。 96 97**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 98 99**起始版本:** 10 100 101| 枚举项 | 描述 | 102| -- | -- | 103| NATIVEBUFFER_PIXEL_FMT_CLUT8 = 0 | CLUT8格式。<br/>**起始版本:** 12 | 104| NATIVEBUFFER_PIXEL_FMT_CLUT1 | CLUT1格式。<br/>**起始版本:** 12 | 105| NATIVEBUFFER_PIXEL_FMT_CLUT4 | CLUT4格式。<br/>**起始版本:** 12 | 106| NATIVEBUFFER_PIXEL_FMT_RGB_565 = 3 | RGB565格式。 | 107| NATIVEBUFFER_PIXEL_FMT_RGBA_5658 | RGBA5658格式。 | 108| NATIVEBUFFER_PIXEL_FMT_RGBX_4444 | RGBX4444格式。 | 109| NATIVEBUFFER_PIXEL_FMT_RGBA_4444 | RGBA4444格式。 | 110| NATIVEBUFFER_PIXEL_FMT_RGB_444 | RGB444格式。 | 111| NATIVEBUFFER_PIXEL_FMT_RGBX_5551 | RGBX5551格式。 | 112| NATIVEBUFFER_PIXEL_FMT_RGBA_5551 | RGBA5551格式。 | 113| NATIVEBUFFER_PIXEL_FMT_RGB_555 | RGB555格式。 | 114| NATIVEBUFFER_PIXEL_FMT_RGBX_8888 | RGBX8888格式。 | 115| NATIVEBUFFER_PIXEL_FMT_RGBA_8888 | RGBA8888格式。 | 116| NATIVEBUFFER_PIXEL_FMT_RGB_888 | RGB888格式。 | 117| NATIVEBUFFER_PIXEL_FMT_BGR_565 | BGR565格式。 | 118| NATIVEBUFFER_PIXEL_FMT_BGRX_4444 | BGRX4444格式。 | 119| NATIVEBUFFER_PIXEL_FMT_BGRA_4444 | BGRA4444格式。 | 120| NATIVEBUFFER_PIXEL_FMT_BGRX_5551 | BGRX5551格式。 | 121| NATIVEBUFFER_PIXEL_FMT_BGRA_5551 | BGRA5551格式。 | 122| NATIVEBUFFER_PIXEL_FMT_BGRX_8888 | BGRX8888格式。 | 123| NATIVEBUFFER_PIXEL_FMT_BGRA_8888 | BGRA8888格式。 | 124| NATIVEBUFFER_PIXEL_FMT_YUV_422_I | YUV422 interleaved 格式。<br/>**起始版本:** 12 | 125| NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP | YCBCR422 semi-planar 格式。<br/>**起始版本:** 12 | 126| NATIVEBUFFER_PIXEL_FMT_YCRCB_422_SP | YCRCB422 semi-planar 格式。<br/>**起始版本:** 12 | 127| NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP | YCBCR420 semi-planar 格式。<br/>**起始版本:** 12 | 128| NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP | YCRCB420 semi-planar 格式。<br/>**起始版本:** 12 | 129| NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P | YCBCR422 planar 格式。<br/>**起始版本:** 12 | 130| NATIVEBUFFER_PIXEL_FMT_YCRCB_422_P | YCRCB422 planar 格式。<br/>**起始版本:** 12 | 131| NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P | YCBCR420 planar 格式。<br/>**起始版本:** 12 | 132| NATIVEBUFFER_PIXEL_FMT_YCRCB_420_P | YCRCB420 planar 格式。<br/>**起始版本:** 12 | 133| NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG | YUYV422 packed 格式。<br/>**起始版本:** 12 | 134| NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG | UYVY422 packed 格式。<br/>**起始版本:** 12 | 135| NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG | YVYU422 packed 格式。<br/>**起始版本:** 12 | 136| NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG | VYUY422 packed 格式。<br/>**起始版本:** 12 | 137| NATIVEBUFFER_PIXEL_FMT_RGBA_1010102 | RGBA_1010102 packed 格式。 | 138| NATIVEBUFFER_PIXEL_FMT_YCBCR_P010 | YCBCR420 semi-planar 10bit packed 格式。 | 139| NATIVEBUFFER_PIXEL_FMT_YCRCB_P010 | YCRCB420 semi-planar 10bit packed 格式。 | 140| NATIVEBUFFER_PIXEL_FMT_RAW10 | Raw 10bit packed 格式。 | 141| NATIVEBUFFER_PIXEL_FMT_BLOB | BLOB格式。<br/>**起始版本:** 15 | 142| NATIVEBUFFER_PIXEL_FMT_RGBA16_FLOAT | RGBA16 float格式。<br/>**起始版本:** 15 | 143| NATIVEBUFFER_PIXEL_FMT_Y8 = 40 | Y8格式。<br/>**起始版本:** 20 | 144| NATIVEBUFFER_PIXEL_FMT_Y16 = 41 | Y16格式。<br/>**起始版本:** 20 | 145| NATIVEBUFFER_PIXEL_FMT_VENDER_MASK = 0X7FFF0000 | vender mask 格式。<br/>**起始版本:** 12| 146| NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF | 无效格式。 | 147 148### OH_NativeBuffer_TransformType 149 150``` 151enum OH_NativeBuffer_TransformType 152``` 153 154**描述** 155 156OH_NativeBuffer的转换类型。 157 158**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 159 160**起始版本:** 12 161 162| 枚举项 | 描述 | 163| -- | -- | 164| NATIVEBUFFER_ROTATE_NONE = 0 | 不旋转。 | 165| NATIVEBUFFER_ROTATE_90 | 旋转90度。 | 166| NATIVEBUFFER_ROTATE_180 | 旋转180度。 | 167| NATIVEBUFFER_ROTATE_270 | 旋转270度。 | 168| NATIVEBUFFER_FLIP_H | 水平翻转。 | 169| NATIVEBUFFER_FLIP_V | 垂直翻转。 | 170| NATIVEBUFFER_FLIP_H_ROT90 | 水平翻转并旋转90度。 | 171| NATIVEBUFFER_FLIP_V_ROT90 | 垂直翻转并旋转90度。 | 172| NATIVEBUFFER_FLIP_H_ROT180 | 水平翻转并旋转180度。 | 173| NATIVEBUFFER_FLIP_V_ROT180 | 垂直翻转并旋转180度。 | 174| NATIVEBUFFER_FLIP_H_ROT270 | 水平翻转并旋转270度。 | 175| NATIVEBUFFER_FLIP_V_ROT270 | 垂直翻转并旋转270度。 | 176 177### OH_NativeBuffer_ColorGamut 178 179``` 180enum OH_NativeBuffer_ColorGamut 181``` 182 183**描述** 184 185OH_NativeBuffer的色域。 186 187**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 188 189**起始版本:** 12 190 191| 枚举项 | 描述 | 192| -- | -- | 193| NATIVEBUFFER_COLOR_GAMUT_NATIVE = 0 | 默认色域格式。 | 194| NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601 = 1 | Standard BT601色域格式。 | 195| NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709 = 2 | Standard BT709色域格式。 | 196| NATIVEBUFFER_COLOR_GAMUT_DCI_P3 = 3 | DCI P3色域格式。 | 197| NATIVEBUFFER_COLOR_GAMUT_SRGB = 4 | SRGB色域格式。 | 198| NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGB = 5 | Adobe RGB色域格式。 | 199| NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3 = 6 | Display P3色域格式。 | 200| NATIVEBUFFER_COLOR_GAMUT_BT2020 = 7 | BT2020色域格式。 | 201| NATIVEBUFFER_COLOR_GAMUT_BT2100_PQ = 8 | BT2100 PQ色域格式。 | 202| NATIVEBUFFER_COLOR_GAMUT_BT2100_HLG = 9 | BT2100 HLG色域格式。 | 203| NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020 = 10 | Display BT2020色域格式。 | 204 205 206## 函数说明 207 208### OH_NativeBuffer_Alloc() 209 210``` 211OH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config) 212``` 213 214**描述** 215 216通过OH_NativeBuffer_Config创建OH_NativeBuffer实例,每次调用都会产生一个新的OH_NativeBuffer实例。<br>本接口需要与[OH_NativeBuffer_Unreference](capi-native-buffer-h.md#oh_nativebuffer_unreference)接口配合使用,否则会存在内存泄露。<br>本接口为非线程安全类型接口。 217 218**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 219 220**起始版本:** 9 221 222 223**参数:** 224 225| 参数项 | 描述 | 226| -- | -- | 227| const [OH_NativeBuffer_Config](capi-oh-nativebuffer-oh-nativebuffer-config.md)* config | 一个指向OH_NativeBuffer_Config类型的指针。 | 228 229**返回:** 230 231| 类型 | 说明 | 232| -- | -- | 233| OH_NativeBuffer* | 创建成功则返回一个指向OH_NativeBuffer结构体实例的指针,否则返回NULL。 | 234 235### OH_NativeBuffer_Reference() 236 237``` 238int32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer) 239``` 240 241**描述** 242 243将OH_NativeBuffer对象的引用计数加1。<br>本接口需要与[OH_NativeBuffer_Unreference](capi-native-buffer-h.md#oh_nativebuffer_unreference)接口配合使用,否则会存在内存泄露。<br>本接口为非线程安全类型接口。 244 245**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 246 247**起始版本:** 9 248 249 250**参数:** 251 252| 参数项 | 描述 | 253| -- | -- | 254| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 255 256**返回:** 257 258| 类型 | 说明 | 259| -- | -- | 260| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 261 262### OH_NativeBuffer_Unreference() 263 264``` 265int32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer) 266``` 267 268**描述** 269 270将OH_NativeBuffer对象的引用计数减1,当引用计数为0的时候,该NativeBuffer对象会被析构掉。<br>本接口为非线程安全类型接口。 271 272**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 273 274**起始版本:** 9 275 276 277**参数:** 278 279| 参数项 | 描述 | 280| -- | -- | 281| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 282 283**返回:** 284 285| 类型 | 说明 | 286| -- | -- | 287| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 288 289### OH_NativeBuffer_GetConfig() 290 291``` 292void OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config) 293``` 294 295**描述** 296 297用于获取OH_NativeBuffer的属性。<br>本接口为非线程安全类型接口。 298 299**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 300 301**起始版本:** 9 302 303 304**参数:** 305 306| 参数项 | 描述 | 307| -- | -- | 308| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 309| [OH_NativeBuffer_Config](capi-oh-nativebuffer-oh-nativebuffer-config.md)* config | 一个指向OH_NativeBuffer_Config的指针,用于接收OH_NativeBuffer的属性。 | 310 311### OH_NativeBuffer_Map() 312 313``` 314int32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr) 315``` 316 317**描述** 318 319将OH_NativeBuffer对应的ION内存映射到进程空间。<br>本接口需要与[OH_NativeBuffer_Unmap](capi-native-buffer-h.md#oh_nativebuffer_unmap)接口配合使用。<br>本接口为非线程安全类型接口。 320 321**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 322 323**起始版本:** 9 324 325 326**参数:** 327 328| 参数项 | 描述 | 329| -- | -- | 330| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 331| void **virAddr | 一个二级指针,二级指针指向映射到当前进程的虚拟内存的地址。 | 332 333**返回:** 334 335| 类型 | 说明 | 336| -- | -- | 337| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 338 339### OH_NativeBuffer_Unmap() 340 341``` 342int32_t OH_NativeBuffer_Unmap(OH_NativeBuffer *buffer) 343``` 344 345**描述** 346 347将OH_NativeBuffer对应的ION内存从进程空间移除。<br>本接口为非线程安全类型接口。 348 349**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 350 351**起始版本:** 9 352 353 354**参数:** 355 356| 参数项 | 描述 | 357| -- | -- | 358| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 359 360**返回:** 361 362| 类型 | 说明 | 363| -- | -- | 364| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 365 366### OH_NativeBuffer_GetSeqNum() 367 368``` 369uint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer) 370``` 371 372**描述** 373 374获取OH_NativeBuffer的序列号。<br>本接口为非线程安全类型接口。 375 376**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 377 378**起始版本:** 9 379 380 381**参数:** 382 383| 参数项 | 描述 | 384| -- | -- | 385| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 386 387**返回:** 388 389| 类型 | 说明 | 390| -- | -- | 391| uint32_t | 返回对应OH_NativeBuffer的唯一序列号。 | 392 393### OH_NativeBuffer_SetColorSpace() 394 395``` 396int32_t OH_NativeBuffer_SetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace) 397``` 398 399**描述** 400 401为OH_NativeBuffer设置颜色空间属性。<br>本接口为非线程安全类型接口。 402 403**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 404 405**起始版本:** 11 406 407 408**参数:** 409 410| 参数项 | 描述 | 411| -- | -- | 412| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 413| [OH_NativeBuffer_ColorSpace](capi-buffer-common-h.md#oh_nativebuffer_colorspace) colorSpace | 为OH_NativeBuffer设置的颜色空间,其值从[OH_NativeBuffer_ColorSpace](capi-buffer-common-h.md#oh_nativebuffer_colorspace)获取。 | 414 415**返回:** 416 417| 类型 | 说明 | 418| -- | -- | 419| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 420 421### OH_NativeBuffer_MapPlanes() 422 423``` 424int32_t OH_NativeBuffer_MapPlanes(OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes) 425``` 426 427**描述** 428 429将OH_NativeBuffer对应的多通道ION内存映射到进程空间。<br>本接口为非线程安全类型接口。 430 431**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 432 433**起始版本:** 12 434 435 436**参数:** 437 438| 参数项 | 描述 | 439| -- | -- | 440| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 441| void **virAddr | 一个二级指针,二级指针指向映射到当前进程的虚拟内存的地址。 | 442| [OH_NativeBuffer_Planes](capi-oh-nativebuffer-oh-nativebuffer-planes.md) *outPlanes | 一个指向所有图像平面格式信息的指针。 | 443 444**返回:** 445 446| 类型 | 说明 | 447| -- | -- | 448| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 449 450### OH_NativeBuffer_FromNativeWindowBuffer() 451 452``` 453int32_t OH_NativeBuffer_FromNativeWindowBuffer(OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer) 454``` 455 456**描述** 457 458将OHNativeWindowBuffer实例转换为OH_NativeBuffer实例。<br>本接口为非线程安全类型接口。 459 460**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 461 462**起始版本:** 12 463 464 465**参数:** 466 467| 参数项 | 描述 | 468| -- | -- | 469| [OHNativeWindowBuffer](capi-nativewindow-nativewindowbuffer.md) *nativeWindowBuffer | 一个指向[OHNativeWindowBuffer](capi-nativewindow-nativewindowbuffer.md)实例的指针。 | 470| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) **buffer | 一个指向OH_NativeBuffer实例的指针。 | 471 472**返回:** 473 474| 类型 | 说明 | 475| -- | -- | 476| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 477 478### OH_NativeBuffer_GetColorSpace() 479 480``` 481int32_t OH_NativeBuffer_GetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace) 482``` 483 484**描述** 485 486获取OH_NativeBuffer颜色空间属性。<br>本接口为非线程安全类型接口。 487 488**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 489 490**起始版本:** 12 491 492 493**参数:** 494 495| 参数项 | 描述 | 496| -- | -- | 497| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 498| [OH_NativeBuffer_ColorSpace](capi-buffer-common-h.md#oh_nativebuffer_colorspace) *colorSpace | 为[OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md)设置的颜色空间,其值从[OH_NativeBuffer_ColorSpace](capi-buffer-common-h.md#oh_nativebuffer_colorspace)获取。 | 499 500**返回:** 501 502| 类型 | 说明 | 503| -- | -- | 504| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 505 506### OH_NativeBuffer_SetMetadataValue() 507 508``` 509int32_t OH_NativeBuffer_SetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey,int32_t size, uint8_t *metadata) 510``` 511 512**描述** 513 514为OH_NativeBuffer设置元数据属性值。<br>本接口为非线程安全类型接口。 515 516**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 517 518**起始版本:** 12 519 520 521**参数:** 522 523| 参数项 | 描述 | 524| -- | -- | 525| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 526| [OH_NativeBuffer_MetadataKey](capi-buffer-common-h.md#oh_nativebuffer_metadatakey) metadataKey | [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md)的元数据类型,其值从[OH_NativeBuffer_MetadataKey](capi-buffer-common-h.md#oh_nativebuffer_metadatakey)获取。 | 527| int32_t size | uint8_t向量的大小,其取值范围参考[OH_NativeBuffer_MetadataKey](capi-buffer-common-h.md#oh_nativebuffer_metadatakey)。 | 528| metaData | 指向uint8_t向量的指针。 | 529 530**返回:** 531 532| 类型 | 说明 | 533| -- | -- | 534| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 535 536### OH_NativeBuffer_GetMetadataValue() 537 538``` 539int32_t OH_NativeBuffer_GetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey,int32_t *size, uint8_t **metadata) 540``` 541 542**描述** 543 544获取OH_NativeBuffer元数据属性值。<br>本接口为非线程安全类型接口。 545 546**系统能力:** SystemCapability.Graphic.Graphic2D.NativeBuffer 547 548**起始版本:** 12 549 550**参数:** 551 552| 参数项 | 描述 | 553| -- | -- | 554| [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md) *buffer | 一个指向OH_NativeBuffer实例的指针。 | 555| [OH_NativeBuffer_MetadataKey](capi-buffer-common-h.md#oh_nativebuffer_metadatakey) metadataKey | [OH_NativeBuffer](capi-oh-nativebuffer-oh-nativebuffer.md)的元数据类型,其值从[OH_NativeBuffer_MetadataKey](capi-buffer-common-h.md#oh_nativebuffer_metadatakey)获取。 | 556| int32_t *size | uint8_t向量的大小,其取值范围参考[OH_NativeBuffer_MetadataKey](capi-buffer-common-h.md#oh_nativebuffer_metadatakey)。 | 557| metaData | 指向uint8_t向量的二级指针。 | 558 559**返回:** 560 561| 类型 | 说明 | 562| -- | -- | 563| int32_t | 返回值为0表示执行成功,其他返回值可参考[OHNativeErrorCode](capi-graphic-error-code-h.md#ohnativeerrorcode)。 | 564 565 566