1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
// automatically generated by rust-bindgen 0.71.1
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::image_processing_types::{
ImageProcessing_ColorSpaceInfo, ImageProcessing_ErrorCode, OH_ImageProcessing,
};
use ohos_sys_opaque_types::{OH_AVFormat, OH_PixelmapNative};
extern "C" {
/// Initialize global environment for image processing.
///
/// This function is optional.
///
/// Typically, this function is called once when the host process is started to initialize the global environment for
/// image processing, which can reduce the time of [`OH_ImageProcessing_Create`].
///
/// To deinitialize global environment, call [`OH_ImageProcessing_DeinitializeEnvironment`].
///
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if initialization is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED`] if initialization is failed.
///
/// You can check if the device GPU is working properly.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_InitializeEnvironment() -> ImageProcessing_ErrorCode;
/// Deinitialize global environment for image processing.
///
/// This function is required if [`OH_ImageProcessing_InitializeEnvironment`] is called. Typically, this
/// function is called when the host process is about to exit to deinitialize the global environment, which is
/// initialized by calling [`OH_ImageProcessing_InitializeEnvironment`].
///
/// If there is some image processing instance existing, this function should not be called.
///
/// If the [`OH_ImageProcessing_InitializeEnvironment`] is not called, this function should not be called.
///
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if deinitialization is successful.
///
/// [`IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED`] if some image processing instance is not destroyed or
/// [`OH_ImageProcessing_InitializeEnvironment`] is not called.
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_DeinitializeEnvironment() -> ImageProcessing_ErrorCode;
/// Query whether the image color space conversion is supported.
///
/// # Arguments
///
/// * `sourceImageInfo` - Input image color space information pointer.
///
/// * `destinationImageInfo` - Output image color space information pointer.
///
/// # Returns
///
/// * <b>true</b> if the color space conversion is supported.
///
/// <b>false</b> if the the color space conversion is unsupported.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_IsColorSpaceConversionSupported(
sourceImageInfo: *const ImageProcessing_ColorSpaceInfo,
destinationImageInfo: *const ImageProcessing_ColorSpaceInfo,
) -> bool;
/// Query whether the image composition is supported.
///
/// # Arguments
///
/// * `sourceImageInfo` - Input image color space information pointer.
///
/// * `sourceGainmapInfo` - Input gainmap color space information pointer.
///
/// * `destinationImageInfo` - Output image color space information pointer.
///
/// # Returns
///
/// * <b>true</b> if the image composition is supported.
///
/// <b>false</b> if the image composition is unsupported.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_IsCompositionSupported(
sourceImageInfo: *const ImageProcessing_ColorSpaceInfo,
sourceGainmapInfo: *const ImageProcessing_ColorSpaceInfo,
destinationImageInfo: *const ImageProcessing_ColorSpaceInfo,
) -> bool;
/// Query whether the image decomposition is supported.
///
/// # Arguments
///
/// * `sourceImageInfo` - Input image color space information pointer.
///
/// * `destinationImageInfo` - Output image color space information pointer.
///
/// * `destinationGainmapInfo` - Output gainmap information pointer.
///
/// # Returns
///
/// * <b>true</b> if the image decomposition is supported.
///
/// <b>false</b> if the image decomposition is unsupported.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_IsDecompositionSupported(
sourceImageInfo: *const ImageProcessing_ColorSpaceInfo,
destinationImageInfo: *const ImageProcessing_ColorSpaceInfo,
destinationGainmapInfo: *const ImageProcessing_ColorSpaceInfo,
) -> bool;
/// Query whether the image metadata generation is supported.
///
/// # Arguments
///
/// * `sourceImageInfo` - Input image color space information pointer.
///
/// # Returns
///
/// * <b>true</b> if the image metadata generation is supported..
///
/// <b>false</b> if the image metadata generation is unsupported.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_IsMetadataGenerationSupported(
sourceImageInfo: *const ImageProcessing_ColorSpaceInfo,
) -> bool;
/// Create an image processing instance.
///
/// # Arguments
///
/// * `imageProcessor` - Output parameter. The *imageProcessor points to a new image processing object.
/// The *imageProcessor must be null before passed in.
///
/// * `type` - Use IMAGE_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not
/// be changed.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if creating an image processing successfully.
///
/// [`IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the type is not supported. For example, if metadata
/// generation is not supported by vendor, it returns unsupported processing.
///
/// [`IMAGE_PROCESSING_ERROR_CREATE_FAILED`] if failed to create an image processing.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or <b>*</b>instance is <b>not</b> null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if type is invalid.
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_Create(
imageProcessor: *mut *mut OH_ImageProcessing,
type_: i32,
) -> ImageProcessing_ErrorCode;
/// Destroy the image processing instance.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer. It is recommended setting the
/// instance pointer to null after the instance is destroyed.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if the instance is destroyed successfully.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_Destroy(
imageProcessor: *mut OH_ImageProcessing,
) -> ImageProcessing_ErrorCode;
/// Set parameter for image processing.
///
/// Add parameter identified by the specified parameter key.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer.
///
/// * `parameter` - The parameter for image processing.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if setting parameter is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the parameter is null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_VALUE`] if some property of the parameter is invalid. For example, the parameter
/// contains unsupported parameter key or value.
///
/// [`IMAGE_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_SetParameter(
imageProcessor: *mut OH_ImageProcessing,
parameter: *const OH_AVFormat,
) -> ImageProcessing_ErrorCode;
/// Get parameter of image processing.
///
/// Get parameter identified by the specified parameter key.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer.
///
/// * `parameter` - The parameter used by the image processing instance.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if getting parameter is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the parameter is null.
///
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_GetParameter(
imageProcessor: *mut OH_ImageProcessing,
parameter: *mut OH_AVFormat,
) -> ImageProcessing_ErrorCode;
/// Conversion between single-layer images.
///
/// The function generate the destinationImage from sourceImage. It include the colorspace conversion from
/// HDR image to SDR image, SDR image to HDR image, SDR image to SDR image and HDR image to HDR image.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer. The instance should be created with
/// type [`IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION`].
///
/// * `sourceImage` - Input image pointer.
///
/// * `destinationImage` - Output image pointer.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if processing image is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the image is null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_VALUE`] if some property of image is invalid. For example, the color space
/// of the image is unsupported.
///
/// [`IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the processing is not supported.
///
/// [`IMAGE_PROCESSING_ERROR_PROCESS_FAILED`] if processing error occurs.
///
/// [`IMAGE_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_ConvertColorSpace(
imageProcessor: *mut OH_ImageProcessing,
sourceImage: *mut OH_PixelmapNative,
destinationImage: *mut OH_PixelmapNative,
) -> ImageProcessing_ErrorCode;
/// Composition from dual-layer HDR images to single-layer HDR images.
///
/// The function generate the destinationImage from sourceImage and sourceGainmap.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer. The instance should be created with
/// type [`IMAGE_PROCESSING_TYPE_COMPOSITION`].
///
/// * `sourceImage` - Input image pointer.
///
/// * `sourceGainmap` - Input gainmap pointer.
///
/// * `destinationImage` - Output image pointer.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if processing image is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the image is null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_VALUE`] if some property of image is invalid. For example, the color space
/// of the image is unsupported.
///
/// [`IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the processing is not supported.
///
/// [`IMAGE_PROCESSING_ERROR_PROCESS_FAILED`] if processing error occurs.
///
/// [`IMAGE_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_Compose(
imageProcessor: *mut OH_ImageProcessing,
sourceImage: *mut OH_PixelmapNative,
sourceGainmap: *mut OH_PixelmapNative,
destinationImage: *mut OH_PixelmapNative,
) -> ImageProcessing_ErrorCode;
/// Decomposition from single-layer HDR images to dual-layer HDR images.
///
/// The function generate the destinationImage and destinationGainmap from sourceImage.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer. The instance should be created with
/// type [`IMAGE_PROCESSING_TYPE_DECOMPOSITION`].
///
/// * `sourceImage` - Input image pointer.
///
/// * `destinationImage` - Output image pointer.
///
/// * `destinationGainmap` - Output gainmap pointer.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if processing image is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the image is null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_VALUE`] if some property of image is invalid. For example, the color space
/// of the image is unsupported.
///
/// [`IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the processing is not supported.
///
/// [`IMAGE_PROCESSING_ERROR_PROCESS_FAILED`] if processing error occurs.
///
/// [`IMAGE_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_Decompose(
imageProcessor: *mut OH_ImageProcessing,
sourceImage: *mut OH_PixelmapNative,
destinationImage: *mut OH_PixelmapNative,
destinationGainmap: *mut OH_PixelmapNative,
) -> ImageProcessing_ErrorCode;
/// Metadata Generation for HDR images.
///
/// The function generate metadata for the sourceImage.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer. The instance should be created with
/// type [`IMAGE_PROCESSING_TYPE_METADATA_GENERATION`].
///
/// * `sourceImage` - Input image pointer.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if processing image is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the image is null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_VALUE`] if some property of image is invalid. For example, the color space
/// of the image is unsupported.
///
/// [`IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the processing is not supported.
///
/// [`IMAGE_PROCESSING_ERROR_PROCESS_FAILED`] if processing error occurs.
///
/// [`IMAGE_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_GenerateMetadata(
imageProcessor: *mut OH_ImageProcessing,
sourceImage: *mut OH_PixelmapNative,
) -> ImageProcessing_ErrorCode;
/// Clarity enhancement for images.
///
/// The function generate the destinationImage from sourceImage with necessary scaling operation according to the size
/// preset in the sourceImage and destinationImage. Different levels of scaling methonds are provided to balance
/// performance and image quality.
///
/// # Arguments
///
/// * `imageProcessor` - An image processing instance pointer. The instance should be created with
/// type [`IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER`].
///
/// * `sourceImage` - Input image pointer.
///
/// * `destinationImage` - Output image pointer.
///
/// # Returns
///
/// * [`IMAGE_PROCESSING_SUCCESS`] if processing image is successful.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_INSTANCE`] if instance is null or not an image processing instance.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_PARAMETER`] if the image is null.
///
/// [`IMAGE_PROCESSING_ERROR_INVALID_VALUE`] if some property of image is invalid. For example, the color space
/// of the image is unsupported.
///
/// [`IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING`] if the processing is not supported.
///
/// [`IMAGE_PROCESSING_ERROR_PROCESS_FAILED`] if processing error occurs.
///
/// [`IMAGE_PROCESSING_ERROR_NO_MEMORY`] if memory allocation failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_ImageProcessing_EnhanceDetail(
imageProcessor: *mut OH_ImageProcessing,
sourceImage: *mut OH_PixelmapNative,
destinationImage: *mut OH_PixelmapNative,
) -> ImageProcessing_ErrorCode;
}