Add CompressionType type
This commit is contained in:
64
src/types/compression_type.rs
Normal file
64
src/types/compression_type.rs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
use crate::bindings;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum CompressionType {
|
||||||
|
Undefined = bindings::CompressionType_UndefinedCompression,
|
||||||
|
B44A = bindings::CompressionType_B44ACompression,
|
||||||
|
B44 = bindings::CompressionType_B44Compression,
|
||||||
|
BZip = bindings::CompressionType_BZipCompression,
|
||||||
|
DXT1 = bindings::CompressionType_DXT1Compression,
|
||||||
|
DXT3 = bindings::CompressionType_DXT3Compression,
|
||||||
|
DXT5 = bindings::CompressionType_DXT5Compression,
|
||||||
|
Fax = bindings::CompressionType_FaxCompression,
|
||||||
|
Group4 = bindings::CompressionType_Group4Compression,
|
||||||
|
JBIG1 = bindings::CompressionType_JBIG1Compression,
|
||||||
|
JBIG2 = bindings::CompressionType_JBIG2Compression,
|
||||||
|
JPEG2000 = bindings::CompressionType_JPEG2000Compression,
|
||||||
|
JPEG = bindings::CompressionType_JPEGCompression,
|
||||||
|
LosslessJPEG = bindings::CompressionType_LosslessJPEGCompression,
|
||||||
|
LZMA = bindings::CompressionType_LZMACompression,
|
||||||
|
LZW = bindings::CompressionType_LZWCompression,
|
||||||
|
No = bindings::CompressionType_NoCompression,
|
||||||
|
Piz = bindings::CompressionType_PizCompression,
|
||||||
|
Pxr24 = bindings::CompressionType_Pxr24Compression,
|
||||||
|
RLE = bindings::CompressionType_RLECompression,
|
||||||
|
Zip = bindings::CompressionType_ZipCompression,
|
||||||
|
ZipS = bindings::CompressionType_ZipSCompression,
|
||||||
|
Zstd = bindings::CompressionType_ZstdCompression,
|
||||||
|
WebP = bindings::CompressionType_WebPCompression,
|
||||||
|
DWAA = bindings::CompressionType_DWAACompression,
|
||||||
|
DWAB = bindings::CompressionType_DWABCompression,
|
||||||
|
BC7 = bindings::CompressionType_BC7Compression,
|
||||||
|
BC5 = bindings::CompressionType_BC5Compression,
|
||||||
|
LERC = bindings::CompressionType_LERCCompression,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CompressionType {
|
||||||
|
fn default() -> Self {
|
||||||
|
return CompressionType::Undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<CompressionType> for bindings::CompressionType {
|
||||||
|
fn from(value: CompressionType) -> Self {
|
||||||
|
return value as bindings::CompressionType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<bindings::CompressionType> for CompressionType {
|
||||||
|
fn from(value: bindings::CompressionType) -> Self {
|
||||||
|
/*
|
||||||
|
* SAFETY:
|
||||||
|
*
|
||||||
|
* `CompressionType` has the same repr as `bindings::CompressionType` - u32
|
||||||
|
*
|
||||||
|
* If `value` is less than LERC than it is in the vaild range and can be safely
|
||||||
|
* reinterpreted as `CompressionType`
|
||||||
|
*/
|
||||||
|
if value <= bindings::CompressionType_LERCCompression {
|
||||||
|
return unsafe { std::mem::transmute(value) };
|
||||||
|
}
|
||||||
|
return CompressionType::default();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
mod alpha_channel_option;
|
mod alpha_channel_option;
|
||||||
mod colorspace_type;
|
mod colorspace_type;
|
||||||
mod composite_operator;
|
mod composite_operator;
|
||||||
|
mod compression_type;
|
||||||
mod dither_method;
|
mod dither_method;
|
||||||
mod filter_type;
|
mod filter_type;
|
||||||
mod gravity_type;
|
mod gravity_type;
|
||||||
@ -11,6 +12,7 @@ mod resource_type;
|
|||||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||||
pub use self::colorspace_type::ColorspaceType;
|
pub use self::colorspace_type::ColorspaceType;
|
||||||
pub use self::composite_operator::CompositeOperator;
|
pub use self::composite_operator::CompositeOperator;
|
||||||
|
pub use self::compression_type::CompressionType;
|
||||||
pub use self::dither_method::DitherMethod;
|
pub use self::dither_method::DitherMethod;
|
||||||
pub use self::filter_type::FilterType;
|
pub use self::filter_type::FilterType;
|
||||||
pub use self::gravity_type::GravityType;
|
pub use self::gravity_type::GravityType;
|
||||||
|
|||||||
@ -34,6 +34,7 @@ use crate::{
|
|||||||
AlphaChannelOption,
|
AlphaChannelOption,
|
||||||
ColorspaceType,
|
ColorspaceType,
|
||||||
CompositeOperator,
|
CompositeOperator,
|
||||||
|
CompressionType,
|
||||||
DitherMethod,
|
DitherMethod,
|
||||||
FilterType,
|
FilterType,
|
||||||
GravityType,
|
GravityType,
|
||||||
@ -1172,11 +1173,11 @@ impl MagickWand {
|
|||||||
set_get!(
|
set_get!(
|
||||||
get_colorspace, set_colorspace, MagickGetColorspace, MagickSetColorspace, ColorspaceType
|
get_colorspace, set_colorspace, MagickGetColorspace, MagickSetColorspace, ColorspaceType
|
||||||
get_image_compose, set_image_compose, MagickGetImageCompose, MagickSetImageCompose, CompositeOperator
|
get_image_compose, set_image_compose, MagickGetImageCompose, MagickSetImageCompose, CompositeOperator
|
||||||
get_compression, set_compression, MagickGetCompression, MagickSetCompression, bindings::CompressionType
|
get_compression, set_compression, MagickGetCompression, MagickSetCompression, CompressionType
|
||||||
get_compression_quality, set_compression_quality, MagickGetCompressionQuality, MagickSetCompressionQuality, usize
|
get_compression_quality, set_compression_quality, MagickGetCompressionQuality, MagickSetCompressionQuality, usize
|
||||||
get_gravity, set_gravity, MagickGetGravity, MagickSetGravity, GravityType
|
get_gravity, set_gravity, MagickGetGravity, MagickSetGravity, GravityType
|
||||||
get_image_colorspace, set_image_colorspace, MagickGetImageColorspace, MagickSetImageColorspace, ColorspaceType
|
get_image_colorspace, set_image_colorspace, MagickGetImageColorspace, MagickSetImageColorspace, ColorspaceType
|
||||||
get_image_compression, set_image_compression, MagickGetImageCompression, MagickSetImageCompression, bindings::CompressionType
|
get_image_compression, set_image_compression, MagickGetImageCompression, MagickSetImageCompression, CompressionType
|
||||||
get_image_compression_quality, set_image_compression_quality, MagickGetImageCompressionQuality, MagickSetImageCompressionQuality, usize
|
get_image_compression_quality, set_image_compression_quality, MagickGetImageCompressionQuality, MagickSetImageCompressionQuality, usize
|
||||||
get_image_delay, set_image_delay, MagickGetImageDelay, MagickSetImageDelay, usize
|
get_image_delay, set_image_delay, MagickGetImageDelay, MagickSetImageDelay, usize
|
||||||
get_image_depth, set_image_depth, MagickGetImageDepth, MagickSetImageDepth, usize
|
get_image_depth, set_image_depth, MagickGetImageDepth, MagickSetImageDepth, usize
|
||||||
|
|||||||
@ -100,7 +100,7 @@ impl PixelWand {
|
|||||||
|
|
||||||
set_get_unchecked!(
|
set_get_unchecked!(
|
||||||
get_color_count, set_color_count, PixelGetColorCount, PixelSetColorCount, size_t
|
get_color_count, set_color_count, PixelGetColorCount, PixelSetColorCount, size_t
|
||||||
get_index, set_index, PixelGetIndex, PixelSetIndex, bindings::Quantum
|
get_index, set_index, PixelGetIndex, PixelSetIndex, f32
|
||||||
get_fuzz, set_fuzz, PixelGetFuzz, PixelSetFuzz, f64
|
get_fuzz, set_fuzz, PixelGetFuzz, PixelSetFuzz, f64
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user