|
| 1 | +use async_tiff::reader::Endianness; |
1 | 2 | use async_tiff::tiff::tags::{ |
2 | 3 | CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, ResolutionUnit, |
3 | 4 | SampleFormat, |
@@ -39,6 +40,30 @@ impl<'py> IntoPyObject<'py> for PyCompressionMethod { |
39 | 40 | } |
40 | 41 | } |
41 | 42 |
|
| 43 | +pub(crate) struct PyEndianness(Endianness); |
| 44 | + |
| 45 | +impl From<Endianness> for PyEndianness { |
| 46 | + fn from(value: Endianness) -> Self { |
| 47 | + Self(value) |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +impl<'py> IntoPyObject<'py> for PyEndianness { |
| 52 | + type Target = PyAny; |
| 53 | + type Output = Bound<'py, PyAny>; |
| 54 | + type Error = PyErr; |
| 55 | + |
| 56 | + fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> { |
| 57 | + let enums_mod = py.import(intern!(py, "async_tiff.enums"))?; |
| 58 | + let endianness_enum = enums_mod.getattr(intern!(py, "Endianness"))?; |
| 59 | + |
| 60 | + match self.0 { |
| 61 | + Endianness::LittleEndian => endianness_enum.getattr("LittleEndian"), |
| 62 | + Endianness::BigEndian => endianness_enum.getattr("BigEndian"), |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
42 | 67 | pub(crate) struct PyPhotometricInterpretation(PhotometricInterpretation); |
43 | 68 |
|
44 | 69 | impl From<PhotometricInterpretation> for PyPhotometricInterpretation { |
@@ -132,6 +157,7 @@ impl<'py> IntoPyObject<'py> for PySampleFormat { |
132 | 157 | to_py_enum_variant(py, intern!(py, "SampleFormat"), self.0.to_u16()) |
133 | 158 | } |
134 | 159 | } |
| 160 | + |
135 | 161 | fn to_py_enum_variant<'py>( |
136 | 162 | py: Python<'py>, |
137 | 163 | enum_name: &Bound<'py, PyString>, |
|
0 commit comments