oiio-sys 0.4.1

Rust sys bindings for OpenImageIO https://github.com/AcademySoftwareFoundation/OpenImageIO
Documentation
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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
pub use ffi::*;

// ROI
#[repr(C)]
pub struct ROI {
    pub xbegin: i32,
    pub xend: i32,
    pub ybegin: i32,
    pub yend: i32,
    pub zbegin: i32,
    pub zend: i32,
    pub chbegin: i32,
    pub chend: i32,
}

unsafe impl cxx::ExternType for ROI {
    type Id = cxx::type_id!("oiio::ROI");
    type Kind = cxx::kind::Trivial;
}

#[repr(i32)]
pub enum OpenMode {
    Create,
    AppendSubimage,
    AppendMIPLevel,
}

unsafe impl cxx::ExternType for OpenMode {
    type Id = cxx::type_id!("oiio::OpenMode");
    type Kind = cxx::kind::Trivial;
}

// This is the raw, signature-compatible FFI layer. Safety contracts and
// operation-oriented arguments belong on the public wrappers in `oiio`.
#[allow(clippy::missing_safety_doc, clippy::too_many_arguments)]
#[cxx::bridge(namespace = oiio)]
mod ffi {
    struct ExtensionMapItem {
        key: String,
        value: Vec<String>,
    }

