1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup ImageEffect 18 * @{ 19 * 20 * @brief Provides APIs for obtaining and using a image filter. 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file image_effect_filter.h 27 * 28 * @brief Declares the functions for setting filter parameters, registering custom filter and filter lookup information. 29 * 30 * @library libimage_effect.so 31 * @syscap SystemCapability.Multimedia.ImageEffect.Core 32 * @since 12 33 */ 34 35 #ifndef NATIVE_IMAGE_EFFECT_FILTER_H 36 #define NATIVE_IMAGE_EFFECT_FILTER_H 37 38 #include <stdint.h> 39 #include "image_effect_errors.h" 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 typedef struct OH_PixelmapNative OH_PixelmapNative; 46 47 /** 48 * @brief Define the new type name OH_EffectFilter for struct OH_EffectFilter 49 * 50 * @syscap SystemCapability.Multimedia.ImageEffect.Core 51 * @since 12 52 */ 53 typedef struct OH_EffectFilter OH_EffectFilter; 54 55 /** 56 * @brief Define the brightness filter name that contain the parameter matched with the key refer to 57 * {@link OH_EFFECT_FILTER_INTENSITY_KEY} and the value refer to {@link ImageEffect_Any} that contain the data type of 58 * {@link EFFECT_DATA_TYPE_FLOAT} 59 * 60 * @syscap SystemCapability.Multimedia.ImageEffect.Core 61 * @since 12 62 */ 63 #define OH_EFFECT_BRIGHTNESS_FILTER "Brightness" 64 65 /** 66 * @brief Define the contrast filter name that contain the parameter matched with the key refer to 67 * {@link OH_EFFECT_FILTER_INTENSITY_KEY} and the value refer to {@link ImageEffect_Any} that contain the data type of 68 * {@link EFFECT_DATA_TYPE_FLOAT} 69 * 70 * @syscap SystemCapability.Multimedia.ImageEffect.Core 71 * @since 12 72 */ 73 #define OH_EFFECT_CONTRAST_FILTER "Contrast" 74 75 /** 76 * @brief Define the crop filter name that contain the parameter matched with the key refer to 77 * {@link OH_EFFECT_FILTER_REGION_KEY} and the value refer to {@link ImageEffect_Any} that contain the data type of 78 * {@link EFFECT_DATA_TYPE_PTR} for @{link ImageEffect_Region} 79 * 80 * @syscap SystemCapability.Multimedia.ImageEffect.Core 81 * @since 12 82 */ 83 #define OH_EFFECT_CROP_FILTER "Crop" 84 85 /** 86 * @brief Define the key that means intensity 87 * 88 * @syscap SystemCapability.Multimedia.ImageEffect.Core 89 * @since 12 90 */ 91 #define OH_EFFECT_FILTER_INTENSITY_KEY "FilterIntensity" 92 93 /** 94 * @brief Define the key that means region and matches the value ref to {@link ImageEffect_Any} contain the data type of 95 * {@link EFFECT_DATA_TYPE_PTR} for @{link ImageEffect_Region} 96 * 97 * @syscap SystemCapability.Multimedia.ImageEffect.Core 98 * @since 12 99 */ 100 #define OH_EFFECT_FILTER_REGION_KEY "FilterRegion" 101 102 /** 103 * @brief Enumerates the data type 104 * 105 * @syscap SystemCapability.Multimedia.ImageEffect.Core 106 * @since 12 107 */ 108 typedef enum ImageEffect_DataType { 109 /** unknown data type */ 110 EFFECT_DATA_TYPE_UNKNOWN = 0, 111 /** int32_t data type */ 112 EFFECT_DATA_TYPE_INT32 = 1, 113 /** float data type */ 114 EFFECT_DATA_TYPE_FLOAT = 2, 115 /** double data type */ 116 EFFECT_DATA_TYPE_DOUBLE = 3, 117 /** char data type */ 118 EFFECT_DATA_TYPE_CHAR = 4, 119 /** long data type */ 120 EFFECT_DATA_TYPE_LONG = 5, 121 /** bool data type */ 122 EFFECT_DATA_TYPE_BOOL = 6, 123 /** point data type */ 124 EFFECT_DATA_TYPE_PTR = 7, 125 } ImageEffect_DataType; 126 127 /** 128 * @brief Data value for the union 129 * 130 * @syscap SystemCapability.Multimedia.ImageEffect.Core 131 * @since 12 132 */ 133 typedef union ImageEffect_DataValue { 134 /** Parameter of 32-bit integer value matches with {@link EFFECT_DATA_TYPE_INT32} */ 135 int32_t int32Value; 136 /** Parameter of float value matches with {@link EFFECT_DATA_TYPE_FLOAT} */ 137 float floatValue; 138 /** Parameter of double value matches with {@link EFFECT_DATA_TYPE_DOUBLE} */ 139 double doubleValue; 140 /** Parameter of character value matches with {@link EFFECT_DATA_TYPE_CHAR} */ 141 char charValue; 142 /** Parameter of long integer value matches with {@link EFFECT_DATA_TYPE_LONG} */ 143 long longValue; 144 /** Parameter of bool value matches with {@link EFFECT_DATA_TYPE_BOOL} */ 145 bool boolValue; 146 /** Parameter of point value matches with {@link EFFECT_DATA_TYPE_PTR} */ 147 void *ptrValue; 148 } ImageEffect_DataValue; 149 150 /** 151 * @brief Data parameter struct information 152 * 153 * @syscap SystemCapability.Multimedia.ImageEffect.Core 154 * @since 12 155 */ 156 typedef struct ImageEffect_Any { 157 /** Effect any data type */ 158 ImageEffect_DataType dataType = ImageEffect_DataType::EFFECT_DATA_TYPE_UNKNOWN; 159 /** Effect any data value */ 160 ImageEffect_DataValue dataValue = { 0 }; 161 } ImageEffect_Any; 162 163 /** 164 * @brief Enumerates the pixel format type 165 * 166 * @syscap SystemCapability.Multimedia.ImageEffect.Core 167 * @since 12 168 */ 169 typedef enum ImageEffect_Format { 170 /** Unknown pixel format */ 171 EFFECT_PIXEL_FORMAT_UNKNOWN = 0, 172 /** RGBA8888 pixel format */ 173 EFFECT_PIXEL_FORMAT_RGBA8888 = 1, 174 /** NV21 pixel format */ 175 EFFECT_PIXEL_FORMAT_NV21 = 2, 176 /** NV12 pixel format */ 177 EFFECT_PIXEL_FORMAT_NV12 = 3, 178 /** RGBA 10bit pixel format */ 179 EFFECT_PIXEL_FORMAT_RGBA1010102 = 4, 180 /** YCBCR420 semi-planar 10bit pixel format */ 181 EFFECT_PIXEL_FORMAT_YCBCR_P010 = 5, 182 /** YCRCB420 semi-planar 10bit pixel format */ 183 EFFECT_PIXEL_FORMAT_YCRCB_P010 = 6, 184 } ImageEffect_Format; 185 186 /** 187 * @brief Enumerates the effect buffer type 188 * 189 * @syscap SystemCapability.Multimedia.ImageEffect.Core 190 * @since 12 191 */ 192 typedef enum ImageEffect_BufferType { 193 /** Unknown buffer type */ 194 EFFECT_BUFFER_TYPE_UNKNOWN = 0, 195 /** Pixel buffer type */ 196 EFFECT_BUFFER_TYPE_PIXEL = 1, 197 /** Texture buffer type */ 198 EFFECT_BUFFER_TYPE_TEXTURE = 2, 199 } ImageEffect_BufferType; 200 201 /** 202 * @brief Define the new type name OH_EffectFilterInfo for struct OH_EffectFilterInfo 203 * 204 * @syscap SystemCapability.Multimedia.ImageEffect.Core 205 * @since 12 206 */ 207 typedef struct OH_EffectFilterInfo OH_EffectFilterInfo; 208 209 /** 210 * @brief Create an OH_EffectFilterInfo instance. It should be noted that the life cycle of the OH_EffectFilterInfo 211 * instance pointed to by the return value * needs to be manually released by {@link OH_EffectFilterInfo_Release} 212 * 213 * @syscap SystemCapability.Multimedia.ImageEffect.Core 214 * @return Returns a pointer to an OH_EffectFilterInfo instance if the execution is successful, otherwise returns 215 * nullptr 216 * @since 12 217 */ 218 OH_EffectFilterInfo *OH_EffectFilterInfo_Create(); 219 220 /** 221 * @brief Set the filter name for OH_EffectFilterInfo structure 222 * 223 * @syscap SystemCapability.Multimedia.ImageEffect.Core 224 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 225 * @param name Indicates the filter name 226 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 227 * {@link ImageEffect_ErrorCode} 228 * @since 12 229 */ 230 ImageEffect_ErrorCode OH_EffectFilterInfo_SetFilterName(OH_EffectFilterInfo *info, const char *name); 231 232 /** 233 * @brief Get the filter name from OH_EffectFilterInfo structure 234 * 235 * @syscap SystemCapability.Multimedia.ImageEffect.Core 236 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 237 * @param name Indicates the filter name 238 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 239 * {@link ImageEffect_ErrorCode} 240 * @since 12 241 */ 242 ImageEffect_ErrorCode OH_EffectFilterInfo_GetFilterName(OH_EffectFilterInfo *info, char **name); 243 244 /** 245 * @brief Set the supported buffer types for OH_EffectFilterInfo structure 246 * 247 * @syscap SystemCapability.Multimedia.ImageEffect.Core 248 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 249 * @param size The size of {@link ImageEffect_BufferType} that can be supported 250 * @param bufferTypeArray Array of {@link ImageEffect_BufferType} that can be supported 251 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 252 * {@link ImageEffect_ErrorCode} 253 * @since 12 254 */ 255 ImageEffect_ErrorCode OH_EffectFilterInfo_SetSupportedBufferTypes(OH_EffectFilterInfo *info, uint32_t size, 256 ImageEffect_BufferType *bufferTypeArray); 257 258 /** 259 * @brief Get the supported buffer types from OH_EffectFilterInfo structure 260 * 261 * @syscap SystemCapability.Multimedia.ImageEffect.Core 262 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 263 * @param size The size of {@link OH_EffectBufferInfoType} that can be supported 264 * @param bufferTypeArray Array of {@link OH_EffectBufferInfoType} that can be supported 265 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 266 * {@link ImageEffect_ErrorCode} 267 * @since 12 268 */ 269 ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedBufferTypes(OH_EffectFilterInfo *info, uint32_t *size, 270 ImageEffect_BufferType **bufferTypeArray); 271 272 /** 273 * @brief Set the supported formats for OH_EffectFilterInfo structure 274 * 275 * @syscap SystemCapability.Multimedia.ImageEffect.Core 276 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 277 * @param size The size of {@link ImageEffect_Format} that can be supported 278 * @param formatArray Array of {@link ImageEffect_Format} that can be supported 279 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 280 * {@link ImageEffect_ErrorCode} 281 * @since 12 282 */ 283 ImageEffect_ErrorCode OH_EffectFilterInfo_SetSupportedFormats(OH_EffectFilterInfo *info, uint32_t size, 284 ImageEffect_Format *formatArray); 285 286 /** 287 * @brief Get the supported formats from OH_EffectFilterInfo structure 288 * 289 * @syscap SystemCapability.Multimedia.ImageEffect.Core 290 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 291 * @param size The size of {@link ImageEffect_Format} that can be supported 292 * @param formatArray Array of {@link ImageEffect_Format} that can be supported 293 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 294 * {@link ImageEffect_ErrorCode} 295 * @since 12 296 */ 297 ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedFormats(OH_EffectFilterInfo *info, uint32_t *size, 298 ImageEffect_Format **formatArray); 299 300 /** 301 * @brief Clear the internal resources of the OH_EffectFilterInfo and destroy the OH_EffectFilterInfo instance 302 * 303 * @syscap SystemCapability.Multimedia.ImageEffect.Core 304 * @param info Encapsulate OH_EffectFilterInfo structure instance pointer 305 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 306 * {@link ImageEffect_ErrorCode} 307 * @since 12 308 */ 309 ImageEffect_ErrorCode OH_EffectFilterInfo_Release(OH_EffectFilterInfo *info); 310 311 /** 312 * @brief EffectFilter names information 313 * 314 * @syscap SystemCapability.Multimedia.ImageEffect.Core 315 * @since 12 316 */ 317 typedef struct ImageEffect_FilterNames { 318 /** EffectFilter names array size */ 319 uint32_t size = 0; 320 /** EffectFilter names memory block */ 321 const char **nameList = nullptr; 322 } ImageEffect_FilterNames; 323 324 /** 325 * @brief Define the new type name OH_EffectBufferInfo for struct OH_EffectBufferInfo 326 * 327 * @syscap SystemCapability.Multimedia.ImageEffect.Core 328 * @since 12 329 */ 330 typedef struct OH_EffectBufferInfo OH_EffectBufferInfo; 331 332 /** 333 * @brief Create an OH_EffectBufferInfo instance. It should be noted that the life cycle of the OH_EffectBufferInfo 334 * instance pointed to by the return value * needs to be manually released by {@link OH_EffectBufferInfo_Release} 335 * 336 * @syscap SystemCapability.Multimedia.ImageEffect.Core 337 * @return Returns a pointer to an OH_EffectBufferInfo instance if the execution is successful, otherwise returns 338 * nullptr 339 * @since 12 340 */ 341 OH_EffectBufferInfo *OH_EffectBufferInfo_Create(); 342 343 /** 344 * @brief Set access to the address of the image in memory 345 * 346 * @syscap SystemCapability.Multimedia.ImageEffect.Core 347 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 348 * @param addr Indicates the address of the image in memory 349 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 350 * {@link ImageEffect_ErrorCode} 351 * @since 12 352 */ 353 ImageEffect_ErrorCode OH_EffectBufferInfo_SetAddr(OH_EffectBufferInfo *info, void *addr); 354 355 /** 356 * @brief Provide direct access to the address of the image in memory for rendering the filter effects 357 * 358 * @syscap SystemCapability.Multimedia.ImageEffect.Core 359 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 360 * @param addr Indicates the address of the image in memory 361 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 362 * {@link ImageEffect_ErrorCode} 363 * @since 12 364 */ 365 ImageEffect_ErrorCode OH_EffectBufferInfo_GetAddr(OH_EffectBufferInfo *info, void **addr); 366 367 /** 368 * @brief Set the width of the image in pixels 369 * 370 * @syscap SystemCapability.Multimedia.ImageEffect.Core 371 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 372 * @param width Indicates the width of the image 373 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 374 * {@link ImageEffect_ErrorCode} 375 * @since 12 376 */ 377 ImageEffect_ErrorCode OH_EffectBufferInfo_SetWidth(OH_EffectBufferInfo *info, int32_t width); 378 379 /** 380 * @brief Get the width of the image in pixels 381 * 382 * @syscap SystemCapability.Multimedia.ImageEffect.Core 383 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 384 * @param width Indicates the width of the image 385 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 386 * {@link ImageEffect_ErrorCode} 387 * @since 12 388 */ 389 ImageEffect_ErrorCode OH_EffectBufferInfo_GetWidth(OH_EffectBufferInfo *info, int32_t *width); 390 391 /** 392 * @brief Set the height of the image in pixels 393 * 394 * @syscap SystemCapability.Multimedia.ImageEffect.Core 395 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 396 * @param height Indicates the height of the image 397 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 398 * {@link ImageEffect_ErrorCode} 399 * @since 12 400 */ 401 ImageEffect_ErrorCode OH_EffectBufferInfo_SetHeight(OH_EffectBufferInfo *info, int32_t height); 402 403 /** 404 * @brief Get the height of the image in pixels 405 * 406 * @syscap SystemCapability.Multimedia.ImageEffect.Core 407 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 408 * @param height Indicates the height of the image 409 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 410 * {@link ImageEffect_ErrorCode} 411 * @since 12 412 */ 413 ImageEffect_ErrorCode OH_EffectBufferInfo_GetHeight(OH_EffectBufferInfo *info, int32_t *height); 414 415 /** 416 * @brief Set number of bytes per row for the image 417 * 418 * @syscap SystemCapability.Multimedia.ImageEffect.Core 419 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 420 * @param rowSize Indicates number of bytes per row 421 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 422 * {@link ImageEffect_ErrorCode} 423 * @since 12 424 */ 425 ImageEffect_ErrorCode OH_EffectBufferInfo_SetRowSize(OH_EffectBufferInfo *info, int32_t rowSize); 426 427 /** 428 * @brief Get number of bytes per row for the image 429 * 430 * @syscap SystemCapability.Multimedia.ImageEffect.Core 431 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 432 * @param rowSize Indicates number of bytes per row 433 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 434 * {@link ImageEffect_ErrorCode} 435 * @since 12 436 */ 437 ImageEffect_ErrorCode OH_EffectBufferInfo_GetRowSize(OH_EffectBufferInfo *info, int32_t *rowSize); 438 439 /** 440 * @brief Set the format of the image for OH_EffectBufferInfo 441 * 442 * @syscap SystemCapability.Multimedia.ImageEffect.Core 443 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 444 * @param format Indicates {@link ImageEffect_Format} of the image 445 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 446 * {@link ImageEffect_ErrorCode} 447 * @since 12 448 */ 449 ImageEffect_ErrorCode OH_EffectBufferInfo_SetEffectFormat(OH_EffectBufferInfo *info, ImageEffect_Format format); 450 451 /** 452 * @brief Get the format of the image from OH_EffectBufferInfo 453 * 454 * @syscap SystemCapability.Multimedia.ImageEffect.Core 455 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 456 * @param format Indicates {@link ImageEffect_Format} of the image 457 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 458 * {@link ImageEffect_ErrorCode} 459 * @since 12 460 */ 461 ImageEffect_ErrorCode OH_EffectBufferInfo_GetEffectFormat(OH_EffectBufferInfo *info, ImageEffect_Format *format); 462 463 /** 464 * @brief Set the timestamp of the image for OH_EffectBufferInfo 465 * 466 * @syscap SystemCapability.Multimedia.ImageEffect.Core 467 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 468 * @param timestamp Indicates the timestamp of the image frame data for the OHNativeWindow input type. 469 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 470 * {@link ImageEffect_ErrorCode} 471 * {@link EFFECT_ERROR_PARAM_INVALID}, the input parameter is a null pointer. 472 * @since 12 473 */ 474 ImageEffect_ErrorCode OH_EffectBufferInfo_SetTimestamp(OH_EffectBufferInfo *info, int64_t timestamp); 475 476 /** 477 * @brief Get the timestamp of the image from OH_EffectBufferInfo 478 * 479 * @syscap SystemCapability.Multimedia.ImageEffect.Core 480 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 481 * @param timestamp Indicates the timestamp of the image frame data for the OHNativeWindow input type. 482 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 483 * {@link ImageEffect_ErrorCode} 484 * {@link EFFECT_ERROR_PARAM_INVALID}, the input parameter is a null pointer. 485 * @since 12 486 */ 487 ImageEffect_ErrorCode OH_EffectBufferInfo_GetTimestamp(OH_EffectBufferInfo *info, int64_t *timestamp); 488 489 /** 490 * @brief Clear the internal resources of the OH_EffectBufferInfo and destroy the OH_EffectBufferInfo instance 491 * 492 * @syscap SystemCapability.Multimedia.ImageEffect.Core 493 * @param info Encapsulate OH_EffectBufferInfo structure instance pointer 494 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 495 * {@link ImageEffect_ErrorCode} 496 * @since 12 497 */ 498 ImageEffect_ErrorCode OH_EffectBufferInfo_Release(OH_EffectBufferInfo *info); 499 500 /** 501 * @brief When executing the method of {@link OH_EffectFilter_SetValue} for the delegate filter, the function pointer 502 * will be called for checking the parameters is valid for the delegate filter 503 * 504 * @syscap SystemCapability.Multimedia.ImageEffect.Core 505 * @param filter Encapsulate OH_EffectFilter structure instance pointer 506 * @param key Indicates the key of the filter 507 * @param value Indicates the value corresponding to the key of the filter 508 * @return Returns true if the parameter is valid, otherwise returns false 509 * @since 12 510 */ 511 typedef bool (*OH_EffectFilterDelegate_SetValue)(OH_EffectFilter *filter, const char *key, 512 const ImageEffect_Any *value); 513 514 /** 515 * @brief Actively execute this callback function at the end of invoking the method of 516 * {@link OH_EffectFilterDelegate_Render} for passing possible new OH_EffectBufferInfo to the next filter. It should be 517 * noted that when passing new OH_EffectBufferInfo, the buffer in OH_EffectBufferInfo needs to be manually released 518 * after the execution of the function ends 519 * 520 * @syscap SystemCapability.Multimedia.ImageEffect.Core 521 * @param filter Encapsulate OH_EffectFilter structure instance pointer 522 * @param info Indicates the information of the image, such as width, height, etc. See {@link OH_EffectBufferInfo} 523 * @since 12 524 */ 525 typedef void (*OH_EffectFilterDelegate_PushData)(OH_EffectFilter *filter, OH_EffectBufferInfo *info); 526 527 /** 528 * @brief When the method of OH_ImageEffect_Start is executed on delegate filter that is contained in OH_ImageEffect, 529 * the function pointer will be called for rendering the delegate filter effects 530 * 531 * @syscap SystemCapability.Multimedia.ImageEffect.Core 532 * @param filter Encapsulate OH_EffectFilter structure instance pointer 533 * @param info Indicates the information of the image, such as width, height, etc. See {@link OH_EffectBufferInfo} 534 * @param pushData Indicates the callback function for passing possible new OH_EffectBufferInfo to the next filter. See 535 * {@link OH_EffectFilterDelegate_PushData} 536 * @return Returns true if this function point is executed successfully, otherwise returns false 537 * @since 12 538 */ 539 typedef bool (*OH_EffectFilterDelegate_Render)(OH_EffectFilter *filter, OH_EffectBufferInfo *info, 540 OH_EffectFilterDelegate_PushData pushData); 541 542 /** 543 * @brief When the method of OH_ImageEffect_Save is executed on delegate filter that is contained in OH_ImageEffect, 544 * the function pointer will be called for serializing the delegate filter parameters 545 * 546 * @syscap SystemCapability.Multimedia.ImageEffect.Core 547 * @param filter Encapsulate OH_EffectFilter structure instance pointer 548 * @param info Indicates the serialized information that is obtained by converting the delegate filter parameters to 549 * JSON string 550 * @return Returns true if this function point is executed successfully, otherwise returns false 551 * @since 12 552 */ 553 typedef bool (*OH_EffectFilterDelegate_Save)(OH_EffectFilter *filter, char **info); 554 555 /** 556 * @brief When the method of OH_ImageEffect_Restore is executed on delegate filter that is contained in OH_ImageEffect, 557 * the function pointer will be called for deserializing the delegate filter parameters 558 * 559 * @syscap SystemCapability.Multimedia.ImageEffect.Core 560 * @param info Indicates the serialized information that is obtained by converting the delegate filter parameters to 561 * JSON string 562 * @return Returns a pointer to an OH_EffectFilter instance if the execution is successful, otherwise returns nullptr 563 * @since 12 564 */ 565 typedef OH_EffectFilter *(*OH_EffectFilterDelegate_Restore)(const char *info); 566 567 /** 568 * @brief A collection of all callback function pointers in OH_EffectFilter. Register an instance of this structure to 569 * the OH_EffectFilter instance by invoking {@link OH_EffectFilter_Register}, and perform related rendering operations 570 * through the callback 571 * 572 * @syscap SystemCapability.Multimedia.ImageEffect.Core 573 * @since 12 574 */ 575 typedef struct ImageEffect_FilterDelegate { 576 /** Monitor checking parameters */ 577 OH_EffectFilterDelegate_SetValue setValue; 578 /** Monitor render */ 579 OH_EffectFilterDelegate_Render render; 580 /** Monitor serialize */ 581 OH_EffectFilterDelegate_Save save; 582 /** Monitor deserialize */ 583 OH_EffectFilterDelegate_Restore restore; 584 } ImageEffect_FilterDelegate; 585 586 /** 587 * @brief Describes the region information 588 * 589 * @syscap SystemCapability.Multimedia.ImageEffect.Core 590 * @since 12 591 */ 592 typedef struct ImageEffect_Region { 593 /** X coordinate of the start point of a line */ 594 int32_t x0; 595 /** Y coordinate of the start point of a line */ 596 int32_t y0; 597 /** X coordinate of the end point of a line */ 598 int32_t x1; 599 /** Y coordinate of the end point of a line */ 600 int32_t y1; 601 } ImageEffect_Region; 602 603 /** 604 * @brief Describes the image size information 605 * 606 * @syscap SystemCapability.Multimedia.ImageEffect.Core 607 * @since 12 608 */ 609 typedef struct ImageEffect_Size { 610 /** Image width, in pixels */ 611 int32_t width; 612 /** Image height, in pixels */ 613 int32_t height; 614 } ImageEffect_Size; 615 616 /** 617 * @brief Create an OH_EffectFilter instance. It should be noted that the life cycle of the OH_EffectFilter instance 618 * pointed to by the return value * needs to be manually released by {@link OH_EffectFilter_Release} 619 * 620 * @syscap SystemCapability.Multimedia.ImageEffect.Core 621 * @param name Indicates the filter name. For example, see {@link OH_EFFECT_BRIGHTNESS_FILTER} 622 * @return Returns a pointer to an OH_EffectFilter instance if the execution is successful, otherwise returns nullptr 623 * @since 12 624 */ 625 OH_EffectFilter *OH_EffectFilter_Create(const char *name); 626 627 /** 628 * @brief Set the filter parameter. It can be set multiple parameters by invoking this function multiple times 629 * 630 * @syscap SystemCapability.Multimedia.ImageEffect.Core 631 * @param filter Encapsulate OH_EffectFilter structure instance pointer 632 * @param key Indicates the key of the filter. For example, see {@link OH_EFFECT_FILTER_INTENSITY_KEY} 633 * @param value Indicates the value corresponding to the key of the filter 634 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 635 * {@link ImageEffect_ErrorCode} 636 * @since 12 637 */ 638 ImageEffect_ErrorCode OH_EffectFilter_SetValue(OH_EffectFilter *filter, const char *key, const ImageEffect_Any *value); 639 640 /** 641 * @brief Get the filter parameter 642 * 643 * @syscap SystemCapability.Multimedia.ImageEffect.Core 644 * @param filter Encapsulate OH_EffectFilter structure instance pointer 645 * @param key Indicates the key of the filter 646 * @param value Indicates the value corresponding to the key of the filter 647 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 648 * {@link ImageEffect_ErrorCode} 649 * @since 12 650 */ 651 ImageEffect_ErrorCode OH_EffectFilter_GetValue(OH_EffectFilter *filter, const char *key, ImageEffect_Any *value); 652 653 /** 654 * @brief Register the delegate filter 655 * 656 * @syscap SystemCapability.Multimedia.ImageEffect.Core 657 * @param info Indicates the capabilities supported by delegate filter, see {@link OH_EffectFilterInfo} 658 * @param delegate A collection of all callback functions, see {@link ImageEffect_FilterDelegate} 659 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 660 * {@link ImageEffect_ErrorCode} 661 * @since 12 662 */ 663 ImageEffect_ErrorCode OH_EffectFilter_Register(const OH_EffectFilterInfo *info, 664 const ImageEffect_FilterDelegate *delegate); 665 666 /** 667 * @brief Lookup for the filter names that matches the lookup condition. It should be noted that the allocated memory of 668 * ImageEffect_FilterNames can be manually released by invoking {@link OH_EffectFilter_ReleaseFilterNames} if need 669 * 670 * @syscap SystemCapability.Multimedia.ImageEffect.Core 671 * @param key Indicates the lookup condition 672 * @return Returns Filter name array that matches the key, see {@link ImageEffect_FilterNames} 673 * @since 12 674 */ 675 ImageEffect_FilterNames *OH_EffectFilter_LookupFilters(const char *key); 676 677 /** 678 * @brief Clear the internal cached resources of the ImageEffect_FilterNames 679 * 680 * @syscap SystemCapability.Multimedia.ImageEffect.Core 681 * @since 12 682 */ 683 void OH_EffectFilter_ReleaseFilterNames(); 684 685 /** 686 * @brief Lookup for the capabilities that supported by the filter 687 * 688 * @syscap SystemCapability.Multimedia.ImageEffect.Core 689 * @param name Indicates the filter name 690 * @param info Indicates the capabilities supported by the filter, see {@link OH_EffectFilterInfo} 691 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 692 * {@link ImageEffect_ErrorCode} 693 * @since 12 694 */ 695 ImageEffect_ErrorCode OH_EffectFilter_LookupFilterInfo(const char *name, OH_EffectFilterInfo *info); 696 697 /** 698 * @brief Render the filter effects. The function is designed to support the same input and output image 699 * 700 * @syscap SystemCapability.Multimedia.ImageEffect.Core 701 * @param filter Encapsulate OH_EffectFilter structure instance pointer 702 * @param inputPixelmap Indicates the input image 703 * @param outputPixelmap Indicates the output image 704 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 705 * {@link ImageEffect_ErrorCode} 706 * @since 12 707 */ 708 ImageEffect_ErrorCode OH_EffectFilter_Render(OH_EffectFilter *filter, OH_PixelmapNative *inputPixelmap, 709 OH_PixelmapNative *outputPixelmap); 710 711 /** 712 * @brief Clear the internal resources of the OH_EffectFilter and destroy the OH_EffectFilter instance 713 * 714 * @syscap SystemCapability.Multimedia.ImageEffect.Core 715 * @param filter Encapsulate OH_EffectFilter structure instance pointer 716 * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to 717 * {@link ImageEffect_ErrorCode} 718 * @since 12 719 */ 720 ImageEffect_ErrorCode OH_EffectFilter_Release(OH_EffectFilter *filter); 721 722 #ifdef __cplusplus 723 } 724 #endif 725 #endif // NATIVE_IMAGE_EFFECT_FILTER_H 726 /** @} */