Enum Compression
pub enum Compression
Specifies which compression method to use.
Use uncompressed data for fastest loading and writing speeds. Use RLE compression for fast loading and writing with slight memory savings. Use ZIP compression for slow processing with large memory savings.
Variants
-
Uncompressed Store uncompressed values. Produces large files that can be read and written very quickly. Consider using RLE instead, as it provides some compression with almost equivalent speed.
-
RLE Produces slightly smaller files that can still be read and written rather quickly. The compressed file size is usually between 60 and 75 percent of the uncompressed size. Works best for images with large flat areas, such as masks and abstract graphics. This compression method is lossless.
-
ZIP1 Uses ZIP compression to compress each line. Slowly produces small images which can be read with moderate speed. This compression method is lossless. Might be slightly faster but larger than `ZIP16´.
-
ZIP16 Uses ZIP compression to compress blocks of 16 lines. Slowly produces small images which can be read with moderate speed. This compression method is lossless. Might be slightly slower but smaller than `ZIP1´.
-
PIZ PIZ compression works well for noisy and natural images. Works better with larger tiles. Only supported for flat images, but not for deep data. This compression method is lossless.
-
PXR24 Like
ZIP1, but reduces precision off32images tof24. Therefore, this is lossless compression forf16andu32data, lossy compression forf32data. This compression method works well for depth buffers and similar images, where the possible range of values is very large, but where full 32-bit floating-point accuracy is not necessary. Rounding improves compression significantly by eliminating the pixels' 8 least significant bits, which tend to be very noisy, and therefore difficult to compress. This produces really small image files. Only supported for flat images, not for deep data.-
B44 This is a lossy compression method for f16 images. It's the predecessor of the
B44Acompression, which has improved compression rates for uniformly colored areas. You should probably useB44Ainstead of the plainB44.Only supported for flat images, not for deep data.
-
B44A This is a lossy compression method for f16 images. All f32 and u32 channels will be stored without compression. All the f16 pixels are divided into 4x4 blocks. Each block is then compressed as a whole.
The 32 bytes of a block will require only ~14 bytes after compression, independent of the actual pixel contents. With chroma subsampling, a block will be compressed to ~7 bytes. Uniformly colored blocks will be compressed to ~3 bytes.
The 512 bytes of an f32 block will not be compressed at all.
Should be fast enough for realtime playback. Only supported for flat images, not for deep data.
-
DWAA(Option<f32>) Lossy DCT-based compression (DreamWorks Animation), 32 scanlines per block. Partial buffer access friendly. Decoding support is implemented. Encoding is not implemented and returns an error.
-
DWAB(Option<f32>) Lossy DCT-based compression (DreamWorks Animation), 256 scanlines per block. Better compression ratio for full frames. Decoding support is implemented. Encoding is not implemented and returns an error.
-
HTJ2K32 This lossy compression is not yet supported by this implementation.
-
HTJ2K256 This lossy compression is not yet supported by this implementation.
Implementations
impl Compression
const fn byte_size() -> usizeNumber of bytes this would consume in an exr file.
fn write<W: Write>(self, write: &mut W) -> UnitResultWithout validation, write this instance to the byte stream.
fn read<R: Read>(read: &mut R) -> Result<Self>Read the value without validating.
impl Compression
fn compress_image_section_to_le(self, header: &Header, uncompressed_native_endian: ByteVec, pixel_section: IntegerBounds) -> Result<ByteVec>Compress the image section, converting from native endian into with little-endian format.
fn decompress_image_section_from_le(self, header: &Header, compressed_le: ByteVec, pixel_section: IntegerBounds, pedantic: bool) -> Result<ByteVec>Decompress the image section from bytes of little-endian format, returning native-endian format.
const fn scan_lines_per_block(self) -> usizeFor scan line images and deep scan line images, one or more scan lines may be stored together as a scan line block. The number of scan lines per block depends on how the pixel data are compressed.
const fn supports_deep_data(self) -> boolDeep data can only be compressed using RLE or ZIP compression.
fn is_lossless_for(self, sample_type: SampleType) -> boolMost compression methods will reconstruct the exact pixel bytes, but some might throw away unimportant data for specific types of samples.
fn may_loose_data(self) -> boolMost compression methods will reconstruct the exact pixel bytes, but some might throw away unimportant data in some cases.
fn supports_nan(self) -> boolMost compression methods will reconstruct the exact pixel bytes, but some might replace NaN with zeroes. This might also depend on the sample type of the pixels. Even a compression method that supports NaN might change the bit patterns of those NaNs.
fn preserves_nan_bits(self) -> boolMost compression methods will reconstruct the exact pixel and NaN bits, but some might replace NaN bits with other NaN bits. This might also depend on the sample type of the pixels.
Trait Implementations
impl Clone for Compression
fn clone(&self) -> Self
impl Copy for Compression
impl Debug for Compression
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for Compression
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
impl PartialEq for Compression
fn eq(&self, other: &Self) -> bool
impl StructuralPartialEq for Compression
Auto Trait Implementations
impl Freeze for Compression
impl RefUnwindSafe for Compression
impl Send for Compression
impl Sync for Compression
impl Unpin for Compression
impl UnsafeUnpin for Compression
impl UnwindSafe for Compression
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for Compression
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for Compression
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for Compression
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Compression
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Compression
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Compression
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Compression
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for Compression
const ALIGN: usize = _;type Init = T;unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T> Read<Exclusive, BecauseExclusive> for Compression
where
T: ?Sized,
impl<T> ToOwned for Compression
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for Compression
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Compression
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Compression
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Compression
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>