    unsafe extern "C++" {
        include!("oiio-sys/src/ffi_imageio.h");

        type DeepData = crate::deepdata::DeepData;
        type IOProxy = crate::filesystem::IOProxy;
        type ROI = crate::imageio::ROI;
        type TypeDesc = crate::typedesc::TypeDesc;
        type ImageBuf = crate::imagebuf::ImageBuf;

        // ROI
        pub fn roi_default() -> ROI;
        #[allow(clippy::too_many_arguments)]
        pub fn roi_new(
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            chbegin: i32,
            chend: i32,
        ) -> ROI;
        pub fn roi_new_all() -> ROI;
        pub fn roi_defined(rpo: &ROI) -> bool;
        pub fn roi_width(rpo: &ROI) -> i32;
        pub fn roi_height(rpo: &ROI) -> i32;
        pub fn roi_depth(rpo: &ROI) -> i32;
        pub fn roi_nchannels(rpo: &ROI) -> i32;
        pub fn roi_npixels(rpo: &ROI) -> u64;
        pub fn roi_eq_roi(rpo: &ROI, other: &ROI) -> bool;
        pub fn roi_ne_roi(rpo: &ROI, other: &ROI) -> bool;
        pub fn roi_contains(rpo: &ROI, x: i32, y: i32, z: i32, ch: i32) -> bool;
        pub fn roi_contains_roi(rpo: &ROI, other: &ROI) -> bool;
        pub fn roi_union(rpo: &ROI, other: &ROI) -> ROI;
        pub fn roi_intersection(rpo: &ROI, other: &ROI) -> ROI;

        // ImageSpec
        pub type ImageSpec;

        pub fn imagespec_from_resolution(xres: i32, yres: i32, nchans: i32)
            -> UniquePtr<ImageSpec>;
        pub fn imagespec_new(
            xres: i32,
            yres: i32,
            nchans: i32,
            format: TypeDesc,
        ) -> UniquePtr<ImageSpec>;
        pub fn imagespec_copy(spec: &ImageSpec) -> UniquePtr<ImageSpec>;
        pub fn imagespec_format(spec: &ImageSpec) -> TypeDesc;
        pub fn imagespec_set_format(spec: Pin<&mut ImageSpec>, format: TypeDesc);
        pub fn imagespec_set_origin(spec: Pin<&mut ImageSpec>, x: i32, y: i32, z: i32);
        pub fn imagespec_set_dimensions(
            spec: Pin<&mut ImageSpec>,
            width: i32,
            height: i32,
            depth: i32,
        );
        pub fn imagespec_set_full(
            spec: Pin<&mut ImageSpec>,
            full_x: i32,
            full_y: i32,
            full_z: i32,
            full_width: i32,
            full_height: i32,
            full_depth: i32,
        );
        pub fn imagespec_set_tile_size(
            spec: Pin<&mut ImageSpec>,
            width: i32,
            height: i32,
            depth: i32,
        );
        pub fn imagespec_set_channel_names(spec: Pin<&mut ImageSpec>, names: &Vec<String>);
        pub fn imagespec_set_channelformats(spec: Pin<&mut ImageSpec>, formats: &[TypeDesc]);
        pub fn imagespec_set_alpha_channel(spec: Pin<&mut ImageSpec>, index: i32);
        pub fn imagespec_set_z_channel(spec: Pin<&mut ImageSpec>, index: i32);
        pub fn imagespec_set_deep(spec: Pin<&mut ImageSpec>, deep: bool);
        pub fn imagespec_attribute_int(spec: Pin<&mut ImageSpec>, name: &str, value: i32);
        pub fn imagespec_attribute_float(spec: Pin<&mut ImageSpec>, name: &str, value: f32);
        pub fn imagespec_attribute_string(spec: Pin<&mut ImageSpec>, name: &str, value: &str);
        pub fn imagespec_erase_attribute(spec: Pin<&mut ImageSpec>, name: &str) -> bool;
        pub fn imagespec_has_attribute(spec: &ImageSpec, name: &str) -> bool;
        pub fn imagespec_attribute_type(spec: &ImageSpec, name: &str) -> TypeDesc;
        pub fn imagespec_get_int_attribute(spec: &ImageSpec, name: &str, defaultval: i32) -> i32;
        pub fn imagespec_get_float_attribute(spec: &ImageSpec, name: &str, defaultval: f32) -> f32;
        pub fn imagespec_get_string_attribute(
            spec: &ImageSpec,
            name: &str,
            defaultval: &str,
        ) -> String;
        pub fn imagespec_attribute_to_string(spec: &ImageSpec, name: &str) -> String;
        pub fn imagespec_attribute_bytes(spec: &ImageSpec, name: &str) -> Vec<u8>;
        pub fn attribute_bytes_are_writable(type_name: &str, length: usize) -> bool;

        pub fn imagespec_attribute_set_bytes(
            spec: Pin<&mut ImageSpec>,
            name: &str,
            type_name: &str,
            bytes: &[u8],
        ) -> bool;
        pub fn imagespec_attribute_strings(spec: &ImageSpec, name: &str) -> Vec<String>;
        pub fn imagespec_attribute_set_strings(
            spec: Pin<&mut ImageSpec>,
            name: &str,
            type_name: &str,
            values: &Vec<String>,
        ) -> bool;
        pub fn imagespec_vector_new() -> UniquePtr<CxxVector<ImageSpec>>;
        pub fn imagespec_vector_push(specs: Pin<&mut CxxVector<ImageSpec>>, spec: &ImageSpec);
        pub fn imagespec_attribute_names(spec: &ImageSpec) -> Vec<String>;
        pub fn imagespec_x(spec: &ImageSpec) -> i32;
        pub fn imagespec_y(spec: &ImageSpec) -> i32;
        pub fn imagespec_z(spec: &ImageSpec) -> i32;
        pub fn imagespec_width(spec: &ImageSpec) -> i32;
        pub fn imagespec_height(spec: &ImageSpec) -> i32;
        pub fn imagespec_depth(spec: &ImageSpec) -> i32;
        pub fn imagespec_full_x(spec: &ImageSpec) -> i32;
        pub fn imagespec_full_y(spec: &ImageSpec) -> i32;
        pub fn imagespec_full_z(spec: &ImageSpec) -> i32;
        pub fn imagespec_full_width(spec: &ImageSpec) -> i32;
        pub fn imagespec_full_height(spec: &ImageSpec) -> i32;
        pub fn imagespec_full_depth(spec: &ImageSpec) -> i32;
        pub fn imagespec_tile_width(spec: &ImageSpec) -> i32;
        pub fn imagespec_tile_height(spec: &ImageSpec) -> i32;
        pub fn imagespec_tile_depth(spec: &ImageSpec) -> i32;
        pub fn imagespec_nchannels(spec: &ImageSpec) -> i32;
        pub fn imagespec_alpha_channel(spec: &ImageSpec) -> i32;
        pub fn imagespec_z_channel(spec: &ImageSpec) -> i32;
        pub fn imagespec_deep(spec: &ImageSpec) -> bool;
        pub fn imagespec_valid(spec: &ImageSpec) -> bool;
        pub fn imagespec_channel_names(spec: &ImageSpec) -> UniquePtr<CxxVector<CxxString>>;
        pub fn imagespec_channelformats(spec: &ImageSpec) -> &[TypeDesc];

        // ImageInput
        pub type ImageInput;

        pub fn imageinput_open_with_config(
            filename: &str,
            config: &ImageSpec,
        ) -> Result<UniquePtr<ImageInput>>;
        pub fn imageinput_open_without_config(filename: &str) -> Result<UniquePtr<ImageInput>>;
        pub fn imageinput_create_with_config(
            filename: &str,
            do_open: bool,
            config: &ImageSpec,
            plugin_searchpath: &str,
        ) -> Result<UniquePtr<ImageInput>>;
        pub fn imageinput_create_without_config(
            filename: &str,
            do_open: bool,
            plugin_searchpath: &str,
        ) -> Result<UniquePtr<ImageInput>>;
        pub fn imageinput_format_name(imageinput: &ImageInput) -> &str;
        pub fn imageinput_supports(imageinput: &ImageInput, feature: &str) -> bool;
        pub fn imageinput_valid_file(imageinput: &ImageInput, filename: &str) -> bool;
        pub fn imageinput_spec(imageinput: &ImageInput) -> &ImageSpec;
        pub fn imageinput_spec_subimage_miplevel(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
        ) -> UniquePtr<ImageSpec>;
        pub fn imageinput_spec_dimensions(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
        ) -> UniquePtr<ImageSpec>;
        /// Safety: must be called with a valid ioproxy pointer that outlives
        /// the returned reader.
        pub unsafe fn imageinput_open_with_ioproxy(
            filename: &str,
            ioproxy: *mut IOProxy,
        ) -> UniquePtr<ImageInput>;
        pub fn imageinput_close(imageinput: Pin<&mut ImageInput>) -> bool;
        pub fn imageinput_current_subimage(imageinput: &ImageInput) -> i32;
        pub fn imageinput_current_miplevel(imageinput: &ImageInput) -> i32;
        pub fn imageinput_seek_subimage(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
        ) -> bool;
        pub unsafe fn imageinput_read_scanline(
            imageinput: Pin<&mut ImageInput>,
            y: i32,
            z: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
        ) -> bool;
        #[allow(clippy::too_many_arguments)]
        pub unsafe fn imageinput_read_scanlines(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            ybegin: i32,
            yend: i32,
            z: i32,
            chbegin: i32,
            chend: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
        ) -> bool;
        #[allow(clippy::too_many_arguments)]
        pub unsafe fn imageinput_read_image(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            chbegin: i32,
            chend: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
            zstride: i64,
        ) -> bool;
        /// The byte slice must be aligned for and contain initialized storage
        /// for `format`. Its length must exactly match the requested image.
        /// Safety: the buffer must be writable for its full length.
        pub unsafe fn imageinput_read_scanlines_span(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            ybegin: i32,
            yend: i32,
            z: i32,
            chbegin: i32,
            chend: i32,
            format: TypeDesc,
            data: &mut [u8],
        ) -> bool;

        /// Safety: the buffer must be writable for its full length.
        pub unsafe fn imageinput_read_tiles_span(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            chbegin: i32,
            chend: i32,
            format: TypeDesc,
            data: &mut [u8],
        ) -> bool;

        pub unsafe fn imageinput_read_image_span(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            chbegin: i32,
            chend: i32,
            format: TypeDesc,
            data: &mut [u8],
        ) -> bool;
        #[allow(clippy::too_many_arguments)]
        pub fn imageinput_read_native_image_bytes(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            data: &mut [u8],
            error: &mut String,
        ) -> bool;

        pub fn imageinput_read_native_deep_scanlines(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            ybegin: i32,
            yend: i32,
            z: i32,
            chbegin: i32,
            chend: i32,
            data: Pin<&mut DeepData>,
            error: &mut String,
        ) -> bool;
        #[allow(clippy::too_many_arguments)]
        pub fn imageinput_read_native_deep_tiles(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            chbegin: i32,
            chend: i32,
            data: Pin<&mut DeepData>,
            error: &mut String,
        ) -> bool;
        pub fn imageinput_read_native_deep_image(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            data: Pin<&mut DeepData>,
            error: &mut String,
        ) -> bool;
        pub unsafe fn imageinput_read_native_scanline(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            y: i32,
            z: i32,
            data: &mut [u8],
        ) -> bool;

        #[allow(clippy::too_many_arguments)]
        pub unsafe fn imageinput_read_native_scanlines(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            ybegin: i32,
            yend: i32,
            z: i32,
            chbegin: i32,
            chend: i32,
            data: &mut [u8],
        ) -> bool;

        pub unsafe fn imageinput_read_native_tile(
            imageinput: Pin<&mut ImageInput>,
            subimage: i32,
            miplevel: i32,
            x: i32,
            y: i32,
            z: i32,
            data: &mut [u8],
        ) -> bool;

        /// # Safety
        /// The caller-supplied x/y/z/channel ranges are forwarded to
        /// OpenImageIO, which sizes the read from them; `data` must be large
        /// enough for the requested block, matching the `unsafe` sibling
        /// `imageinput_read_native_tile`. Declared `unsafe` for the same reason
        /// as the rest of the raw-buffer read family.
        #[allow(clippy::too_many_arguments)]
        pub unsafe fn imageinput_read_native_tiles(
            imageinput: Pin<&mut ImageInput>,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            chbegin: i32,
            chend: i32,
            data: &mut [u8],
        ) -> bool;

        /// Set the IO proxy for this ImageInput.
        /// # Safety
        /// Must be called with a valid ioproxy pointer.
        pub unsafe fn imageinput_set_ioproxy(
            imageinput: Pin<&mut ImageInput>,
            ioproxy: *mut IOProxy,
        ) -> bool;

        pub fn imageinput_has_error(imageinput: &ImageInput) -> bool;

        pub fn imageinput_geterror(imageinput: Pin<&mut ImageInput>) -> String;

        pub fn imageinput_seterror(imageinput: Pin<&mut ImageInput>, message: &str);

        pub fn imageinput_set_threads(imageinput: Pin<&mut ImageInput>, n: i32);

        pub fn imageinput_threads(imageinput: &ImageInput) -> i32;

        // ImageOutput
        type OpenMode = crate::imageio::OpenMode;

        pub type ImageOutput;

        /// Safety: must be called with a valid ioproxy pointer.
        pub unsafe fn imageoutput_create(
            filename: &str,
            ioproxy: *mut IOProxy,
            plugin_searchpath: &str,
        ) -> UniquePtr<ImageOutput>;

        pub fn imageoutput_format_name(imageoutput: &ImageOutput) -> &str;

        pub fn imageoutput_supports(imageoutput: &ImageOutput, feature: &str) -> i32;

        pub fn imageoutput_open(
            imageoutput: Pin<&mut ImageOutput>,
            filename: &str,
            newspec: &ImageSpec,
            mode: OpenMode,
        ) -> bool;

        /// Safety: must be called with a valid specs pointer. The subimages
        /// must be less than or equal to the number of subimages in the specs.
        pub unsafe fn imageoutput_open_multi_subimage(
            imageoutput: Pin<&mut ImageOutput>,
            filename: &str,
            subimages: i32,
            specs: *const ImageSpec,
        ) -> bool;

        pub fn imageoutput_open_specs(
            imageoutput: Pin<&mut ImageOutput>,
            filename: &str,
            specs: &CxxVector<ImageSpec>,
        ) -> bool;

        pub fn imageoutput_spec(imageoutput: &ImageOutput) -> &ImageSpec;

        pub fn imageoutput_close(imageoutput: Pin<&mut ImageOutput>) -> bool;

        pub unsafe fn imageoutput_write_scanline(
            imageoutput: Pin<&mut ImageOutput>,
            y: i32,
            z: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
        ) -> bool;

        pub unsafe fn imageoutput_write_scanlines(
            imageoutput: Pin<&mut ImageOutput>,
            ybegin: i32,
            yend: i32,
            z: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
        ) -> bool;

        pub unsafe fn imageoutput_write_tile(
            imageoutput: Pin<&mut ImageOutput>,
            x: i32,
            y: i32,
            z: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
            zstride: i64,
        ) -> bool;

        pub unsafe fn imageoutput_write_tiles(
            imageoutput: Pin<&mut ImageOutput>,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
            zstride: i64,
        ) -> bool;

        pub unsafe fn imageoutput_write_rectangle(
            imageoutput: Pin<&mut ImageOutput>,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
            zstride: i64,
        ) -> bool;

        pub unsafe fn imageoutput_write_image(
            imageoutput: Pin<&mut ImageOutput>,
            format: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
            zstride: i64,
        ) -> bool;

        /// Safety: the buffer must hold initialized values of `format`.
        pub unsafe fn imageoutput_write_image_span(
            imageoutput: Pin<&mut ImageOutput>,
            format: TypeDesc,
            data: &[u8],
        ) -> bool;

        /// Safety: the buffer must hold initialized values of `format`.
        pub unsafe fn imageoutput_write_scanlines_span(
            imageoutput: Pin<&mut ImageOutput>,
            ybegin: i32,
            yend: i32,
            format: TypeDesc,
            data: &[u8],
        ) -> bool;

        /// Safety: the buffer must hold initialized values of `format`.
        pub unsafe fn imageoutput_write_tiles_span(
            imageoutput: Pin<&mut ImageOutput>,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            format: TypeDesc,
            data: &[u8],
        ) -> bool;

        /// Safety: the buffer must hold initialized values of `format`.
        pub unsafe fn imageoutput_write_rectangle_span(
            imageoutput: Pin<&mut ImageOutput>,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            format: TypeDesc,
            data: &[u8],
        ) -> bool;

        pub fn imageoutput_write_deep_scanlines(
            imageoutput: Pin<&mut ImageOutput>,
            ybegin: i32,
            yend: i32,
            z: i32,
            data: &DeepData,
        ) -> bool;

        pub fn imageoutput_write_deep_tiles(
            imageoutput: Pin<&mut ImageOutput>,
            xbegin: i32,
            xend: i32,
            ybegin: i32,
            yend: i32,
            zbegin: i32,
            zend: i32,
            data: &DeepData,
        ) -> bool;

        pub fn imageoutput_write_deep_image(
            imageoutput: Pin<&mut ImageOutput>,
            data: &DeepData,
        ) -> bool;

        pub fn imageoutput_set_thumbnail(
            imageoutput: Pin<&mut ImageOutput>,
            thumb: &ImageBuf,
        ) -> bool;

        pub unsafe fn imageoutput_copy_image(
            imageoutput: Pin<&mut ImageOutput>,
            imageinput: *mut ImageInput,
        ) -> bool;

        pub unsafe fn imageoutput_set_ioproxy(
            imageoutput: Pin<&mut ImageOutput>,
            ioproxy: *mut IOProxy,
        ) -> bool;

        pub fn imageoutput_has_error(imageoutput: &ImageOutput) -> bool;

        pub fn imageoutput_geterror(imageoutput: &ImageOutput, clear: bool) -> String;

        pub fn imageoutput_seterror(imageoutput: Pin<&mut ImageOutput>, message: &str);

        pub fn imageoutput_set_threads(imageoutput: Pin<&mut ImageOutput>, n: i32);

        pub fn imageoutput_threads(imageoutput: &ImageOutput) -> i32;

        pub fn shutdown();

        pub fn openimageio_version() -> i32;

        pub fn openimageio_build_version() -> i32;

        pub fn has_error() -> bool;

        pub fn get_error(clear: bool) -> String;

        pub unsafe fn attribute(name: &str, type_: TypeDesc, value: &mut [u8]) -> bool;

        pub fn attribute_float(name: &str, value: f32) -> bool;

        pub fn attribute_int(name: &str, value: i32) -> bool;

        pub fn attribute_string(name: &str, value: &str) -> bool;

        pub unsafe fn getattribute(name: &str, type_: TypeDesc, value: &mut [u8]) -> bool;

        pub fn getattribute_int(name: &str, value: &mut i32) -> bool;

        pub fn getattribute_float(name: &str, value: &mut f32) -> bool;

        pub fn getattribute_string(name: &str, value: &mut String) -> bool;

        pub fn get_int_attribute(name: &str, defaultval: i32) -> i32;

        pub fn get_float_attribute(name: &str, defaultval: f32) -> f32;

        pub fn get_string_attribute(name: &str, defaultval: &str) -> String;

        // pub unsafe fn declare_imageio_format(
        //     name: &str,
        //     input_creator: fn() -> *mut ImageInput,
        //     input_extensions: &[&str],
        //     output_creator: fn() -> *mut ImageOutput,
        //     output_extensions: &[&str],
        //     lib_version: &str,
        // );

        pub fn is_imageio_format_name(name: &str) -> bool;

        pub fn get_extension_map() -> Vec<ExtensionMapItem>;

        pub unsafe fn convert_pixel_values(
            src_type: TypeDesc,
            src: &[u8],
            dst_type: TypeDesc,
            dst: &mut [u8],
        ) -> bool;

        pub unsafe fn convert_image(
            nchannels: i32,
            width: i32,
            height: i32,
            depth: i32,
            src: &[u8],
            src_type: TypeDesc,
            src_xstride: i64,
            src_ystride: i64,
            src_zstride: i64,
            dst: &mut [u8],
            dst_type: TypeDesc,
            dst_xstride: i64,
            dst_ystride: i64,
            dst_zstride: i64,
        ) -> bool;

        pub unsafe fn parallel_convert_image(
            nchannels: i32,
            width: i32,
            height: i32,
            depth: i32,
            src: &[u8],
            src_type: TypeDesc,
            src_xstride: i64,
            src_ystride: i64,
            src_zstride: i64,
            dst: &mut [u8],
            dst_type: TypeDesc,
            dst_xstride: i64,
            dst_ystride: i64,
            dst_zstride: i64,
            nthreads: i32,
        ) -> bool;

        pub unsafe fn add_dither(
            nchannels: i32,
            width: i32,
            height: i32,
            depth: i32,
            data: *mut f32,
            xstride: i64,
            ystride: i64,
            zstride: i64,
            ditheramplitude: f32,
            alpha_channel: i32,
            z_channel: i32,
            ditherseed: u32,
            chorigin: i32,
            xorigin: i32,
            yorigin: i32,
            zorigin: i32,
        );

        pub unsafe fn premult(
            nchannels: i32,
            width: i32,
            height: i32,
            depth: i32,
            chbegin: i32,
            chend: i32,
            datatype: TypeDesc,
            data: &mut [u8],
            xstride: i64,
            ystride: i64,
            zstride: i64,
            alpha_channel: i32,
            z_channel: i32,
        );

        pub unsafe fn copy_image(
            nchannels: i32,
            width: i32,
            height: i32,
            depth: i32,
            src: &[u8],
            pixelsize: i64,
            src_xstride: i64,
            src_ystride: i64,
            src_zstride: i64,
            dst: &mut [u8],
            dst_xstride: i64,
            dst_ystride: i64,
            dst_zstride: i64,
        ) -> bool;

        pub fn wrap_black(coord: &mut i32, origin: i32, width: i32) -> bool;

        pub fn wrap_clamp(coord: &mut i32, origin: i32, width: i32) -> bool;

        pub fn wrap_periodic(coord: &mut i32, origin: i32, width: i32) -> bool;

        pub fn wrap_periodic_pow2(coord: &mut i32, origin: i32, width: i32) -> bool;

        pub fn wrap_mirror(coord: &mut i32, origin: i32, width: i32) -> bool;

        pub fn debug(message: &str);
    }
}