Redesign types module
Now we are using more functionality given to us by rust-bindgen instead of maintaining enum mappings ourselves: * Rustified enums can be generated automatically by using the EnumVariation::Rust style in rust-bindgen * Redundant suffixes can be removed through implementing ParseCallbacks::enum_variant_name * The redundant FromRust trait was removed and replaced with the standard From and Into traits
This commit is contained in:
106
build.rs
106
build.rs
@ -125,6 +125,31 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct RemoveEnumVariantSuffix {
|
||||||
|
enum_name: String,
|
||||||
|
variant_suffix: String
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RemoveEnumVariantSuffix {
|
||||||
|
fn new(enum_name: impl Into<String>, variant_suffix: impl Into<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
enum_name: enum_name.into(),
|
||||||
|
variant_suffix: variant_suffix.into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl bindgen::callbacks::ParseCallbacks for RemoveEnumVariantSuffix {
|
||||||
|
fn enum_variant_name(&self, enum_name: Option<&str>, original_variant_name: &str, _variant_value: bindgen::callbacks::EnumVariantValue) -> Option<String> {
|
||||||
|
if enum_name != Some(&self.enum_name) {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(original_variant_name.trim_end_matches(&self.variant_suffix).to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let ignored_macros = IgnoreMacros(
|
let ignored_macros = IgnoreMacros(
|
||||||
vec![
|
vec![
|
||||||
"FP_INFINITE".into(),
|
"FP_INFINITE".into(),
|
||||||
@ -143,6 +168,79 @@ fn main() {
|
|||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let enum_suffixes = vec![
|
||||||
|
("ClassType", "Class"),
|
||||||
|
("CompositeOperator", "CompositeOp"),
|
||||||
|
("GravityType", "Gravity"),
|
||||||
|
("ImageType", "Type"),
|
||||||
|
("InterlaceType", "Interlace"),
|
||||||
|
("OrientationType", "Orientation"),
|
||||||
|
("ResolutionType", "Resolution"),
|
||||||
|
("TransmitType", "TransmitType"),
|
||||||
|
("MapMode", "Mode"),
|
||||||
|
("ColorspaceType", "Colorspace"),
|
||||||
|
("ChannelType", "Channel"),
|
||||||
|
("PixelChannel", "PixelChannel"),
|
||||||
|
("PixelIntensityMethod", "PixelIntensityMethod"),
|
||||||
|
("PixelInterpolateMethod", "InterpolatePixel"),
|
||||||
|
("PixelMask", "PixelMask"),
|
||||||
|
("PixelTrait", "PixelTrait"),
|
||||||
|
("VirtualPixelMethod", "VirtualPixelMethod"),
|
||||||
|
("ComplianceType", "Compliance"),
|
||||||
|
("IlluminantType", "Illuminant"),
|
||||||
|
("CompressionType", "Compression"),
|
||||||
|
("KernelInfoType", "Kernel"),
|
||||||
|
("MorphologyMethod", "Morphology"),
|
||||||
|
("PreviewType", "Preview"),
|
||||||
|
("DisposeType", "Dispose"),
|
||||||
|
("LayerMethod", "Layer"),
|
||||||
|
("RenderingIntent", "Intent"),
|
||||||
|
("EndianType", "Endian"),
|
||||||
|
("QuantumAlphaType", "QuantumAlpha"),
|
||||||
|
("QuantumFormat", "QuantumFormat"),
|
||||||
|
("QuantumType", "Quantum"),
|
||||||
|
("FilterType", "Filter"),
|
||||||
|
("TimerState", "TimerState"),
|
||||||
|
("StretchType", "Stretch"),
|
||||||
|
("StyleType", "Style"),
|
||||||
|
("AlignType", "Align"),
|
||||||
|
("DecorationType", "Decoration"),
|
||||||
|
("DirectionType", "Direction"),
|
||||||
|
("FillRule", "Rule"),
|
||||||
|
("GradientType", "Gradient"),
|
||||||
|
("LineCap", "Cap"),
|
||||||
|
("LineJoin", "Join"),
|
||||||
|
("PaintMethod", "Method"),
|
||||||
|
("PrimitiveType", "Primitive"),
|
||||||
|
("ReferenceType", "Reference"),
|
||||||
|
("SpreadMethod", "Spread"),
|
||||||
|
("WordBreakType", "WordBreakType"),
|
||||||
|
("CacheType", "Cache"),
|
||||||
|
("AlphaChannelOption", "AlphaChannel"),
|
||||||
|
("MetricType", "ErrorMetric"),
|
||||||
|
("MagickFormatType", "FormatType"),
|
||||||
|
("MagickInfoFlag", "Flag"),
|
||||||
|
("DistortMethod", "Distortion"),
|
||||||
|
("SparseColorMethod", "ColorInterpolate"),
|
||||||
|
("ComplexOperator", "ComplexOperator"),
|
||||||
|
("MontageMode", "Mode"),
|
||||||
|
("MagickCLDeviceType", "DeviceType"),
|
||||||
|
("CommandOption", "Options"), // debatable
|
||||||
|
("ValidateType", "Validate"),
|
||||||
|
("CommandOptionFLags", "OptionFlag"),
|
||||||
|
("PolicyDomain", "PolicyDomain"),
|
||||||
|
("PolicyRights", "PolicyRights"),
|
||||||
|
("DitherMethod", "DitherMethod"),
|
||||||
|
("RegistryType", "RegistryType"),
|
||||||
|
("ResourceType", "Resource"),
|
||||||
|
("MagickEvaluateOperator", "EvaluateOperator"),
|
||||||
|
("MagickFunction", "Function"),
|
||||||
|
("StatisticType", "Statistic"),
|
||||||
|
("AutoThresholdMethod", "ThresholdMethod"),
|
||||||
|
("PathType", "Path"),
|
||||||
|
("NoiseType", "Noise")
|
||||||
|
];
|
||||||
|
|
||||||
if !Path::new(&bindings_path_str).exists() {
|
if !Path::new(&bindings_path_str).exists() {
|
||||||
// Create the header file that rust-bindgen needs as input.
|
// Create the header file that rust-bindgen needs as input.
|
||||||
let gen_h_path = out_dir.join("gen.h");
|
let gen_h_path = out_dir.join("gen.h");
|
||||||
@ -160,12 +258,18 @@ fn main() {
|
|||||||
.size_t_is_usize(true)
|
.size_t_is_usize(true)
|
||||||
.parse_callbacks(Box::new(ignored_macros))
|
.parse_callbacks(Box::new(ignored_macros))
|
||||||
.blocklist_type("timex")
|
.blocklist_type("timex")
|
||||||
.blocklist_function("clock_adjtime");
|
.blocklist_function("clock_adjtime")
|
||||||
|
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false });
|
||||||
|
|
||||||
for d in include_dirs {
|
for d in include_dirs {
|
||||||
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
|
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (enum_name, suffix) in enum_suffixes {
|
||||||
|
let remove_suffix = RemoveEnumVariantSuffix::new(enum_name, suffix);
|
||||||
|
builder = builder.parse_callbacks(Box::new(remove_suffix));
|
||||||
|
}
|
||||||
|
|
||||||
let bindings = if cfg!(all(windows, target_pointer_width = "64")) {
|
let bindings = if cfg!(all(windows, target_pointer_width = "64")) {
|
||||||
match builder.clone().generate() {
|
match builder.clone().generate() {
|
||||||
Ok(bindings) => bindings,
|
Ok(bindings) => bindings,
|
||||||
|
|||||||
@ -15,29 +15,20 @@
|
|||||||
*/
|
*/
|
||||||
use super::bindings;
|
use super::bindings;
|
||||||
|
|
||||||
pub trait FromRust<T> {
|
impl From<bindings::MagickBooleanType> for bool {
|
||||||
fn from_rust(t: T) -> Self;
|
fn from(value: bindings::MagickBooleanType) -> Self {
|
||||||
}
|
match value {
|
||||||
|
bindings::MagickBooleanType::MagickFalse => false,
|
||||||
impl FromRust<bool> for bindings::MagickBooleanType {
|
bindings::MagickBooleanType::MagickTrue => true
|
||||||
fn from_rust(b: bool) -> Self {
|
|
||||||
if b {
|
|
||||||
bindings::MagickBooleanType_MagickTrue
|
|
||||||
} else {
|
|
||||||
bindings::MagickBooleanType_MagickFalse
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ToMagick<T> {
|
impl From<bool> for bindings::MagickBooleanType {
|
||||||
fn to_magick(self) -> T;
|
fn from(value: bool) -> Self {
|
||||||
}
|
match value {
|
||||||
|
true => bindings::MagickBooleanType::MagickTrue,
|
||||||
impl<T, E> ToMagick<T> for E
|
false => bindings::MagickBooleanType::MagickFalse
|
||||||
where
|
}
|
||||||
T: FromRust<E>,
|
|
||||||
{
|
|
||||||
fn to_magick(self) -> T {
|
|
||||||
<T as FromRust<E>>::from_rust(self)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/lib.rs
11
src/lib.rs
@ -34,7 +34,6 @@ extern crate libc;
|
|||||||
|
|
||||||
use libc::size_t;
|
use libc::size_t;
|
||||||
|
|
||||||
pub use conversions::ToMagick;
|
|
||||||
pub use result::MagickError;
|
pub use result::MagickError;
|
||||||
use result::Result;
|
use result::Result;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
@ -51,7 +50,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
|||||||
pub fn magick_wand_genesis() {
|
pub fn magick_wand_genesis() {
|
||||||
unsafe {
|
unsafe {
|
||||||
match bindings::IsMagickWandInstantiated() {
|
match bindings::IsMagickWandInstantiated() {
|
||||||
bindings::MagickBooleanType_MagickTrue => (),
|
bindings::MagickBooleanType::MagickTrue => (),
|
||||||
_ => bindings::MagickWandGenesis(),
|
_ => bindings::MagickWandGenesis(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +60,7 @@ pub fn magick_wand_genesis() {
|
|||||||
/// This function is safe to be called repeatedly.
|
/// This function is safe to be called repeatedly.
|
||||||
pub fn magick_wand_terminus() {
|
pub fn magick_wand_terminus() {
|
||||||
unsafe {
|
unsafe {
|
||||||
if let bindings::MagickBooleanType_MagickTrue = bindings::IsMagickWandInstantiated() {
|
if let bindings::MagickBooleanType::MagickTrue = bindings::IsMagickWandInstantiated() {
|
||||||
bindings::MagickWandTerminus();
|
bindings::MagickWandTerminus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,7 +68,7 @@ pub fn magick_wand_terminus() {
|
|||||||
|
|
||||||
pub fn magick_query_fonts(pattern: &str) -> Result<Vec<String>> {
|
pub fn magick_query_fonts(pattern: &str) -> Result<Vec<String>> {
|
||||||
let mut number_fonts: size_t = 0;
|
let mut number_fonts: size_t = 0;
|
||||||
let c_string = ::std::ffi::CString::new(pattern).map_err(|_| "could not convert to cstring")?;
|
let c_string = std::ffi::CString::new(pattern).map_err(|_| "could not convert to cstring")?;
|
||||||
let ptr =
|
let ptr =
|
||||||
unsafe { bindings::MagickQueryFonts(c_string.as_ptr(), &mut number_fonts as *mut size_t) };
|
unsafe { bindings::MagickQueryFonts(c_string.as_ptr(), &mut number_fonts as *mut size_t) };
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
@ -78,9 +77,9 @@ pub fn magick_query_fonts(pattern: &str) -> Result<Vec<String>> {
|
|||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
let mut v = Vec::new();
|
let mut v = Vec::new();
|
||||||
let c_str_ptr_slice = unsafe { ::std::slice::from_raw_parts(ptr, number_fonts as usize) };
|
let c_str_ptr_slice = unsafe { std::slice::from_raw_parts(ptr, number_fonts as usize) };
|
||||||
for c_str_ptr in c_str_ptr_slice {
|
for c_str_ptr in c_str_ptr_slice {
|
||||||
let c_str = unsafe { ::std::ffi::CStr::from_ptr(*c_str_ptr) };
|
let c_str = unsafe { std::ffi::CStr::from_ptr(*c_str_ptr) };
|
||||||
v.push(c_str.to_string_lossy().into_owned())
|
v.push(c_str.to_string_lossy().into_owned())
|
||||||
}
|
}
|
||||||
Ok(v)
|
Ok(v)
|
||||||
|
|||||||
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum AlignType {
|
|
||||||
Undefined = bindings::AlignType_UndefinedAlign,
|
|
||||||
Left = bindings::AlignType_LeftAlign,
|
|
||||||
Center = bindings::AlignType_CenterAlign,
|
|
||||||
Right = bindings::AlignType_RightAlign,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for AlignType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return AlignType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<AlignType> for bindings::AlignType {
|
|
||||||
fn from(value: AlignType) -> Self {
|
|
||||||
return value as bindings::AlignType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::AlignType> for AlignType {
|
|
||||||
fn from(value: bindings::AlignType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `AlignType` has the same repr as `bindings::AlignType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Right than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `AlignType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::AlignType_RightAlign {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return AlignType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum AlphaChannelOption {
|
|
||||||
Undefined = bindings::AlphaChannelOption_UndefinedAlphaChannel,
|
|
||||||
Activate = bindings::AlphaChannelOption_ActivateAlphaChannel,
|
|
||||||
Associate = bindings::AlphaChannelOption_AssociateAlphaChannel,
|
|
||||||
Background = bindings::AlphaChannelOption_BackgroundAlphaChannel,
|
|
||||||
Copy = bindings::AlphaChannelOption_CopyAlphaChannel,
|
|
||||||
Deactivate = bindings::AlphaChannelOption_DeactivateAlphaChannel,
|
|
||||||
Discrete = bindings::AlphaChannelOption_DiscreteAlphaChannel,
|
|
||||||
Disassociate = bindings::AlphaChannelOption_DisassociateAlphaChannel,
|
|
||||||
Extract = bindings::AlphaChannelOption_ExtractAlphaChannel,
|
|
||||||
Off = bindings::AlphaChannelOption_OffAlphaChannel,
|
|
||||||
On = bindings::AlphaChannelOption_OnAlphaChannel,
|
|
||||||
Opaque = bindings::AlphaChannelOption_OpaqueAlphaChannel,
|
|
||||||
Remove = bindings::AlphaChannelOption_RemoveAlphaChannel,
|
|
||||||
Set = bindings::AlphaChannelOption_SetAlphaChannel,
|
|
||||||
Shape = bindings::AlphaChannelOption_ShapeAlphaChannel,
|
|
||||||
Transparent = bindings::AlphaChannelOption_TransparentAlphaChannel,
|
|
||||||
OffIfOpaque = bindings::AlphaChannelOption_OffIfOpaqueAlphaChannel,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for AlphaChannelOption {
|
|
||||||
fn default() -> Self {
|
|
||||||
return AlphaChannelOption::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<AlphaChannelOption> for bindings::AlphaChannelOption {
|
|
||||||
fn from(value: AlphaChannelOption) -> Self {
|
|
||||||
return value as bindings::AlphaChannelOption;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::AlphaChannelOption> for AlphaChannelOption {
|
|
||||||
fn from(value: bindings::AlphaChannelOption) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `AlphaChannelOption` has the same repr as `bindings::AlphaChannelOption` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than OffIfOpaque than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `AlphaChannelOption`
|
|
||||||
*/
|
|
||||||
if value <= bindings::AlphaChannelOption_OffIfOpaqueAlphaChannel {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return AlphaChannelOption::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum AutoThresholdMethod {
|
|
||||||
Undefined = bindings::AutoThresholdMethod_UndefinedThresholdMethod,
|
|
||||||
Kapur = bindings::AutoThresholdMethod_KapurThresholdMethod,
|
|
||||||
OTSU = bindings::AutoThresholdMethod_OTSUThresholdMethod,
|
|
||||||
Triangle = bindings::AutoThresholdMethod_TriangleThresholdMethod,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for AutoThresholdMethod {
|
|
||||||
fn default() -> Self {
|
|
||||||
return AutoThresholdMethod::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<AutoThresholdMethod> for bindings::AutoThresholdMethod {
|
|
||||||
fn from(value: AutoThresholdMethod) -> Self {
|
|
||||||
return value as bindings::AutoThresholdMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,120 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub enum ChannelType {
|
|
||||||
Undefined,
|
|
||||||
RedChannel,
|
|
||||||
GrayChannel,
|
|
||||||
CyanChannel,
|
|
||||||
LChannel,
|
|
||||||
GreenChannel,
|
|
||||||
MagentaChannel,
|
|
||||||
aChannel,
|
|
||||||
BlueChannel,
|
|
||||||
bChannel,
|
|
||||||
YellowChannel,
|
|
||||||
BlackChannel,
|
|
||||||
AlphaChannel,
|
|
||||||
OpacityChannel,
|
|
||||||
IndexChannel,
|
|
||||||
ReadMaskChannel,
|
|
||||||
WriteMaskChannel,
|
|
||||||
MetaChannel,
|
|
||||||
CompositeMaskChannel,
|
|
||||||
CompositeChannels,
|
|
||||||
AllChannels,
|
|
||||||
TrueAlphaChannel,
|
|
||||||
RGBChannels,
|
|
||||||
GrayChannels,
|
|
||||||
SyncChannels,
|
|
||||||
DefaultChannels,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ChannelType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return ChannelType::DefaultChannels;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ChannelType> for bindings::ChannelType {
|
|
||||||
fn from(value: ChannelType) -> Self {
|
|
||||||
match value {
|
|
||||||
ChannelType::Undefined => bindings::ChannelType_UndefinedChannel,
|
|
||||||
ChannelType::RedChannel => bindings::ChannelType_RedChannel,
|
|
||||||
ChannelType::GrayChannel => bindings::ChannelType_GrayChannel,
|
|
||||||
ChannelType::CyanChannel => bindings::ChannelType_CyanChannel,
|
|
||||||
ChannelType::LChannel => bindings::ChannelType_LChannel,
|
|
||||||
ChannelType::GreenChannel => bindings::ChannelType_GreenChannel,
|
|
||||||
ChannelType::MagentaChannel => bindings::ChannelType_MagentaChannel,
|
|
||||||
ChannelType::aChannel => bindings::ChannelType_aChannel,
|
|
||||||
ChannelType::BlueChannel => bindings::ChannelType_BlueChannel,
|
|
||||||
ChannelType::bChannel => bindings::ChannelType_bChannel,
|
|
||||||
ChannelType::YellowChannel => bindings::ChannelType_YellowChannel,
|
|
||||||
ChannelType::BlackChannel => bindings::ChannelType_BlackChannel,
|
|
||||||
ChannelType::AlphaChannel => bindings::ChannelType_AlphaChannel,
|
|
||||||
ChannelType::OpacityChannel => bindings::ChannelType_OpacityChannel,
|
|
||||||
ChannelType::IndexChannel => bindings::ChannelType_IndexChannel,
|
|
||||||
ChannelType::ReadMaskChannel => bindings::ChannelType_ReadMaskChannel,
|
|
||||||
ChannelType::WriteMaskChannel => bindings::ChannelType_WriteMaskChannel,
|
|
||||||
ChannelType::MetaChannel => bindings::ChannelType_MetaChannel,
|
|
||||||
ChannelType::CompositeMaskChannel => bindings::ChannelType_CompositeMaskChannel,
|
|
||||||
ChannelType::CompositeChannels => bindings::ChannelType_CompositeChannels,
|
|
||||||
ChannelType::AllChannels => bindings::ChannelType_AllChannels,
|
|
||||||
ChannelType::TrueAlphaChannel => bindings::ChannelType_TrueAlphaChannel,
|
|
||||||
ChannelType::RGBChannels => bindings::ChannelType_RGBChannels,
|
|
||||||
ChannelType::GrayChannels => bindings::ChannelType_GrayChannels,
|
|
||||||
ChannelType::SyncChannels => bindings::ChannelType_SyncChannels,
|
|
||||||
ChannelType::DefaultChannels => bindings::ChannelType_DefaultChannels,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::ChannelType> for ChannelType {
|
|
||||||
fn from(value: bindings::ChannelType) -> Self {
|
|
||||||
// Unreachable match arms commented out
|
|
||||||
match value {
|
|
||||||
bindings::ChannelType_UndefinedChannel => ChannelType::Undefined,
|
|
||||||
bindings::ChannelType_RedChannel => ChannelType::RedChannel,
|
|
||||||
// bindings::ChannelType_GrayChannel => { ChannelType::GrayChannel },
|
|
||||||
// bindings::ChannelType_CyanChannel => { ChannelType::CyanChannel },
|
|
||||||
// bindings::ChannelType_LChannel => { ChannelType::LChannel },
|
|
||||||
bindings::ChannelType_GreenChannel => ChannelType::GreenChannel,
|
|
||||||
// bindings::ChannelType_MagentaChannel => { ChannelType::MagentaChannel },
|
|
||||||
// bindings::ChannelType_aChannel => { ChannelType::aChannel },
|
|
||||||
bindings::ChannelType_BlueChannel => ChannelType::BlueChannel,
|
|
||||||
// bindings::ChannelType_bChannel => { ChannelType::bChannel },
|
|
||||||
// bindings::ChannelType_YellowChannel => { ChannelType::YellowChannel },
|
|
||||||
bindings::ChannelType_BlackChannel => ChannelType::BlackChannel,
|
|
||||||
bindings::ChannelType_AlphaChannel => ChannelType::AlphaChannel,
|
|
||||||
// bindings::ChannelType_OpacityChannel => { ChannelType::OpacityChannel },
|
|
||||||
bindings::ChannelType_IndexChannel => ChannelType::IndexChannel,
|
|
||||||
bindings::ChannelType_ReadMaskChannel => ChannelType::ReadMaskChannel,
|
|
||||||
bindings::ChannelType_WriteMaskChannel => ChannelType::WriteMaskChannel,
|
|
||||||
bindings::ChannelType_MetaChannel => ChannelType::MetaChannel,
|
|
||||||
bindings::ChannelType_CompositeMaskChannel => ChannelType::CompositeMaskChannel,
|
|
||||||
bindings::ChannelType_CompositeChannels => ChannelType::CompositeChannels,
|
|
||||||
bindings::ChannelType_AllChannels => ChannelType::AllChannels,
|
|
||||||
// bindings::ChannelType_TrueAlphaChannel => { ChannelType::TrueAlphaChannel },
|
|
||||||
// bindings::ChannelType_RGBChannels => { ChannelType::RGBChannels },
|
|
||||||
bindings::ChannelType_GrayChannels => ChannelType::GrayChannels,
|
|
||||||
bindings::ChannelType_SyncChannels => ChannelType::SyncChannels,
|
|
||||||
// bindings::ChannelType_DefaultChannels => { ChannelType::DefaultChannels },
|
|
||||||
_ => ChannelType::Undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum ClipPathUnits {
|
|
||||||
Undefined = bindings::ClipPathUnits_UndefinedPathUnits,
|
|
||||||
UserSpace = bindings::ClipPathUnits_UserSpace,
|
|
||||||
UserSpaceOnUse = bindings::ClipPathUnits_UserSpaceOnUse,
|
|
||||||
ObjectBoundingBox = bindings::ClipPathUnits_ObjectBoundingBox,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ClipPathUnits {
|
|
||||||
fn default() -> Self {
|
|
||||||
return ClipPathUnits::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ClipPathUnits> for bindings::ClipPathUnits {
|
|
||||||
fn from(value: ClipPathUnits) -> Self {
|
|
||||||
return value as bindings::ClipPathUnits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::ClipPathUnits> for ClipPathUnits {
|
|
||||||
fn from(value: bindings::ClipPathUnits) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `ClipPathUnits` has the same repr as `bindings::ClipPathUnits` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than ObjectBoundingBox than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `ClipPathUnits`
|
|
||||||
*/
|
|
||||||
if value <= bindings::ClipPathUnits_ObjectBoundingBox {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return ClipPathUnits::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum ColorspaceType {
|
|
||||||
Undefined = bindings::ColorspaceType_UndefinedColorspace,
|
|
||||||
CMY = bindings::ColorspaceType_CMYColorspace,
|
|
||||||
CMYK = bindings::ColorspaceType_CMYKColorspace,
|
|
||||||
GRAY = bindings::ColorspaceType_GRAYColorspace,
|
|
||||||
HCL = bindings::ColorspaceType_HCLColorspace,
|
|
||||||
HCLp = bindings::ColorspaceType_HCLpColorspace,
|
|
||||||
HSB = bindings::ColorspaceType_HSBColorspace,
|
|
||||||
HSI = bindings::ColorspaceType_HSIColorspace,
|
|
||||||
HSL = bindings::ColorspaceType_HSLColorspace,
|
|
||||||
HSV = bindings::ColorspaceType_HSVColorspace,
|
|
||||||
HWB = bindings::ColorspaceType_HWBColorspace,
|
|
||||||
Lab = bindings::ColorspaceType_LabColorspace,
|
|
||||||
LCH = bindings::ColorspaceType_LCHColorspace,
|
|
||||||
LCHab = bindings::ColorspaceType_LCHabColorspace,
|
|
||||||
LCHuv = bindings::ColorspaceType_LCHuvColorspace,
|
|
||||||
Log = bindings::ColorspaceType_LogColorspace,
|
|
||||||
LMS = bindings::ColorspaceType_LMSColorspace,
|
|
||||||
Luv = bindings::ColorspaceType_LuvColorspace,
|
|
||||||
OHTA = bindings::ColorspaceType_OHTAColorspace,
|
|
||||||
Rec601YCbCr = bindings::ColorspaceType_Rec601YCbCrColorspace,
|
|
||||||
Rec709YCbCr = bindings::ColorspaceType_Rec709YCbCrColorspace,
|
|
||||||
RGB = bindings::ColorspaceType_RGBColorspace,
|
|
||||||
scRGB = bindings::ColorspaceType_scRGBColorspace,
|
|
||||||
sRGB = bindings::ColorspaceType_sRGBColorspace,
|
|
||||||
Transparent = bindings::ColorspaceType_TransparentColorspace,
|
|
||||||
xyY = bindings::ColorspaceType_xyYColorspace,
|
|
||||||
XYZ = bindings::ColorspaceType_XYZColorspace,
|
|
||||||
YCbCr = bindings::ColorspaceType_YCbCrColorspace,
|
|
||||||
YCC = bindings::ColorspaceType_YCCColorspace,
|
|
||||||
YDbDr = bindings::ColorspaceType_YDbDrColorspace,
|
|
||||||
YIQ = bindings::ColorspaceType_YIQColorspace,
|
|
||||||
YPbPr = bindings::ColorspaceType_YPbPrColorspace,
|
|
||||||
YUV = bindings::ColorspaceType_YUVColorspace,
|
|
||||||
LinearGRAY = bindings::ColorspaceType_LinearGRAYColorspace,
|
|
||||||
Jzazbz = bindings::ColorspaceType_JzazbzColorspace,
|
|
||||||
DisplayP3 = bindings::ColorspaceType_DisplayP3Colorspace,
|
|
||||||
Adobe98 = bindings::ColorspaceType_Adobe98Colorspace,
|
|
||||||
ProPhoto = bindings::ColorspaceType_ProPhotoColorspace,
|
|
||||||
Oklab = bindings::ColorspaceType_OklabColorspace,
|
|
||||||
Oklch = bindings::ColorspaceType_OklchColorspace,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ColorspaceType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return ColorspaceType::RGB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ColorspaceType> for bindings::ColorspaceType {
|
|
||||||
fn from(value: ColorspaceType) -> Self {
|
|
||||||
return value as bindings::ColorspaceType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::ColorspaceType> for ColorspaceType {
|
|
||||||
fn from(value: bindings::ColorspaceType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `ColorspaceType` has the same repr as `bindings::ColorspaceType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Oklch than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `ColorspaceType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::ColorspaceType_OklchColorspace {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return ColorspaceType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum CompositeOperator {
|
|
||||||
Undefined = bindings::CompositeOperator_UndefinedCompositeOp,
|
|
||||||
Alpha = bindings::CompositeOperator_AlphaCompositeOp,
|
|
||||||
Atop = bindings::CompositeOperator_AtopCompositeOp,
|
|
||||||
Blend = bindings::CompositeOperator_BlendCompositeOp,
|
|
||||||
Blur = bindings::CompositeOperator_BlurCompositeOp,
|
|
||||||
Bumpmap = bindings::CompositeOperator_BumpmapCompositeOp,
|
|
||||||
ChangeMask = bindings::CompositeOperator_ChangeMaskCompositeOp,
|
|
||||||
Clear = bindings::CompositeOperator_ClearCompositeOp,
|
|
||||||
ColorBurn = bindings::CompositeOperator_ColorBurnCompositeOp,
|
|
||||||
ColorDodge = bindings::CompositeOperator_ColorDodgeCompositeOp,
|
|
||||||
Colorize = bindings::CompositeOperator_ColorizeCompositeOp,
|
|
||||||
CopyBlack = bindings::CompositeOperator_CopyBlackCompositeOp,
|
|
||||||
CopyBlue = bindings::CompositeOperator_CopyBlueCompositeOp,
|
|
||||||
Copy = bindings::CompositeOperator_CopyCompositeOp,
|
|
||||||
CopyCyan = bindings::CompositeOperator_CopyCyanCompositeOp,
|
|
||||||
CopyGreen = bindings::CompositeOperator_CopyGreenCompositeOp,
|
|
||||||
CopyMagenta = bindings::CompositeOperator_CopyMagentaCompositeOp,
|
|
||||||
CopyAlpha = bindings::CompositeOperator_CopyAlphaCompositeOp,
|
|
||||||
CopyRed = bindings::CompositeOperator_CopyRedCompositeOp,
|
|
||||||
CopyYellow = bindings::CompositeOperator_CopyYellowCompositeOp,
|
|
||||||
Darken = bindings::CompositeOperator_DarkenCompositeOp,
|
|
||||||
DarkenIntensity = bindings::CompositeOperator_DarkenIntensityCompositeOp,
|
|
||||||
Difference = bindings::CompositeOperator_DifferenceCompositeOp,
|
|
||||||
Displace = bindings::CompositeOperator_DisplaceCompositeOp,
|
|
||||||
Dissolve = bindings::CompositeOperator_DissolveCompositeOp,
|
|
||||||
Distort = bindings::CompositeOperator_DistortCompositeOp,
|
|
||||||
DivideDst = bindings::CompositeOperator_DivideDstCompositeOp,
|
|
||||||
DivideSrc = bindings::CompositeOperator_DivideSrcCompositeOp,
|
|
||||||
DstAtop = bindings::CompositeOperator_DstAtopCompositeOp,
|
|
||||||
Dst = bindings::CompositeOperator_DstCompositeOp,
|
|
||||||
DstIn = bindings::CompositeOperator_DstInCompositeOp,
|
|
||||||
DstOut = bindings::CompositeOperator_DstOutCompositeOp,
|
|
||||||
DstOver = bindings::CompositeOperator_DstOverCompositeOp,
|
|
||||||
Exclusion = bindings::CompositeOperator_ExclusionCompositeOp,
|
|
||||||
HardLight = bindings::CompositeOperator_HardLightCompositeOp,
|
|
||||||
HardMix = bindings::CompositeOperator_HardMixCompositeOp,
|
|
||||||
Hue = bindings::CompositeOperator_HueCompositeOp,
|
|
||||||
In = bindings::CompositeOperator_InCompositeOp,
|
|
||||||
Intensity = bindings::CompositeOperator_IntensityCompositeOp,
|
|
||||||
Lighten = bindings::CompositeOperator_LightenCompositeOp,
|
|
||||||
LightenIntensity = bindings::CompositeOperator_LightenIntensityCompositeOp,
|
|
||||||
LinearBurn = bindings::CompositeOperator_LinearBurnCompositeOp,
|
|
||||||
LinearDodge = bindings::CompositeOperator_LinearDodgeCompositeOp,
|
|
||||||
LinearLight = bindings::CompositeOperator_LinearLightCompositeOp,
|
|
||||||
Luminize = bindings::CompositeOperator_LuminizeCompositeOp,
|
|
||||||
Mathematics = bindings::CompositeOperator_MathematicsCompositeOp,
|
|
||||||
MinusDst = bindings::CompositeOperator_MinusDstCompositeOp,
|
|
||||||
MinusSrc = bindings::CompositeOperator_MinusSrcCompositeOp,
|
|
||||||
Modulate = bindings::CompositeOperator_ModulateCompositeOp,
|
|
||||||
ModulusAdd = bindings::CompositeOperator_ModulusAddCompositeOp,
|
|
||||||
ModulusSubtract = bindings::CompositeOperator_ModulusSubtractCompositeOp,
|
|
||||||
Multiply = bindings::CompositeOperator_MultiplyCompositeOp,
|
|
||||||
No = bindings::CompositeOperator_NoCompositeOp,
|
|
||||||
Out = bindings::CompositeOperator_OutCompositeOp,
|
|
||||||
Over = bindings::CompositeOperator_OverCompositeOp,
|
|
||||||
Overlay = bindings::CompositeOperator_OverlayCompositeOp,
|
|
||||||
PegtopLight = bindings::CompositeOperator_PegtopLightCompositeOp,
|
|
||||||
PinLight = bindings::CompositeOperator_PinLightCompositeOp,
|
|
||||||
Plus = bindings::CompositeOperator_PlusCompositeOp,
|
|
||||||
Replace = bindings::CompositeOperator_ReplaceCompositeOp,
|
|
||||||
Saturate = bindings::CompositeOperator_SaturateCompositeOp,
|
|
||||||
Screen = bindings::CompositeOperator_ScreenCompositeOp,
|
|
||||||
SoftLight = bindings::CompositeOperator_SoftLightCompositeOp,
|
|
||||||
SrcAtop = bindings::CompositeOperator_SrcAtopCompositeOp,
|
|
||||||
Src = bindings::CompositeOperator_SrcCompositeOp,
|
|
||||||
SrcIn = bindings::CompositeOperator_SrcInCompositeOp,
|
|
||||||
SrcOut = bindings::CompositeOperator_SrcOutCompositeOp,
|
|
||||||
SrcOver = bindings::CompositeOperator_SrcOverCompositeOp,
|
|
||||||
Threshold = bindings::CompositeOperator_ThresholdCompositeOp,
|
|
||||||
VividLight = bindings::CompositeOperator_VividLightCompositeOp,
|
|
||||||
Xor = bindings::CompositeOperator_XorCompositeOp,
|
|
||||||
Stereo = bindings::CompositeOperator_StereoCompositeOp,
|
|
||||||
Freeze = bindings::CompositeOperator_FreezeCompositeOp,
|
|
||||||
Interpolate = bindings::CompositeOperator_InterpolateCompositeOp,
|
|
||||||
Negate = bindings::CompositeOperator_NegateCompositeOp,
|
|
||||||
Reflect = bindings::CompositeOperator_ReflectCompositeOp,
|
|
||||||
SoftBurn = bindings::CompositeOperator_SoftBurnCompositeOp,
|
|
||||||
SoftDodge = bindings::CompositeOperator_SoftDodgeCompositeOp,
|
|
||||||
Stamp = bindings::CompositeOperator_StampCompositeOp,
|
|
||||||
RMSE = bindings::CompositeOperator_RMSECompositeOp,
|
|
||||||
SaliencyBlend = bindings::CompositeOperator_SaliencyBlendCompositeOp,
|
|
||||||
SeamlessBlend = bindings::CompositeOperator_SeamlessBlendCompositeOp,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for CompositeOperator {
|
|
||||||
fn default() -> Self {
|
|
||||||
return CompositeOperator::Over;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<CompositeOperator> for bindings::CompositeOperator {
|
|
||||||
fn from(value: CompositeOperator) -> Self {
|
|
||||||
return value as bindings::CompositeOperator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::CompositeOperator> for CompositeOperator {
|
|
||||||
fn from(value: bindings::CompositeOperator) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `CompositeOperator` has the same repr as `bindings::CompositeOperator` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than SeamlessBlend than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `CompositeOperator`
|
|
||||||
*/
|
|
||||||
if value <= bindings::CompositeOperator_SeamlessBlendCompositeOp {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return CompositeOperator::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
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,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum DecorationType {
|
|
||||||
Undefined = bindings::DecorationType_UndefinedDecoration,
|
|
||||||
No = bindings::DecorationType_NoDecoration,
|
|
||||||
Underline = bindings::DecorationType_UnderlineDecoration,
|
|
||||||
Overline = bindings::DecorationType_OverlineDecoration,
|
|
||||||
LineThrough = bindings::DecorationType_LineThroughDecoration,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DecorationType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return DecorationType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DecorationType> for bindings::DecorationType {
|
|
||||||
fn from(value: DecorationType) -> Self {
|
|
||||||
return value as bindings::DecorationType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::DecorationType> for DecorationType {
|
|
||||||
fn from(value: bindings::DecorationType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `DecorationType` has the same repr as `bindings::DecorationType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than LineThrough than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `DecorationType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::DecorationType_LineThroughDecoration {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return DecorationType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum DirectionType {
|
|
||||||
Undefined = bindings::DirectionType_UndefinedDirection,
|
|
||||||
RightToLeft = bindings::DirectionType_RightToLeftDirection,
|
|
||||||
LeftToRight = bindings::DirectionType_LeftToRightDirection,
|
|
||||||
TopToBottom = bindings::DirectionType_TopToBottomDirection,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DirectionType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return DirectionType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DirectionType> for bindings::DirectionType {
|
|
||||||
fn from(value: DirectionType) -> Self {
|
|
||||||
return value as bindings::DirectionType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::DirectionType> for DirectionType {
|
|
||||||
fn from(value: bindings::DirectionType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `DirectionType` has the same repr as `bindings::DirectionType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than TopToBottom than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `DirectionType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::DirectionType_TopToBottomDirection {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return DirectionType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum DisposeType {
|
|
||||||
/*
|
|
||||||
* Identical to `Undefined`
|
|
||||||
*/
|
|
||||||
// Unrecognized = bindings::DisposeType_UnrecognizedDispose,
|
|
||||||
Undefined = bindings::DisposeType_UndefinedDispose,
|
|
||||||
None = bindings::DisposeType_NoneDispose,
|
|
||||||
Background = bindings::DisposeType_BackgroundDispose,
|
|
||||||
Previous = bindings::DisposeType_PreviousDispose,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DisposeType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return DisposeType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DisposeType> for bindings::DisposeType {
|
|
||||||
fn from(value: DisposeType) -> Self {
|
|
||||||
return value as bindings::DisposeType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::DisposeType> for DisposeType {
|
|
||||||
fn from(value: bindings::DisposeType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `DisposeType` has the same repr as `bindings::DisposeType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Previous than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `DisposeType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::DisposeType_PreviousDispose {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return DisposeType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum DitherMethod {
|
|
||||||
Undefined = bindings::DitherMethod_UndefinedDitherMethod,
|
|
||||||
No = bindings::DitherMethod_NoDitherMethod,
|
|
||||||
Riemersma = bindings::DitherMethod_RiemersmaDitherMethod,
|
|
||||||
FloydSteinberg = bindings::DitherMethod_FloydSteinbergDitherMethod,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DitherMethod {
|
|
||||||
fn default() -> Self {
|
|
||||||
return DitherMethod::No;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<DitherMethod> for bindings::DitherMethod {
|
|
||||||
fn from(value: DitherMethod) -> Self {
|
|
||||||
return value as bindings::DitherMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum EndianType {
|
|
||||||
Undefined = bindings::EndianType_UndefinedEndian,
|
|
||||||
LSB = bindings::EndianType_LSBEndian,
|
|
||||||
MSB = bindings::EndianType_MSBEndian,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for EndianType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return EndianType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<EndianType> for bindings::EndianType {
|
|
||||||
fn from(value: EndianType) -> Self {
|
|
||||||
return value as bindings::EndianType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::EndianType> for EndianType {
|
|
||||||
fn from(value: bindings::EndianType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `EndianType` has the same repr as `bindings::EndianType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than MSB than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `EndianType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::EndianType_MSBEndian {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return EndianType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum FillRule {
|
|
||||||
Undefined = bindings::FillRule_UndefinedRule,
|
|
||||||
EvenOdd = bindings::FillRule_EvenOddRule,
|
|
||||||
NonZero = bindings::FillRule_NonZeroRule,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for FillRule {
|
|
||||||
fn default() -> Self {
|
|
||||||
return FillRule::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<FillRule> for bindings::FillRule {
|
|
||||||
fn from(value: FillRule) -> Self {
|
|
||||||
return value as bindings::FillRule;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::FillRule> for FillRule {
|
|
||||||
fn from(value: bindings::FillRule) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `FillRule` has the same repr as `bindings::FillRule` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than NonZero than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `FillRule`
|
|
||||||
*/
|
|
||||||
if value <= bindings::FillRule_NonZeroRule {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return FillRule::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum FilterType {
|
|
||||||
Undefined = bindings::FilterType_UndefinedFilter,
|
|
||||||
Point = bindings::FilterType_PointFilter,
|
|
||||||
Box = bindings::FilterType_BoxFilter,
|
|
||||||
Triangle = bindings::FilterType_TriangleFilter,
|
|
||||||
Hermite = bindings::FilterType_HermiteFilter,
|
|
||||||
Hann = bindings::FilterType_HannFilter,
|
|
||||||
Hamming = bindings::FilterType_HammingFilter,
|
|
||||||
Blackman = bindings::FilterType_BlackmanFilter,
|
|
||||||
Gaussian = bindings::FilterType_GaussianFilter,
|
|
||||||
Quadratic = bindings::FilterType_QuadraticFilter,
|
|
||||||
Cubic = bindings::FilterType_CubicFilter,
|
|
||||||
Catrom = bindings::FilterType_CatromFilter,
|
|
||||||
Mitchell = bindings::FilterType_MitchellFilter,
|
|
||||||
Jinc = bindings::FilterType_JincFilter,
|
|
||||||
Sinc = bindings::FilterType_SincFilter,
|
|
||||||
SincFast = bindings::FilterType_SincFastFilter,
|
|
||||||
Kaiser = bindings::FilterType_KaiserFilter,
|
|
||||||
Welch = bindings::FilterType_WelchFilter,
|
|
||||||
Parzen = bindings::FilterType_ParzenFilter,
|
|
||||||
Bohman = bindings::FilterType_BohmanFilter,
|
|
||||||
Bartlett = bindings::FilterType_BartlettFilter,
|
|
||||||
Lagrange = bindings::FilterType_LagrangeFilter,
|
|
||||||
Lanczos = bindings::FilterType_LanczosFilter,
|
|
||||||
LanczosSharp = bindings::FilterType_LanczosSharpFilter,
|
|
||||||
Lanczos2 = bindings::FilterType_Lanczos2Filter,
|
|
||||||
Lanczos2Sharp = bindings::FilterType_Lanczos2SharpFilter,
|
|
||||||
Robidoux = bindings::FilterType_RobidouxFilter,
|
|
||||||
RobidouxSharp = bindings::FilterType_RobidouxSharpFilter,
|
|
||||||
Cosine = bindings::FilterType_CosineFilter,
|
|
||||||
Spline = bindings::FilterType_SplineFilter,
|
|
||||||
LanczosRadius = bindings::FilterType_LanczosRadiusFilter,
|
|
||||||
CubicSpline = bindings::FilterType_CubicSplineFilter,
|
|
||||||
Sentinel = bindings::FilterType_SentinelFilter,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<FilterType> for bindings::FilterType {
|
|
||||||
fn from(value: FilterType) -> Self {
|
|
||||||
return value as bindings::FilterType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum GravityType {
|
|
||||||
Undefined = bindings::GravityType_UndefinedGravity,
|
|
||||||
/*
|
|
||||||
* Identical to `Undefined`
|
|
||||||
*/
|
|
||||||
// Forget = bindings::GravityType_ForgetGravity,
|
|
||||||
NorthWest = bindings::GravityType_NorthWestGravity,
|
|
||||||
North = bindings::GravityType_NorthGravity,
|
|
||||||
NorthEast = bindings::GravityType_NorthEastGravity,
|
|
||||||
West = bindings::GravityType_WestGravity,
|
|
||||||
Center = bindings::GravityType_CenterGravity,
|
|
||||||
East = bindings::GravityType_EastGravity,
|
|
||||||
SouthWest = bindings::GravityType_SouthWestGravity,
|
|
||||||
South = bindings::GravityType_SouthGravity,
|
|
||||||
SouthEast = bindings::GravityType_SouthEastGravity,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for GravityType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return GravityType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<GravityType> for bindings::GravityType {
|
|
||||||
fn from(value: GravityType) -> Self {
|
|
||||||
return value as bindings::GravityType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::GravityType> for GravityType {
|
|
||||||
fn from(value: bindings::GravityType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `GravityType` has the same repr as `bindings::GravityType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than SouthEast than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `GravityType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::GravityType_SouthEastGravity {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return GravityType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum ImageType {
|
|
||||||
Undefined = bindings::ImageType_UndefinedType,
|
|
||||||
Bilevel = bindings::ImageType_BilevelType,
|
|
||||||
Grayscale = bindings::ImageType_GrayscaleType,
|
|
||||||
GrayscaleAlpha = bindings::ImageType_GrayscaleAlphaType,
|
|
||||||
Palette = bindings::ImageType_PaletteType,
|
|
||||||
PaletteAlpha = bindings::ImageType_PaletteAlphaType,
|
|
||||||
TrueColor = bindings::ImageType_TrueColorType,
|
|
||||||
TrueColorAlpha = bindings::ImageType_TrueColorAlphaType,
|
|
||||||
ColorSeparation = bindings::ImageType_ColorSeparationType,
|
|
||||||
ColorSeparationAlpha = bindings::ImageType_ColorSeparationAlphaType,
|
|
||||||
Optimize = bindings::ImageType_OptimizeType,
|
|
||||||
PaletteBilevelAlpha = bindings::ImageType_PaletteBilevelAlphaType,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ImageType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return ImageType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ImageType> for bindings::ImageType {
|
|
||||||
fn from(value: ImageType) -> Self {
|
|
||||||
return value as bindings::ImageType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::ImageType> for ImageType {
|
|
||||||
fn from(value: bindings::ImageType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `ImageType` has the same repr as `bindings::ImageType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than SouthEast than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `ImageType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::ImageType_PaletteBilevelAlphaType {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return ImageType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum InterlaceType {
|
|
||||||
Undefined = bindings::InterlaceType_UndefinedInterlace,
|
|
||||||
No = bindings::InterlaceType_NoInterlace,
|
|
||||||
Line = bindings::InterlaceType_LineInterlace,
|
|
||||||
Plane = bindings::InterlaceType_PlaneInterlace,
|
|
||||||
Partition = bindings::InterlaceType_PartitionInterlace,
|
|
||||||
GIF = bindings::InterlaceType_GIFInterlace,
|
|
||||||
JPEG = bindings::InterlaceType_JPEGInterlace,
|
|
||||||
PNG = bindings::InterlaceType_PNGInterlace,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for InterlaceType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return InterlaceType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<InterlaceType> for bindings::InterlaceType {
|
|
||||||
fn from(value: InterlaceType) -> Self {
|
|
||||||
return value as bindings::InterlaceType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::InterlaceType> for InterlaceType {
|
|
||||||
fn from(value: bindings::InterlaceType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `InterlaceType` has the same repr as `bindings::InterlaceType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than PNG than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `InterlaceType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::InterlaceType_PNGInterlace {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return InterlaceType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -18,101 +18,6 @@ use std::ffi::CString;
|
|||||||
use crate::bindings;
|
use crate::bindings;
|
||||||
use crate::{MagickError, Result};
|
use crate::{MagickError, Result};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum KernelInfoType {
|
|
||||||
Undefined = bindings::KernelInfoType_UndefinedKernel,
|
|
||||||
Unity = bindings::KernelInfoType_UnityKernel,
|
|
||||||
Gaussian = bindings::KernelInfoType_GaussianKernel,
|
|
||||||
DoG = bindings::KernelInfoType_DoGKernel,
|
|
||||||
LoG = bindings::KernelInfoType_LoGKernel,
|
|
||||||
Blur = bindings::KernelInfoType_BlurKernel,
|
|
||||||
Comet = bindings::KernelInfoType_CometKernel,
|
|
||||||
Binomial = bindings::KernelInfoType_BinomialKernel,
|
|
||||||
Laplacian = bindings::KernelInfoType_LaplacianKernel,
|
|
||||||
Sobel = bindings::KernelInfoType_SobelKernel,
|
|
||||||
FreiChen = bindings::KernelInfoType_FreiChenKernel,
|
|
||||||
Roberts = bindings::KernelInfoType_RobertsKernel,
|
|
||||||
Prewitt = bindings::KernelInfoType_PrewittKernel,
|
|
||||||
Compass = bindings::KernelInfoType_CompassKernel,
|
|
||||||
Kirsch = bindings::KernelInfoType_KirschKernel,
|
|
||||||
Diamond = bindings::KernelInfoType_DiamondKernel,
|
|
||||||
Square = bindings::KernelInfoType_SquareKernel,
|
|
||||||
Rectangle = bindings::KernelInfoType_RectangleKernel,
|
|
||||||
Octagon = bindings::KernelInfoType_OctagonKernel,
|
|
||||||
Disk = bindings::KernelInfoType_DiskKernel,
|
|
||||||
Plus = bindings::KernelInfoType_PlusKernel,
|
|
||||||
Cross = bindings::KernelInfoType_CrossKernel,
|
|
||||||
Ring = bindings::KernelInfoType_RingKernel,
|
|
||||||
Peaks = bindings::KernelInfoType_PeaksKernel,
|
|
||||||
Edges = bindings::KernelInfoType_EdgesKernel,
|
|
||||||
Corners = bindings::KernelInfoType_CornersKernel,
|
|
||||||
Diagonals = bindings::KernelInfoType_DiagonalsKernel,
|
|
||||||
LineEnds = bindings::KernelInfoType_LineEndsKernel,
|
|
||||||
LineJunctions = bindings::KernelInfoType_LineJunctionsKernel,
|
|
||||||
Ridges = bindings::KernelInfoType_RidgesKernel,
|
|
||||||
ConvexHull = bindings::KernelInfoType_ConvexHullKernel,
|
|
||||||
ThinSE = bindings::KernelInfoType_ThinSEKernel,
|
|
||||||
Skeleton = bindings::KernelInfoType_SkeletonKernel,
|
|
||||||
Chebyshev = bindings::KernelInfoType_ChebyshevKernel,
|
|
||||||
Manhattan = bindings::KernelInfoType_ManhattanKernel,
|
|
||||||
Octagonal = bindings::KernelInfoType_OctagonalKernel,
|
|
||||||
Euclidean = bindings::KernelInfoType_EuclideanKernel,
|
|
||||||
UserDefined = bindings::KernelInfoType_UserDefinedKernel,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for KernelInfoType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return KernelInfoType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<KernelInfoType> for bindings::KernelInfoType {
|
|
||||||
fn from(value: KernelInfoType) -> Self {
|
|
||||||
return value as bindings::KernelInfoType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum MorphologyMethod {
|
|
||||||
Undefined = bindings::MorphologyMethod_UndefinedMorphology,
|
|
||||||
Convolve = bindings::MorphologyMethod_ConvolveMorphology,
|
|
||||||
Correlate = bindings::MorphologyMethod_CorrelateMorphology,
|
|
||||||
Erode = bindings::MorphologyMethod_ErodeMorphology,
|
|
||||||
Dilate = bindings::MorphologyMethod_DilateMorphology,
|
|
||||||
ErodeIntensity = bindings::MorphologyMethod_ErodeIntensityMorphology,
|
|
||||||
DilateIntensity = bindings::MorphologyMethod_DilateIntensityMorphology,
|
|
||||||
IterativeDistance = bindings::MorphologyMethod_IterativeDistanceMorphology,
|
|
||||||
Open = bindings::MorphologyMethod_OpenMorphology,
|
|
||||||
Close = bindings::MorphologyMethod_CloseMorphology,
|
|
||||||
OpenIntensity = bindings::MorphologyMethod_OpenIntensityMorphology,
|
|
||||||
CloseIntensity = bindings::MorphologyMethod_CloseIntensityMorphology,
|
|
||||||
Smooth = bindings::MorphologyMethod_SmoothMorphology,
|
|
||||||
EdgeIn = bindings::MorphologyMethod_EdgeInMorphology,
|
|
||||||
EdgeOut = bindings::MorphologyMethod_EdgeOutMorphology,
|
|
||||||
Edge = bindings::MorphologyMethod_EdgeMorphology,
|
|
||||||
TopHat = bindings::MorphologyMethod_TopHatMorphology,
|
|
||||||
BottomHat = bindings::MorphologyMethod_BottomHatMorphology,
|
|
||||||
HitAndMiss = bindings::MorphologyMethod_HitAndMissMorphology,
|
|
||||||
Thinning = bindings::MorphologyMethod_ThinningMorphology,
|
|
||||||
Thicken = bindings::MorphologyMethod_ThickenMorphology,
|
|
||||||
Distance = bindings::MorphologyMethod_DistanceMorphology,
|
|
||||||
Voronoi = bindings::MorphologyMethod_VoronoiMorphology,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for MorphologyMethod {
|
|
||||||
fn default() -> Self {
|
|
||||||
return MorphologyMethod::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MorphologyMethod> for bindings::KernelInfoType {
|
|
||||||
fn from(value: MorphologyMethod) -> Self {
|
|
||||||
return value as bindings::MorphologyMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Builder, that creates instances of [KernelInfo](self::KernelInfo)
|
/// Builder, that creates instances of [KernelInfo](self::KernelInfo)
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
@ -171,7 +76,7 @@ pub struct KernelBuilder {
|
|||||||
center: Option<(usize, usize)>,
|
center: Option<(usize, usize)>,
|
||||||
values: Option<Vec<f64>>,
|
values: Option<Vec<f64>>,
|
||||||
|
|
||||||
info_type: Option<KernelInfoType>,
|
info_type: Option<crate::KernelInfoType>,
|
||||||
geom_info: Option<crate::GeometryInfo>,
|
geom_info: Option<crate::GeometryInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +155,7 @@ impl KernelBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Used for builtin kernels
|
/// Used for builtin kernels
|
||||||
pub fn set_info_type(mut self, info_type: KernelInfoType) -> KernelBuilder {
|
pub fn set_info_type(mut self, info_type: crate::KernelInfoType) -> KernelBuilder {
|
||||||
self.info_type = Some(info_type);
|
self.info_type = Some(info_type);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -295,7 +200,7 @@ impl KernelInfo {
|
|||||||
|
|
||||||
/// The values within the kernel is scaled directly using given scaling factor without change.
|
/// The values within the kernel is scaled directly using given scaling factor without change.
|
||||||
pub fn scale(&mut self, factor: f64) {
|
pub fn scale(&mut self, factor: f64) {
|
||||||
unsafe { bindings::ScaleKernelInfo(self.kernel_info, factor, 0) }
|
unsafe { bindings::ScaleKernelInfo(self.kernel_info, factor, bindings::GeometryFlags::NoValue) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Kernel normalization is designed to ensure that any use of the kernel scaling factor with
|
/// Kernel normalization is designed to ensure that any use of the kernel scaling factor with
|
||||||
@ -319,7 +224,7 @@ impl KernelInfo {
|
|||||||
bindings::ScaleKernelInfo(
|
bindings::ScaleKernelInfo(
|
||||||
self.kernel_info,
|
self.kernel_info,
|
||||||
1.0,
|
1.0,
|
||||||
bindings::GeometryFlags_NormalizeValue,
|
bindings::GeometryFlags::NormalizeValue,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,7 +238,7 @@ impl KernelInfo {
|
|||||||
bindings::ScaleKernelInfo(
|
bindings::ScaleKernelInfo(
|
||||||
self.kernel_info,
|
self.kernel_info,
|
||||||
1.0,
|
1.0,
|
||||||
bindings::GeometryFlags_CorrelateNormalizeValue,
|
bindings::GeometryFlags::CorrelateNormalizeValue,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum LayerMethod {
|
|
||||||
Undefined = bindings::LayerMethod_UndefinedLayer,
|
|
||||||
Coalesce = bindings::LayerMethod_CoalesceLayer,
|
|
||||||
CompareAny = bindings::LayerMethod_CompareAnyLayer,
|
|
||||||
CompareClear = bindings::LayerMethod_CompareClearLayer,
|
|
||||||
CompareOverlay = bindings::LayerMethod_CompareOverlayLayer,
|
|
||||||
Dispose = bindings::LayerMethod_DisposeLayer,
|
|
||||||
Optimize = bindings::LayerMethod_OptimizeLayer,
|
|
||||||
OptimizeImage = bindings::LayerMethod_OptimizeImageLayer,
|
|
||||||
OptimizePlus = bindings::LayerMethod_OptimizePlusLayer,
|
|
||||||
OptimizeTrans = bindings::LayerMethod_OptimizeTransLayer,
|
|
||||||
RemoveDups = bindings::LayerMethod_RemoveDupsLayer,
|
|
||||||
RemoveZero = bindings::LayerMethod_RemoveZeroLayer,
|
|
||||||
Composite = bindings::LayerMethod_CompositeLayer,
|
|
||||||
Merge = bindings::LayerMethod_MergeLayer,
|
|
||||||
Flatten = bindings::LayerMethod_FlattenLayer,
|
|
||||||
Mosaic = bindings::LayerMethod_MosaicLayer,
|
|
||||||
TrimBounds = bindings::LayerMethod_TrimBoundsLayer,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for LayerMethod {
|
|
||||||
fn default() -> Self {
|
|
||||||
return LayerMethod::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<LayerMethod> for bindings::LayerMethod {
|
|
||||||
fn from(value: LayerMethod) -> Self {
|
|
||||||
return value as bindings::LayerMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum LineCap {
|
|
||||||
Undefined = bindings::LineCap_UndefinedCap,
|
|
||||||
Butt = bindings::LineCap_ButtCap,
|
|
||||||
Round = bindings::LineCap_RoundCap,
|
|
||||||
Square = bindings::LineCap_SquareCap,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for LineCap {
|
|
||||||
fn default() -> Self {
|
|
||||||
return LineCap::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<LineCap> for bindings::LineCap {
|
|
||||||
fn from(value: LineCap) -> Self {
|
|
||||||
return value as bindings::LineCap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::LineCap> for LineCap {
|
|
||||||
fn from(value: bindings::LineCap) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `LineCap` has the same repr as `bindings::LineCap` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Square than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `LineCap`
|
|
||||||
*/
|
|
||||||
if value <= bindings::LineCap_SquareCap {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return LineCap::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum LineJoin {
|
|
||||||
Undefined = bindings::LineJoin_UndefinedJoin,
|
|
||||||
Miter = bindings::LineJoin_MiterJoin,
|
|
||||||
Round = bindings::LineJoin_RoundJoin,
|
|
||||||
Bevel = bindings::LineJoin_BevelJoin,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for LineJoin {
|
|
||||||
fn default() -> Self {
|
|
||||||
return LineJoin::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<LineJoin> for bindings::LineJoin {
|
|
||||||
fn from(value: LineJoin) -> Self {
|
|
||||||
return value as bindings::LineJoin;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::LineJoin> for LineJoin {
|
|
||||||
fn from(value: bindings::LineJoin) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `LineJoin` has the same repr as `bindings::LineJoin` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Bevel than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `LineJoin`
|
|
||||||
*/
|
|
||||||
if value <= bindings::LineJoin_BevelJoin {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return LineJoin::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum MagickEvaluateOperator {
|
|
||||||
Undefined = bindings::MagickEvaluateOperator_UndefinedEvaluateOperator,
|
|
||||||
Abs = bindings::MagickEvaluateOperator_AbsEvaluateOperator,
|
|
||||||
Add = bindings::MagickEvaluateOperator_AddEvaluateOperator,
|
|
||||||
AddModulus = bindings::MagickEvaluateOperator_AddModulusEvaluateOperator,
|
|
||||||
And = bindings::MagickEvaluateOperator_AndEvaluateOperator,
|
|
||||||
Cosine = bindings::MagickEvaluateOperator_CosineEvaluateOperator,
|
|
||||||
Divide = bindings::MagickEvaluateOperator_DivideEvaluateOperator,
|
|
||||||
Exponential = bindings::MagickEvaluateOperator_ExponentialEvaluateOperator,
|
|
||||||
GaussianNoise = bindings::MagickEvaluateOperator_GaussianNoiseEvaluateOperator,
|
|
||||||
ImpulseNoise = bindings::MagickEvaluateOperator_ImpulseNoiseEvaluateOperator,
|
|
||||||
LaplacianNoise = bindings::MagickEvaluateOperator_LaplacianNoiseEvaluateOperator,
|
|
||||||
LeftShift = bindings::MagickEvaluateOperator_LeftShiftEvaluateOperator,
|
|
||||||
Log = bindings::MagickEvaluateOperator_LogEvaluateOperator,
|
|
||||||
Max = bindings::MagickEvaluateOperator_MaxEvaluateOperator,
|
|
||||||
Mean = bindings::MagickEvaluateOperator_MeanEvaluateOperator,
|
|
||||||
Median = bindings::MagickEvaluateOperator_MedianEvaluateOperator,
|
|
||||||
Min = bindings::MagickEvaluateOperator_MinEvaluateOperator,
|
|
||||||
MultiplicativeNoise = bindings::MagickEvaluateOperator_MultiplicativeNoiseEvaluateOperator,
|
|
||||||
Multiply = bindings::MagickEvaluateOperator_MultiplyEvaluateOperator,
|
|
||||||
Or = bindings::MagickEvaluateOperator_OrEvaluateOperator,
|
|
||||||
PoissonNoise = bindings::MagickEvaluateOperator_PoissonNoiseEvaluateOperator,
|
|
||||||
Pow = bindings::MagickEvaluateOperator_PowEvaluateOperator,
|
|
||||||
RightShift = bindings::MagickEvaluateOperator_RightShiftEvaluateOperator,
|
|
||||||
RootMeanSquare = bindings::MagickEvaluateOperator_RootMeanSquareEvaluateOperator,
|
|
||||||
Set = bindings::MagickEvaluateOperator_SetEvaluateOperator,
|
|
||||||
Sine = bindings::MagickEvaluateOperator_SineEvaluateOperator,
|
|
||||||
Subtract = bindings::MagickEvaluateOperator_SubtractEvaluateOperator,
|
|
||||||
Sum = bindings::MagickEvaluateOperator_SumEvaluateOperator,
|
|
||||||
ThresholdBlack = bindings::MagickEvaluateOperator_ThresholdBlackEvaluateOperator,
|
|
||||||
Threshold = bindings::MagickEvaluateOperator_ThresholdEvaluateOperator,
|
|
||||||
ThresholdWhite = bindings::MagickEvaluateOperator_ThresholdWhiteEvaluateOperator,
|
|
||||||
UniformNoise = bindings::MagickEvaluateOperator_UniformNoiseEvaluateOperator,
|
|
||||||
Xor = bindings::MagickEvaluateOperator_XorEvaluateOperator,
|
|
||||||
InverseLog = bindings::MagickEvaluateOperator_InverseLogEvaluateOperator,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for MagickEvaluateOperator {
|
|
||||||
fn default() -> Self {
|
|
||||||
return MagickEvaluateOperator::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MagickEvaluateOperator> for bindings::MagickEvaluateOperator {
|
|
||||||
fn from(value: MagickEvaluateOperator) -> Self {
|
|
||||||
return value as bindings::MagickEvaluateOperator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum MagickFunction {
|
|
||||||
Undefined = bindings::MagickFunction_UndefinedFunction,
|
|
||||||
Arcsin = bindings::MagickFunction_ArcsinFunction,
|
|
||||||
Arctan = bindings::MagickFunction_ArctanFunction,
|
|
||||||
Polynomial = bindings::MagickFunction_PolynomialFunction,
|
|
||||||
Sinusoid = bindings::MagickFunction_SinusoidFunction,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for MagickFunction {
|
|
||||||
fn default() -> Self {
|
|
||||||
return MagickFunction::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MagickFunction> for bindings::MagickFunction {
|
|
||||||
fn from(value: MagickFunction) -> Self {
|
|
||||||
return value as bindings::MagickFunction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
pub enum MetricType {
|
|
||||||
Undefined = bindings::MetricType_UndefinedErrorMetric as isize,
|
|
||||||
Absolute = bindings::MetricType_AbsoluteErrorMetric as isize,
|
|
||||||
Fuzz = bindings::MetricType_FuzzErrorMetric as isize,
|
|
||||||
MeanAbsolute = bindings::MetricType_MeanAbsoluteErrorMetric as isize,
|
|
||||||
MeanErrorPerPixel = bindings::MetricType_MeanErrorPerPixelErrorMetric as isize,
|
|
||||||
MeanSquared = bindings::MetricType_MeanSquaredErrorMetric as isize,
|
|
||||||
NormalizedCrossCorrelation =
|
|
||||||
bindings::MetricType_NormalizedCrossCorrelationErrorMetric as isize,
|
|
||||||
PeakAbsolute = bindings::MetricType_PeakAbsoluteErrorMetric as isize,
|
|
||||||
PeakSignalToNoiseRatio = bindings::MetricType_PeakSignalToNoiseRatioErrorMetric as isize,
|
|
||||||
PerceptualHash = bindings::MetricType_PerceptualHashErrorMetric as isize,
|
|
||||||
RootMeanSquared = bindings::MetricType_RootMeanSquaredErrorMetric as isize,
|
|
||||||
StructuralSimilarity = bindings::MetricType_StructuralSimilarityErrorMetric as isize,
|
|
||||||
StructuralDissimilarity = bindings::MetricType_StructuralDissimilarityErrorMetric as isize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for MetricType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return MetricType::Absolute;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<MetricType> for bindings::MetricType {
|
|
||||||
fn from(value: MetricType) -> Self {
|
|
||||||
return value as bindings::MetricType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
110
src/types/mod.rs
110
src/types/mod.rs
@ -13,76 +13,46 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
mod align_type;
|
|
||||||
mod alpha_channel_option;
|
|
||||||
mod auto_threshold_method;
|
|
||||||
mod channel_type;
|
|
||||||
mod clip_path_units;
|
|
||||||
mod colorspace_type;
|
|
||||||
mod composite_operator;
|
|
||||||
mod compression_type;
|
|
||||||
mod decoration_type;
|
|
||||||
mod direction_type;
|
|
||||||
mod dispose_type;
|
|
||||||
mod dither_method;
|
|
||||||
mod endian_type;
|
|
||||||
mod fill_rule;
|
|
||||||
mod filter_type;
|
|
||||||
mod geometry_info;
|
|
||||||
mod gravity_type;
|
|
||||||
mod image;
|
|
||||||
mod image_type;
|
|
||||||
mod interlace_type;
|
|
||||||
mod kernel;
|
|
||||||
mod layer_method;
|
|
||||||
mod line_cap;
|
|
||||||
mod line_join;
|
|
||||||
mod magick_evaluate_operator;
|
|
||||||
mod magick_function;
|
|
||||||
mod metric_type;
|
|
||||||
mod orientation_type;
|
|
||||||
mod pixel_interpolate_method;
|
|
||||||
mod pixel_mask;
|
|
||||||
mod rendering_intent;
|
|
||||||
mod resolution_type;
|
|
||||||
mod resource_type;
|
|
||||||
mod statistic_type;
|
|
||||||
mod stretch_type;
|
|
||||||
mod style_type;
|
|
||||||
|
|
||||||
pub use self::align_type::AlignType;
|
mod geometry_info;
|
||||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
mod image;
|
||||||
pub use self::auto_threshold_method::AutoThresholdMethod;
|
mod kernel;
|
||||||
pub use self::channel_type::ChannelType;
|
|
||||||
pub use self::clip_path_units::ClipPathUnits;
|
pub use bindings::AlignType;
|
||||||
pub use self::colorspace_type::ColorspaceType;
|
pub use bindings::AlphaChannelOption;
|
||||||
pub use self::composite_operator::CompositeOperator;
|
pub use bindings::AutoThresholdMethod;
|
||||||
pub use self::compression_type::CompressionType;
|
pub use bindings::ChannelType;
|
||||||
pub use self::decoration_type::DecorationType;
|
pub use bindings::ClipPathUnits;
|
||||||
pub use self::direction_type::DirectionType;
|
pub use bindings::CompositeOperator;
|
||||||
pub use self::dispose_type::DisposeType;
|
pub use bindings::ColorspaceType;
|
||||||
pub use self::dither_method::DitherMethod;
|
pub use bindings::CompressionType;
|
||||||
pub use self::endian_type::EndianType;
|
pub use bindings::DecorationType;
|
||||||
pub use self::fill_rule::FillRule;
|
pub use bindings::DirectionType;
|
||||||
pub use self::filter_type::FilterType;
|
pub use bindings::DisposeType;
|
||||||
|
pub use bindings::DitherMethod;
|
||||||
|
pub use bindings::EndianType;
|
||||||
|
pub use bindings::FillRule;
|
||||||
|
pub use bindings::FilterType;
|
||||||
pub use self::geometry_info::GeometryInfo;
|
pub use self::geometry_info::GeometryInfo;
|
||||||
pub use self::gravity_type::GravityType;
|
pub use bindings::GravityType;
|
||||||
pub use self::image::Image;
|
pub use self::image::Image;
|
||||||
pub use self::image_type::ImageType;
|
pub use bindings::ImageType;
|
||||||
pub use self::interlace_type::InterlaceType;
|
pub use bindings::InterlaceType;
|
||||||
pub use self::kernel::*;
|
pub use bindings::KernelInfoType;
|
||||||
pub use self::layer_method::LayerMethod;
|
pub use self::kernel::{KernelBuilder, KernelInfo};
|
||||||
pub use self::line_cap::LineCap;
|
pub use bindings::LayerMethod;
|
||||||
pub use self::line_join::LineJoin;
|
pub use bindings::LineCap;
|
||||||
pub use self::magick_evaluate_operator::MagickEvaluateOperator;
|
pub use bindings::LineJoin;
|
||||||
pub use self::magick_function::MagickFunction;
|
pub use bindings::MagickEvaluateOperator;
|
||||||
pub use self::metric_type::MetricType;
|
pub use bindings::MagickFunction;
|
||||||
pub use self::orientation_type::OrientationType;
|
pub use bindings::MetricType;
|
||||||
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
pub use bindings::MorphologyMethod;
|
||||||
pub use self::pixel_mask::PixelMask;
|
pub use bindings::OrientationType;
|
||||||
pub use self::rendering_intent::RenderingIntent;
|
pub use bindings::PixelInterpolateMethod;
|
||||||
pub use self::resolution_type::ResolutionType;
|
pub use bindings::PixelMask;
|
||||||
pub use self::resource_type::ResourceType;
|
pub use bindings::RenderingIntent;
|
||||||
pub use self::statistic_type::StatisticType;
|
pub use bindings::ResolutionType;
|
||||||
pub use self::stretch_type::StretchType;
|
pub use bindings::ResourceType;
|
||||||
pub use self::style_type::StyleType;
|
pub use bindings::StatisticType;
|
||||||
|
pub use bindings::StretchType;
|
||||||
|
pub use bindings::StyleType;
|
||||||
|
|||||||
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum OrientationType {
|
|
||||||
Undefined = bindings::OrientationType_UndefinedOrientation,
|
|
||||||
TopLeft = bindings::OrientationType_TopLeftOrientation,
|
|
||||||
TopRight = bindings::OrientationType_TopRightOrientation,
|
|
||||||
BottomRight = bindings::OrientationType_BottomRightOrientation,
|
|
||||||
BottomLeft = bindings::OrientationType_BottomLeftOrientation,
|
|
||||||
LeftTop = bindings::OrientationType_LeftTopOrientation,
|
|
||||||
RightTop = bindings::OrientationType_RightTopOrientation,
|
|
||||||
RightBottom = bindings::OrientationType_RightBottomOrientation,
|
|
||||||
LeftBottom = bindings::OrientationType_LeftBottomOrientation,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for OrientationType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return OrientationType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<OrientationType> for bindings::OrientationType {
|
|
||||||
fn from(value: OrientationType) -> Self {
|
|
||||||
return value as bindings::OrientationType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::OrientationType> for OrientationType {
|
|
||||||
fn from(value: bindings::OrientationType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `OrientationType` has the same repr as `bindings::OrientationType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than LeftBottom than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `OrientationType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::OrientationType_LeftBottomOrientation {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return OrientationType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum PixelInterpolateMethod {
|
|
||||||
Undefined = bindings::PixelInterpolateMethod_UndefinedInterpolatePixel,
|
|
||||||
Average = bindings::PixelInterpolateMethod_AverageInterpolatePixel,
|
|
||||||
Average9 = bindings::PixelInterpolateMethod_Average9InterpolatePixel,
|
|
||||||
Average16 = bindings::PixelInterpolateMethod_Average16InterpolatePixel,
|
|
||||||
Background = bindings::PixelInterpolateMethod_BackgroundInterpolatePixel,
|
|
||||||
Bilinear = bindings::PixelInterpolateMethod_BilinearInterpolatePixel,
|
|
||||||
Blend = bindings::PixelInterpolateMethod_BlendInterpolatePixel,
|
|
||||||
Catrom = bindings::PixelInterpolateMethod_CatromInterpolatePixel,
|
|
||||||
Integer = bindings::PixelInterpolateMethod_IntegerInterpolatePixel,
|
|
||||||
Mesh = bindings::PixelInterpolateMethod_MeshInterpolatePixel,
|
|
||||||
Nearest = bindings::PixelInterpolateMethod_NearestInterpolatePixel,
|
|
||||||
Spline = bindings::PixelInterpolateMethod_SplineInterpolatePixel,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for PixelInterpolateMethod {
|
|
||||||
fn default() -> Self {
|
|
||||||
return PixelInterpolateMethod::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PixelInterpolateMethod> for bindings::PixelInterpolateMethod {
|
|
||||||
fn from(value: PixelInterpolateMethod) -> Self {
|
|
||||||
return value as bindings::PixelInterpolateMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::PixelInterpolateMethod> for PixelInterpolateMethod {
|
|
||||||
fn from(value: bindings::PixelInterpolateMethod) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `PixelInterpolateMethod` has the same repr as `bindings::PixelInterpolateMethod` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Spline than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `PixelInterpolateMethod`
|
|
||||||
*/
|
|
||||||
if value <= bindings::PixelInterpolateMethod_SplineInterpolatePixel {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return PixelInterpolateMethod::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum PixelMask {
|
|
||||||
Undefined = bindings::PixelMask_UndefinedPixelMask,
|
|
||||||
Read = bindings::PixelMask_ReadPixelMask,
|
|
||||||
Write = bindings::PixelMask_WritePixelMask,
|
|
||||||
Composite = bindings::PixelMask_CompositePixelMask,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for PixelMask {
|
|
||||||
fn default() -> Self {
|
|
||||||
return PixelMask::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PixelMask> for bindings::PixelMask {
|
|
||||||
fn from(value: PixelMask) -> Self {
|
|
||||||
return value as bindings::PixelMask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum RenderingIntent {
|
|
||||||
Undefined = bindings::RenderingIntent_UndefinedIntent,
|
|
||||||
Saturation = bindings::RenderingIntent_SaturationIntent,
|
|
||||||
Perceptual = bindings::RenderingIntent_PerceptualIntent,
|
|
||||||
Absolute = bindings::RenderingIntent_AbsoluteIntent,
|
|
||||||
Relative = bindings::RenderingIntent_RelativeIntent,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for RenderingIntent {
|
|
||||||
fn default() -> Self {
|
|
||||||
return RenderingIntent::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<RenderingIntent> for bindings::RenderingIntent {
|
|
||||||
fn from(value: RenderingIntent) -> Self {
|
|
||||||
return value as bindings::RenderingIntent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::RenderingIntent> for RenderingIntent {
|
|
||||||
fn from(value: bindings::RenderingIntent) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `RenderingIntent` has the same repr as `bindings::RenderingIntent` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Relative than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `RenderingIntent`
|
|
||||||
*/
|
|
||||||
if value <= bindings::RenderingIntent_RelativeIntent {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return RenderingIntent::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum ResolutionType {
|
|
||||||
Undefined = bindings::ResolutionType_UndefinedResolution,
|
|
||||||
PixelsPerInch = bindings::ResolutionType_PixelsPerInchResolution,
|
|
||||||
PixelsPerCentimeter = bindings::ResolutionType_PixelsPerCentimeterResolution,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ResolutionType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return ResolutionType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ResolutionType> for bindings::ResolutionType {
|
|
||||||
fn from(value: ResolutionType) -> Self {
|
|
||||||
return value as bindings::ResolutionType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::ResolutionType> for ResolutionType {
|
|
||||||
fn from(value: bindings::ResolutionType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `ResolutionType` has the same repr as `bindings::ResolutionType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than PixelsPerCentimeter than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `ResolutionType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::ResolutionType_PixelsPerCentimeterResolution {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return ResolutionType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
/// Resource type to use with [set_resource_limit](crate::MagickWand::set_resource_limit)
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub enum ResourceType {
|
|
||||||
Undefined = bindings::ResourceType_UndefinedResource as isize,
|
|
||||||
Area = bindings::ResourceType_AreaResource as isize,
|
|
||||||
Disk = bindings::ResourceType_DiskResource as isize,
|
|
||||||
File = bindings::ResourceType_FileResource as isize,
|
|
||||||
Height = bindings::ResourceType_HeightResource as isize,
|
|
||||||
Map = bindings::ResourceType_MapResource as isize,
|
|
||||||
Memory = bindings::ResourceType_MemoryResource as isize,
|
|
||||||
Thread = bindings::ResourceType_ThreadResource as isize,
|
|
||||||
Throttle = bindings::ResourceType_ThrottleResource as isize,
|
|
||||||
Time = bindings::ResourceType_TimeResource as isize,
|
|
||||||
Width = bindings::ResourceType_WidthResource as isize,
|
|
||||||
ListLength = bindings::ResourceType_ListLengthResource as isize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ResourceType> for bindings::ResourceType {
|
|
||||||
fn from(value: ResourceType) -> Self {
|
|
||||||
return value as bindings::ResourceType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum StatisticType {
|
|
||||||
Undefined = bindings::StatisticType_UndefinedStatistic,
|
|
||||||
Gradient = bindings::StatisticType_GradientStatistic,
|
|
||||||
Maximum = bindings::StatisticType_MaximumStatistic,
|
|
||||||
Mean = bindings::StatisticType_MeanStatistic,
|
|
||||||
Median = bindings::StatisticType_MedianStatistic,
|
|
||||||
Minimum = bindings::StatisticType_MinimumStatistic,
|
|
||||||
Mode = bindings::StatisticType_ModeStatistic,
|
|
||||||
Nonpeak = bindings::StatisticType_NonpeakStatistic,
|
|
||||||
RootMeanSquare = bindings::StatisticType_RootMeanSquareStatistic,
|
|
||||||
StandardDeviation = bindings::StatisticType_StandardDeviationStatistic,
|
|
||||||
Contrast = bindings::StatisticType_ContrastStatistic,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for StatisticType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return StatisticType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<StatisticType> for bindings::StatisticType {
|
|
||||||
fn from(value: StatisticType) -> Self {
|
|
||||||
return value as bindings::StatisticType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::StatisticType> for StatisticType {
|
|
||||||
fn from(value: bindings::StatisticType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `StatisticType` has the same repr as `bindings::StatisticType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Contrast than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `StatisticType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::StatisticType_ContrastStatistic {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return StatisticType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum StretchType {
|
|
||||||
Undefined = bindings::StretchType_UndefinedStretch,
|
|
||||||
Normal = bindings::StretchType_NormalStretch,
|
|
||||||
UltraCondensed = bindings::StretchType_UltraCondensedStretch,
|
|
||||||
ExtraCondensed = bindings::StretchType_ExtraCondensedStretch,
|
|
||||||
Condensed = bindings::StretchType_CondensedStretch,
|
|
||||||
SemiCondensed = bindings::StretchType_SemiCondensedStretch,
|
|
||||||
SemiExpanded = bindings::StretchType_SemiExpandedStretch,
|
|
||||||
Expanded = bindings::StretchType_ExpandedStretch,
|
|
||||||
ExtraExpanded = bindings::StretchType_ExtraExpandedStretch,
|
|
||||||
UltraExpanded = bindings::StretchType_UltraExpandedStretch,
|
|
||||||
Any = bindings::StretchType_AnyStretch,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for StretchType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return StretchType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<StretchType> for bindings::StretchType {
|
|
||||||
fn from(value: StretchType) -> Self {
|
|
||||||
return value as bindings::StretchType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::StretchType> for StretchType {
|
|
||||||
fn from(value: bindings::StretchType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `StretchType` has the same repr as `bindings::StretchType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Any than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `StretchType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::StretchType_AnyStretch {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return StretchType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2024 5ohue
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
use crate::bindings;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
#[repr(u32)]
|
|
||||||
pub enum StyleType {
|
|
||||||
Undefined = bindings::StyleType_UndefinedStyle,
|
|
||||||
Normal = bindings::StyleType_NormalStyle,
|
|
||||||
Italic = bindings::StyleType_ItalicStyle,
|
|
||||||
Oblique = bindings::StyleType_ObliqueStyle,
|
|
||||||
Any = bindings::StyleType_AnyStyle,
|
|
||||||
Bold = bindings::StyleType_BoldStyle,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for StyleType {
|
|
||||||
fn default() -> Self {
|
|
||||||
return StyleType::Undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<StyleType> for bindings::StyleType {
|
|
||||||
fn from(value: StyleType) -> Self {
|
|
||||||
return value as bindings::StyleType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bindings::StyleType> for StyleType {
|
|
||||||
fn from(value: bindings::StyleType) -> Self {
|
|
||||||
/*
|
|
||||||
* SAFETY:
|
|
||||||
*
|
|
||||||
* `StyleType` has the same repr as `bindings::StyleType` - u32
|
|
||||||
*
|
|
||||||
* If `value` is less than Bold than it is in the vaild range and can be safely
|
|
||||||
* reinterpreted as `StyleType`
|
|
||||||
*/
|
|
||||||
if value <= bindings::StyleType_BoldStyle {
|
|
||||||
return unsafe { std::mem::transmute(value) };
|
|
||||||
}
|
|
||||||
return StyleType::default();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -39,7 +39,7 @@ macro_rules! wand_common {
|
|||||||
|
|
||||||
pub fn clear_exception(&mut self) -> Result<()> {
|
pub fn clear_exception(&mut self) -> Result<()> {
|
||||||
match unsafe { ::bindings::$clear_exc(self.wand) } {
|
match unsafe { ::bindings::$clear_exc(self.wand) } {
|
||||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(
|
_ => Err(MagickError(
|
||||||
concat!("failed to clear", stringify!($wand), "exception").to_string(),
|
concat!("failed to clear", stringify!($wand), "exception").to_string(),
|
||||||
)),
|
)),
|
||||||
@ -52,7 +52,7 @@ macro_rules! wand_common {
|
|||||||
|
|
||||||
pub fn get_exception(&self) -> Result<(String, ::bindings::ExceptionType)> {
|
pub fn get_exception(&self) -> Result<(String, ::bindings::ExceptionType)> {
|
||||||
let mut severity: ::bindings::ExceptionType =
|
let mut severity: ::bindings::ExceptionType =
|
||||||
::bindings::ExceptionType_UndefinedException;
|
::bindings::ExceptionType::UndefinedException;
|
||||||
|
|
||||||
let ptr = unsafe { ::bindings::$get_exc(self.wand, &mut severity as *mut _) };
|
let ptr = unsafe { ::bindings::$get_exc(self.wand, &mut severity as *mut _) };
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
@ -70,7 +70,7 @@ macro_rules! wand_common {
|
|||||||
|
|
||||||
pub fn is_wand(&self) -> Result<()> {
|
pub fn is_wand(&self) -> Result<()> {
|
||||||
match unsafe { ::bindings::$is_wand(self.wand) } {
|
match unsafe { ::bindings::$is_wand(self.wand) } {
|
||||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(
|
_ => Err(MagickError(
|
||||||
concat!(stringify!($wand), " not a wand").to_string(),
|
concat!(stringify!($wand), " not a wand").to_string(),
|
||||||
)),
|
)),
|
||||||
@ -122,7 +122,7 @@ macro_rules! set_get {
|
|||||||
}
|
}
|
||||||
pub fn $set(&mut self, v: $typ) -> Result<()> {
|
pub fn $set(&mut self, v: $typ) -> Result<()> {
|
||||||
match unsafe { ::bindings::$c_set(self.wand, v.into()) } {
|
match unsafe { ::bindings::$c_set(self.wand, v.into()) } {
|
||||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(concat!(stringify!($set), " returned false").to_string()))
|
_ => Err(MagickError(concat!(stringify!($set), " returned false").to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ macro_rules! string_set_get {
|
|||||||
pub fn $set(&mut self, s: &str) -> Result<()> {
|
pub fn $set(&mut self, s: &str) -> Result<()> {
|
||||||
let c_string = std::ffi::CString::new(s).map_err(|_| "could not convert to cstring")?;
|
let c_string = std::ffi::CString::new(s).map_err(|_| "could not convert to cstring")?;
|
||||||
match unsafe { ::bindings::$c_set(self.wand, c_string.as_ptr()) } {
|
match unsafe { ::bindings::$c_set(self.wand, c_string.as_ptr()) } {
|
||||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(concat!(stringify!($set), " returned false").to_string()))
|
_ => Err(MagickError(concat!(stringify!($set), " returned false").to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ macro_rules! mutations {
|
|||||||
$(#[$attr])*
|
$(#[$attr])*
|
||||||
pub fn $fun(&self $(, $arg: $ty)*) -> Result<()> {
|
pub fn $fun(&self $(, $arg: $ty)*) -> Result<()> {
|
||||||
match unsafe { bindings::$c_fun(self.wand $(, $arg.into())*) } {
|
match unsafe { bindings::$c_fun(self.wand $(, $arg.into())*) } {
|
||||||
bindings::MagickBooleanType_MagickTrue => Ok(()),
|
bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(concat!(stringify!($c_fun), " invocation failed").to_string()))
|
_ => Err(MagickError(concat!(stringify!($c_fun), " invocation failed").to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ use libc::c_void;
|
|||||||
use libc::size_t;
|
use libc::size_t;
|
||||||
|
|
||||||
use bindings;
|
use bindings;
|
||||||
use conversions::*;
|
|
||||||
use result::MagickError;
|
use result::MagickError;
|
||||||
#[cfg(not(target_os = "freebsd"))]
|
#[cfg(not(target_os = "freebsd"))]
|
||||||
use size_t;
|
use size_t;
|
||||||
@ -140,7 +139,7 @@ impl MagickWand {
|
|||||||
|
|
||||||
pub fn append_all(&mut self, stack: bool) -> Result<MagickWand> {
|
pub fn append_all(&mut self, stack: bool) -> Result<MagickWand> {
|
||||||
unsafe { bindings::MagickResetIterator(self.wand) };
|
unsafe { bindings::MagickResetIterator(self.wand) };
|
||||||
let result = unsafe { bindings::MagickAppendImages(self.wand, stack.to_magick()) };
|
let result = unsafe { bindings::MagickAppendImages(self.wand, stack.into()) };
|
||||||
|
|
||||||
if result.is_null() {
|
if result.is_null() {
|
||||||
return Err(MagickError("failed to append image".to_string()));
|
return Err(MagickError("failed to append image".to_string()));
|
||||||
@ -160,7 +159,7 @@ impl MagickWand {
|
|||||||
pub fn write_images(&self, path: &str, adjoin: bool) -> Result<()> {
|
pub fn write_images(&self, path: &str, adjoin: bool) -> Result<()> {
|
||||||
let c_name = CString::new(path).map_err(|_| "path string contains null byte")?;
|
let c_name = CString::new(path).map_err(|_| "path string contains null byte")?;
|
||||||
let result =
|
let result =
|
||||||
unsafe { bindings::MagickWriteImages(self.wand, c_name.as_ptr(), adjoin.to_magick()) };
|
unsafe { bindings::MagickWriteImages(self.wand, c_name.as_ptr(), adjoin.into()) };
|
||||||
match result {
|
match result {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(self.get_exception()?.0)),
|
_ => Err(MagickError(self.get_exception()?.0)),
|
||||||
@ -478,7 +477,7 @@ impl MagickWand {
|
|||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
bindings::MagickSigmoidalContrastImage(
|
bindings::MagickSigmoidalContrastImage(
|
||||||
self.wand,
|
self.wand,
|
||||||
sharpen.to_magick(),
|
sharpen.into(),
|
||||||
strength,
|
strength,
|
||||||
midpoint * quantum_range,
|
midpoint * quantum_range,
|
||||||
)
|
)
|
||||||
@ -961,7 +960,7 @@ impl MagickWand {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
c_map.as_ptr(),
|
c_map.as_ptr(),
|
||||||
bindings::StorageType_CharPixel,
|
bindings::StorageType::CharPixel,
|
||||||
pixels.as_mut_ptr() as *mut c_void,
|
pixels.as_mut_ptr() as *mut c_void,
|
||||||
) == MagickTrue
|
) == MagickTrue
|
||||||
{
|
{
|
||||||
@ -993,7 +992,7 @@ impl MagickWand {
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
c_map.as_ptr(),
|
c_map.as_ptr(),
|
||||||
bindings::StorageType_DoublePixel,
|
bindings::StorageType::DoublePixel,
|
||||||
pixels.as_mut_ptr() as *mut c_void,
|
pixels.as_mut_ptr() as *mut c_void,
|
||||||
) == MagickTrue
|
) == MagickTrue
|
||||||
{
|
{
|
||||||
@ -1138,7 +1137,7 @@ impl MagickWand {
|
|||||||
self.wand,
|
self.wand,
|
||||||
new_width.into(),
|
new_width.into(),
|
||||||
new_height.into(),
|
new_height.into(),
|
||||||
bindings::FilterType_LanczosFilter,
|
FilterType::Lanczos,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1314,7 +1313,7 @@ impl MagickWand {
|
|||||||
columns,
|
columns,
|
||||||
rows,
|
rows,
|
||||||
pixel_map.as_ptr(),
|
pixel_map.as_ptr(),
|
||||||
bindings::StorageType_CharPixel,
|
bindings::StorageType::CharPixel,
|
||||||
pixels.as_ptr() as *const libc::c_void,
|
pixels.as_ptr() as *const libc::c_void,
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
@ -1341,8 +1340,8 @@ impl MagickWand {
|
|||||||
columns,
|
columns,
|
||||||
rows,
|
rows,
|
||||||
pixel_map.as_ptr(),
|
pixel_map.as_ptr(),
|
||||||
bindings::StorageType_DoublePixel,
|
bindings::StorageType::DoublePixel,
|
||||||
pixels.as_ptr() as *const libc::c_void,
|
pixels.as_ptr() as *const c_void,
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
@ -1401,7 +1400,7 @@ impl MagickWand {
|
|||||||
colorspace.into(),
|
colorspace.into(),
|
||||||
tree_depth.into(),
|
tree_depth.into(),
|
||||||
dither_method.into(),
|
dither_method.into(),
|
||||||
measure_error.to_magick(),
|
measure_error.into(),
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
@ -1425,7 +1424,7 @@ impl MagickWand {
|
|||||||
colorspace.into(),
|
colorspace.into(),
|
||||||
tree_depth.into(),
|
tree_depth.into(),
|
||||||
dither_method.into(),
|
dither_method.into(),
|
||||||
measure_error.to_magick(),
|
measure_error.into(),
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
|
|||||||
@ -23,5 +23,5 @@ pub use self::drawing::DrawingWand;
|
|||||||
pub use self::magick::MagickWand;
|
pub use self::magick::MagickWand;
|
||||||
pub use self::pixel::{PixelWand, HSL};
|
pub use self::pixel::{PixelWand, HSL};
|
||||||
|
|
||||||
use bindings::MagickBooleanType_MagickFalse as MagickFalse;
|
use bindings::MagickBooleanType::MagickFalse as MagickFalse;
|
||||||
use bindings::MagickBooleanType_MagickTrue as MagickTrue;
|
use bindings::MagickBooleanType::MagickTrue as MagickTrue;
|
||||||
|
|||||||
Reference in New Issue
Block a user