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
use libheif_sys as lh;
#[derive(Debug)]
pub struct DecodingOptions {
pub(crate) inner: *mut lh::heif_decoding_options,
}
impl DecodingOptions {
pub fn new() -> Option<Self> {
let inner = unsafe { lh::heif_decoding_options_alloc() };
if inner.is_null() {
return None;
}
Some(Self { inner })
}
}
impl Drop for DecodingOptions {
fn drop(&mut self) {
unsafe {
lh::heif_decoding_options_free(self.inner);
}
}
}
impl DecodingOptions {
#[inline(always)]
fn inner_ref(&self) -> &lh::heif_decoding_options {
unsafe { &(*self.inner) }
}
#[inline(always)]
fn inner_mut(&mut self) -> &mut lh::heif_decoding_options {
unsafe { &mut (*self.inner) }
}
#[inline]
pub fn version(&self) -> u8 {
self.inner_ref().version
}
#[inline]
pub fn ignore_transformations(&self) -> bool {
self.inner_ref().ignore_transformations != 0
}
#[inline]
pub fn set_ignore_transformations(&mut self, enable: bool) {
self.inner_mut().ignore_transformations = if enable { 1 } else { 0 }
}
#[inline]
pub fn convert_hdr_to_8bit(&self) -> bool {
self.inner_ref().convert_hdr_to_8bit != 0
}
#[inline]
pub fn set_convert_hdr_to_8bit(&mut self, enable: bool) {
self.inner_mut().convert_hdr_to_8bit = if enable { 1 } else { 0 }
}
#[inline]
pub fn strict_decoding(&self) -> bool {
self.inner_ref().strict_decoding != 0
}
#[inline]
pub fn set_strict_decoding(&mut self, enable: bool) {
self.inner_mut().strict_decoding = if enable { 1 } else { 0 }
}
}