Compare commits
1 Commits
958e3f6bde
...
pkg-config
| Author | SHA1 | Date | |
|---|---|---|---|
| da465daa20 |
48
INSTALL.md
48
INSTALL.md
@ -43,50 +43,6 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|||||||
. "$HOME/.cargo/env"
|
. "$HOME/.cargo/env"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Installing on Windows
|
|
||||||
|
|
||||||
Currently, the only way to build on Windows is from source, as the `.lib` files have been removed from the binary releases (see [ImageMagick#7272](https://github.com/ImageMagick/ImageMagick/issues/7272)). You will need to follow the below steps carefully.
|
|
||||||
|
|
||||||
1. Ensure you have installed Git and LLVM. The easiest way to do this on Windows is by using `winget`:
|
|
||||||
```powershell
|
|
||||||
winget install Git.Git
|
|
||||||
winget install LLVM.LLVM
|
|
||||||
```
|
|
||||||
2. Ensure you have installed Visual Studio 2022, with the "C++ MFC for latest build tools (x86 & x64)".
|
|
||||||
3. Clone the [ImageMagick-Windows](https://github.com/ImageMagick/ImageMagick-Windows) repository to a well known place. The following instructions assume `C:\IM7`, but the choice does not matter:
|
|
||||||
```powershell
|
|
||||||
git clone https://github.com/ImageMagick/ImageMagick-Windows C:\IM7
|
|
||||||
```
|
|
||||||
4. Run the `CloneRepositories.IM7.cmd` batch file from the source directory, but take care to include the SHA hash of the latest [ImageMagick](https://github.com/ImageMagick/ImageMagick) release (e.g. d775d2a for [7.1.1-35](https://github.com/ImageMagick/ImageMagick/releases/tag/7.1.1-35)):
|
|
||||||
```powershell
|
|
||||||
cd C:\IM7
|
|
||||||
.\CloneRepositories.IM7.cmd d775d2a
|
|
||||||
```
|
|
||||||
5. With Visual Studio 2022, open the `C:\IM7\Configure\Configure.sln` solution.
|
|
||||||
6. Build and run this application. You can use Ctrl+F5 as a shortcut.
|
|
||||||
7. Using the wizard, configure for "Dynamic Multi-Threaded DLL Runtimes". You can leave everything else as defaults.
|
|
||||||
8. Open the generated `C:\IM7\IM7.Dynamic.x64.sln` solution.
|
|
||||||
9. Change the run configuration from Debug to Release mode.
|
|
||||||
10. Build the solution using "Build Solution" under the "Build" menu, or press Ctrl+Shift+B.
|
|
||||||
12. Get a cup of coffee, because this will take a while to finish compiling.
|
|
||||||
13. Search for "Edit the system environment variables" in the Start menu and click on "Environment Variables..."
|
|
||||||
14. Add the following as system or user environment variables (replacing `C:\IM7` as appropriate):
|
|
||||||
```ini
|
|
||||||
IMAGE_MAGICK_DIR=C:\IM7\Output
|
|
||||||
IMAGE_MAGICK_INCLUDE_DIRS=C:\IM7\ImageMagick
|
|
||||||
```
|
|
||||||
15. Add the following directory to your `PATH` variable:
|
|
||||||
```
|
|
||||||
C:\IM7\Output\bin
|
|
||||||
```
|
|
||||||
16. Once you have restarted your IDE or terminal to pick up on the changes, you may run `cargo build` in your project that includes `magick_rust` to confirm that ImageMagick is linked successfully.
|
|
||||||
|
|
||||||
__NOTE:__ Keep in mind that these instructions will *dynamically* link your Rust application with the ImageMagick DLLs. Thus, when distributing your application, you will either need to provide these DLLs (found as `C:\IM7\Output\bin\*_RL_*_.dll`) in the same directory as your executable, or get your users to install the ImageMagick binary distribution.
|
|
||||||
|
|
||||||
A set of instructions to enable static linkage of ImageMagick on Windows has yet to be found.
|
|
||||||
|
|
||||||
## Creating an Example
|
|
||||||
|
|
||||||
Create the example and copy the code that follows into the `src/main.rs` file.
|
Create the example and copy the code that follows into the `src/main.rs` file.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@ -134,9 +90,7 @@ cargo run
|
|||||||
|
|
||||||
Hopefully that produced a `thumbnail-cat.jpg` file.
|
Hopefully that produced a `thumbnail-cat.jpg` file.
|
||||||
|
|
||||||
## Debugging
|
### Debugging
|
||||||
|
|
||||||
### Linux builds
|
|
||||||
|
|
||||||
Maybe that failed with the "failed to read file" error, in which case you can double-check that the image libraries were found and linked into the final binary. Use the `ldd` tool as shown below to make sure there are no libraries that were "not found". If there are any, make sure to install the requisite library, and then try `ldd` again.
|
Maybe that failed with the "failed to read file" error, in which case you can double-check that the image libraries were found and linked into the final binary. Use the `ldd` tool as shown below to make sure there are no libraries that were "not found". If there are any, make sure to install the requisite library, and then try `ldd` again.
|
||||||
|
|
||||||
|
|||||||
28
README.md
28
README.md
@ -7,12 +7,12 @@ A somewhat safe Rust interface to the [ImageMagick](http://www.imagemagick.org/)
|
|||||||
Because this crate is generating bindings for a C/C++ library, there are several dependencies beyond simply having the latest Rust toolchain installed.
|
Because this crate is generating bindings for a C/C++ library, there are several dependencies beyond simply having the latest Rust toolchain installed.
|
||||||
|
|
||||||
* [Rust](https://www.rust-lang.org) stable
|
* [Rust](https://www.rust-lang.org) stable
|
||||||
* [ImageMagick](https://imagemagick.org) (version 7.1.1-26 or later)
|
* [ImageMagick](https://imagemagick.org) (version 7.0.10-36 to 7.1.x)
|
||||||
- Does _not_ work with ImageMagick **6.x** due to backward incompatible changes.
|
- Does _not_ work with ImageMagick **6.x** due to backward incompatible changes.
|
||||||
- [FreeBSD](https://www.freebsd.org): `sudo pkg install ImageMagick7`
|
- [FreeBSD](https://www.freebsd.org): `sudo pkg install ImageMagick7`
|
||||||
- [Homebrew](http://brew.sh): `brew install imagemagick`
|
- [Homebrew](http://brew.sh): `brew install imagemagick`
|
||||||
- Linux may require building ImageMagick from source, see the [INSTALL.md](./INSTALL.md) guide
|
- Linux may require building ImageMagick from source, see the [INSTALL.md](./INSTALL.md) guide
|
||||||
- Windows currently requires building from source, see [INSTALL.md](./INSTALL.md#installing-on-windows)
|
- Windows: download `*-dll` [installer](https://www.imagemagick.org/script/download.php#windows). When installing, check the *Install development headers and libraries for C and C++* checkbox.
|
||||||
* [Clang](https://clang.llvm.org) (version 5.0 or higher, as dictated by [rust-bindgen](https://github.com/rust-lang/rust-bindgen))
|
* [Clang](https://clang.llvm.org) (version 5.0 or higher, as dictated by [rust-bindgen](https://github.com/rust-lang/rust-bindgen))
|
||||||
* Windows requires MSVC toolchain
|
* Windows requires MSVC toolchain
|
||||||
- Download the [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and select the `MSVC ... build tools` (latest version with appropriate architecture) and `Windows 11 SDK` (or `10` if using Windows 10).
|
- Download the [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and select the `MSVC ... build tools` (latest version with appropriate architecture) and `Windows 11 SDK` (or `10` if using Windows 10).
|
||||||
@ -25,8 +25,8 @@ For detailed examples, see the [INSTALL.md](./INSTALL.md) guide, along with some
|
|||||||
On FreeBSD, Linux, and macOS the following commands should suffice.
|
On FreeBSD, Linux, and macOS the following commands should suffice.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cargo build
|
$ cargo build
|
||||||
cargo test
|
$ cargo test
|
||||||
```
|
```
|
||||||
|
|
||||||
If `pkg-config` is not available, or you wish to override its behavior, you can set one or more environment variables before building. The `build.rs` script will pick these up and use them instead of trying to invoke the `pkg-config` utility.
|
If `pkg-config` is not available, or you wish to override its behavior, you can set one or more environment variables before building. The `build.rs` script will pick these up and use them instead of trying to invoke the `pkg-config` utility.
|
||||||
@ -38,7 +38,13 @@ If `pkg-config` is not available, or you wish to override its behavior, you can
|
|||||||
|
|
||||||
### Build on Windows
|
### Build on Windows
|
||||||
|
|
||||||
At the moment, building on Windows requires building from source. See [INSTALL.md](./INSTALL.md#installing-on-windows) for guidance.
|
When building on Windows, you will need to set the `IMAGE_MAGICK_DIR` environment variable to point to the ImageMagick installation path. Maybe this is possible with the `set` command, but it may be necessary to set the variable in the system preferences. Without setting `IMAGE_MAGICK_DIR`, the `build.rs` script will try to run `pkg-config` which is a tool generally found on Unix-based systems.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
> set IMAGE_MAGICK_DIR=<path to ImageMagick installation directory>
|
||||||
|
> cargo build
|
||||||
|
> cargo test
|
||||||
|
```
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@ -57,10 +63,10 @@ There are still many missing functions, so if you find there is something you wo
|
|||||||
[Docker](https://www.docker.com) can be used to build and test the code without affecting your development environment, which may have a different version of ImageMagick installed. The use of `docker compose`, as shown in the example below, is optional, but it makes the process very simple.
|
[Docker](https://www.docker.com) can be used to build and test the code without affecting your development environment, which may have a different version of ImageMagick installed. The use of `docker compose`, as shown in the example below, is optional, but it makes the process very simple.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
cd docker
|
$ cd docker
|
||||||
docker compose build --pull
|
$ docker compose build --pull
|
||||||
docker compose run magick-rust
|
$ docker compose run magick-rust
|
||||||
cargo clean
|
$ cargo clean
|
||||||
cargo build
|
$ cargo build
|
||||||
cargo test
|
$ cargo test
|
||||||
```
|
```
|
||||||
|
|||||||
194
build.rs
194
build.rs
@ -16,14 +16,14 @@
|
|||||||
extern crate bindgen;
|
extern crate bindgen;
|
||||||
extern crate pkg_config;
|
extern crate pkg_config;
|
||||||
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashSet;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
const MIN_VERSION: &str = "7.1.1";
|
const MIN_VERSION: &str = "7.0";
|
||||||
const MAX_VERSION: &str = "7.2";
|
const MAX_VERSION: &str = "7.2";
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -47,73 +47,8 @@ pub const PATH_SEPARATOR: &str = match cfg!(target_os = "windows") {
|
|||||||
_ => ":",
|
_ => ":",
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct IgnoreMacros {
|
|
||||||
macros_to_ignore: HashSet<String>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IgnoreMacros {
|
|
||||||
fn from_iter<S, I>(macro_names: I) -> Self
|
|
||||||
where
|
|
||||||
S: Into<String>,
|
|
||||||
I: IntoIterator<Item = S>
|
|
||||||
{
|
|
||||||
let mut macros_to_ignore = HashSet::new();
|
|
||||||
for macro_name in macro_names {
|
|
||||||
macros_to_ignore.insert(macro_name.into());
|
|
||||||
}
|
|
||||||
Self {
|
|
||||||
macros_to_ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bindgen::callbacks::ParseCallbacks for IgnoreMacros {
|
|
||||||
fn will_parse_macro(&self, name: &str) -> bindgen::callbacks::MacroParsingBehavior {
|
|
||||||
if self.macros_to_ignore.contains(name) {
|
|
||||||
bindgen::callbacks::MacroParsingBehavior::Ignore
|
|
||||||
} else {
|
|
||||||
bindgen::callbacks::MacroParsingBehavior::Default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct RemoveEnumVariantSuffixes {
|
|
||||||
names_to_suffix: HashMap<String, String>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RemoveEnumVariantSuffixes {
|
|
||||||
fn from_iter<S, I>(enum_suffix_pairs: I) -> Self
|
|
||||||
where
|
|
||||||
S: Into<String>,
|
|
||||||
I: IntoIterator<Item = (S, S)>,
|
|
||||||
{
|
|
||||||
let mut names_to_suffix = HashMap::new();
|
|
||||||
for (enum_name, variant_suffix) in enum_suffix_pairs {
|
|
||||||
names_to_suffix.insert(enum_name.into(), variant_suffix.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
|
||||||
names_to_suffix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl bindgen::callbacks::ParseCallbacks for RemoveEnumVariantSuffixes {
|
|
||||||
fn enum_variant_name(
|
|
||||||
&self,
|
|
||||||
enum_name: Option<&str>,
|
|
||||||
original_variant_name: &str,
|
|
||||||
_variant_value: bindgen::callbacks::EnumVariantValue
|
|
||||||
) -> Option<String> {
|
|
||||||
let suffix = self.names_to_suffix.get(enum_name?)?;
|
|
||||||
Some(original_variant_name.trim_end_matches(suffix).to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let check_cppflags = if cfg!(all(target_os = "windows", not(target_env = "msvc"))) {
|
let check_cppflags = if cfg!(target_os = "windows") {
|
||||||
// Resolve bash from directories listed in the PATH environment variable in the
|
// Resolve bash from directories listed in the PATH environment variable in the
|
||||||
// order they appear.
|
// order they appear.
|
||||||
Command::new("cmd")
|
Command::new("cmd")
|
||||||
@ -123,7 +58,7 @@ fn main() {
|
|||||||
.arg("--cppflags")
|
.arg("--cppflags")
|
||||||
.output()
|
.output()
|
||||||
} else {
|
} else {
|
||||||
Command::new("MagickCore-config").arg("--cppflags").output()
|
Command::new("pkg-config").args(["--cflags", "--libs", "MagickCore"]).output()
|
||||||
};
|
};
|
||||||
if let Ok(ok_cppflags) = check_cppflags {
|
if let Ok(ok_cppflags) = check_cppflags {
|
||||||
let cppflags = ok_cppflags.stdout;
|
let cppflags = ok_cppflags.stdout;
|
||||||
@ -159,7 +94,7 @@ fn main() {
|
|||||||
Ok(ref v) => v.split(PATH_SEPARATOR).map(|x| x.to_owned()).collect(),
|
Ok(ref v) => v.split(PATH_SEPARATOR).map(|x| x.to_owned()).collect(),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
if target.contains("windows") {
|
if target.contains("windows") {
|
||||||
vec!["CORE_RL_MagickWand_".to_string(), "CORE_RL_MagickCore_".to_string()]
|
vec!["CORE_RL_MagickWand_".to_string()]
|
||||||
} else if target.contains("freebsd") {
|
} else if target.contains("freebsd") {
|
||||||
vec!["MagickWand-7".to_string()]
|
vec!["MagickWand-7".to_string()]
|
||||||
} else {
|
} else {
|
||||||
@ -177,92 +112,36 @@ fn main() {
|
|||||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
let bindings_path_str = out_dir.join("bindings.rs");
|
let bindings_path_str = out_dir.join("bindings.rs");
|
||||||
|
|
||||||
let ignored_macros = IgnoreMacros::from_iter([
|
#[derive(Debug)]
|
||||||
"FP_INFINITE",
|
struct IgnoreMacros(HashSet<String>);
|
||||||
"FP_NAN",
|
|
||||||
"FP_NORMAL",
|
|
||||||
"FP_SUBNORMAL",
|
|
||||||
"FP_ZERO",
|
|
||||||
"IPPORT_RESERVED",
|
|
||||||
"FP_INT_UPWARD",
|
|
||||||
"FP_INT_DOWNWARD",
|
|
||||||
"FP_INT_TOWARDZERO",
|
|
||||||
"FP_INT_TONEARESTFROMZERO",
|
|
||||||
"FP_INT_TONEAREST",
|
|
||||||
]);
|
|
||||||
|
|
||||||
let remove_enum_suffixes = RemoveEnumVariantSuffixes::from_iter([
|
impl bindgen::callbacks::ParseCallbacks for IgnoreMacros {
|
||||||
("ClassType", "Class"),
|
fn will_parse_macro(&self, name: &str) -> bindgen::callbacks::MacroParsingBehavior {
|
||||||
("CompositeOperator", "CompositeOp"),
|
if self.0.contains(name) {
|
||||||
("GravityType", "Gravity"),
|
bindgen::callbacks::MacroParsingBehavior::Ignore
|
||||||
("ImageType", "Type"),
|
} else {
|
||||||
("InterlaceType", "Interlace"),
|
bindgen::callbacks::MacroParsingBehavior::Default
|
||||||
("OrientationType", "Orientation"),
|
}
|
||||||
("ResolutionType", "Resolution"),
|
}
|
||||||
("TransmitType", "TransmitType"),
|
}
|
||||||
("MapMode", "Mode"),
|
|
||||||
("ColorspaceType", "Colorspace"),
|
let ignored_macros = IgnoreMacros(
|
||||||
("ChannelType", "Channel"),
|
vec![
|
||||||
("PixelChannel", "PixelChannel"),
|
"FP_INFINITE".into(),
|
||||||
("PixelIntensityMethod", "PixelIntensityMethod"),
|
"FP_NAN".into(),
|
||||||
("PixelInterpolateMethod", "InterpolatePixel"),
|
"FP_NORMAL".into(),
|
||||||
("PixelMask", "PixelMask"),
|
"FP_SUBNORMAL".into(),
|
||||||
("PixelTrait", "PixelTrait"),
|
"FP_ZERO".into(),
|
||||||
("VirtualPixelMethod", "VirtualPixelMethod"),
|
"IPPORT_RESERVED".into(),
|
||||||
("ComplianceType", "Compliance"),
|
"FP_INT_UPWARD".into(),
|
||||||
("IlluminantType", "Illuminant"),
|
"FP_INT_DOWNWARD".into(),
|
||||||
("CompressionType", "Compression"),
|
"FP_INT_TOWARDZERO".into(),
|
||||||
("KernelInfoType", "Kernel"),
|
"FP_INT_TONEARESTFROMZERO".into(),
|
||||||
("MorphologyMethod", "Morphology"),
|
"FP_INT_TONEAREST".into(),
|
||||||
("PreviewType", "Preview"),
|
]
|
||||||
("DisposeType", "Dispose"),
|
.into_iter()
|
||||||
("LayerMethod", "Layer"),
|
.collect(),
|
||||||
("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"),
|
|
||||||
("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.
|
||||||
@ -280,11 +159,8 @@ fn main() {
|
|||||||
.header(gen_h_path.to_str().unwrap())
|
.header(gen_h_path.to_str().unwrap())
|
||||||
.size_t_is_usize(true)
|
.size_t_is_usize(true)
|
||||||
.parse_callbacks(Box::new(ignored_macros))
|
.parse_callbacks(Box::new(ignored_macros))
|
||||||
.parse_callbacks(Box::new(remove_enum_suffixes))
|
|
||||||
.blocklist_type("timex")
|
.blocklist_type("timex")
|
||||||
.blocklist_function("clock_adjtime")
|
.blocklist_function("clock_adjtime");
|
||||||
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: false })
|
|
||||||
.derive_eq(true);
|
|
||||||
|
|
||||||
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()));
|
||||||
|
|||||||
@ -15,20 +15,29 @@
|
|||||||
*/
|
*/
|
||||||
use super::bindings;
|
use super::bindings;
|
||||||
|
|
||||||
impl From<bindings::MagickBooleanType> for bool {
|
pub trait FromRust<T> {
|
||||||
fn from(value: bindings::MagickBooleanType) -> Self {
|
fn from_rust(t: T) -> Self;
|
||||||
match value {
|
}
|
||||||
bindings::MagickBooleanType::MagickFalse => false,
|
|
||||||
bindings::MagickBooleanType::MagickTrue => true
|
impl FromRust<bool> for bindings::MagickBooleanType {
|
||||||
|
fn from_rust(b: bool) -> Self {
|
||||||
|
if b {
|
||||||
|
bindings::MagickBooleanType_MagickTrue
|
||||||
|
} else {
|
||||||
|
bindings::MagickBooleanType_MagickFalse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bool> for bindings::MagickBooleanType {
|
pub trait ToMagick<T> {
|
||||||
fn from(value: bool) -> Self {
|
fn to_magick(self) -> T;
|
||||||
match value {
|
}
|
||||||
true => bindings::MagickBooleanType::MagickTrue,
|
|
||||||
false => bindings::MagickBooleanType::MagickFalse
|
impl<T, E> ToMagick<T> for E
|
||||||
}
|
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,6 +34,7 @@ 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::*;
|
||||||
@ -50,7 +51,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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +61,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +69,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() {
|
||||||
@ -77,9 +78,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)
|
||||||
|
|||||||
54
src/types/align_type.rs
Normal file
54
src/types/align_type.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
67
src/types/alpha_channel_option.rs
Normal file
67
src/types/alpha_channel_option.rs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/types/auto_threshold_method.rs
Normal file
37
src/types/auto_threshold_method.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
120
src/types/channel_type.rs
Normal file
120
src/types/channel_type.rs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/types/clip_path_units.rs
Normal file
54
src/types/clip_path_units.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
90
src/types/colorspace_type.rs
Normal file
90
src/types/colorspace_type.rs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
132
src/types/composite_operator.rs
Normal file
132
src/types/composite_operator.rs
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
79
src/types/compression_type.rs
Normal file
79
src/types/compression_type.rs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/types/decoration_type.rs
Normal file
55
src/types/decoration_type.rs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/types/direction_type.rs
Normal file
54
src/types/direction_type.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
58
src/types/dispose_type.rs
Normal file
58
src/types/dispose_type.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/types/dither_method.rs
Normal file
37
src/types/dither_method.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/types/endian_type.rs
Normal file
53
src/types/endian_type.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/types/fill_rule.rs
Normal file
53
src/types/fill_rule.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/types/filter_type.rs
Normal file
60
src/types/filter_type.rs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
64
src/types/gravity_type.rs
Normal file
64
src/types/gravity_type.rs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/types/image_type.rs
Normal file
62
src/types/image_type.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
58
src/types/interlace_type.rs
Normal file
58
src/types/interlace_type.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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,6 +18,101 @@ 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
|
||||||
@ -76,7 +171,7 @@ pub struct KernelBuilder {
|
|||||||
center: Option<(usize, usize)>,
|
center: Option<(usize, usize)>,
|
||||||
values: Option<Vec<f64>>,
|
values: Option<Vec<f64>>,
|
||||||
|
|
||||||
info_type: Option<crate::KernelInfoType>,
|
info_type: Option<KernelInfoType>,
|
||||||
geom_info: Option<crate::GeometryInfo>,
|
geom_info: Option<crate::GeometryInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +250,7 @@ impl KernelBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Used for builtin kernels
|
/// Used for builtin kernels
|
||||||
pub fn set_info_type(mut self, info_type: crate::KernelInfoType) -> KernelBuilder {
|
pub fn set_info_type(mut self, info_type: KernelInfoType) -> KernelBuilder {
|
||||||
self.info_type = Some(info_type);
|
self.info_type = Some(info_type);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -200,7 +295,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, bindings::GeometryFlags::NoValue) }
|
unsafe { bindings::ScaleKernelInfo(self.kernel_info, factor, 0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@ -224,7 +319,7 @@ impl KernelInfo {
|
|||||||
bindings::ScaleKernelInfo(
|
bindings::ScaleKernelInfo(
|
||||||
self.kernel_info,
|
self.kernel_info,
|
||||||
1.0,
|
1.0,
|
||||||
bindings::GeometryFlags::NormalizeValue,
|
bindings::GeometryFlags_NormalizeValue,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,7 +333,7 @@ impl KernelInfo {
|
|||||||
bindings::ScaleKernelInfo(
|
bindings::ScaleKernelInfo(
|
||||||
self.kernel_info,
|
self.kernel_info,
|
||||||
1.0,
|
1.0,
|
||||||
bindings::GeometryFlags::CorrelateNormalizeValue,
|
bindings::GeometryFlags_CorrelateNormalizeValue,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/types/layer_method.rs
Normal file
50
src/types/layer_method.rs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/types/line_cap.rs
Normal file
54
src/types/line_cap.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
54
src/types/line_join.rs
Normal file
54
src/types/line_join.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
67
src/types/magick_evaluate_operator.rs
Normal file
67
src/types/magick_evaluate_operator.rs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/types/magick_function.rs
Normal file
38
src/types/magick_function.rs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/types/metric_type.rs
Normal file
45
src/types/metric_type.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
104
src/types/mod.rs
104
src/types/mod.rs
@ -13,46 +13,76 @@
|
|||||||
* 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 geometry_info;
|
||||||
|
mod gravity_type;
|
||||||
mod image;
|
mod image;
|
||||||
|
mod image_type;
|
||||||
|
mod interlace_type;
|
||||||
mod kernel;
|
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 bindings::AlignType;
|
pub use self::align_type::AlignType;
|
||||||
pub use bindings::AlphaChannelOption;
|
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||||
pub use bindings::AutoThresholdMethod;
|
pub use self::auto_threshold_method::AutoThresholdMethod;
|
||||||
pub use bindings::ChannelType;
|
pub use self::channel_type::ChannelType;
|
||||||
pub use bindings::ClipPathUnits;
|
pub use self::clip_path_units::ClipPathUnits;
|
||||||
pub use bindings::CompositeOperator;
|
pub use self::colorspace_type::ColorspaceType;
|
||||||
pub use bindings::ColorspaceType;
|
pub use self::composite_operator::CompositeOperator;
|
||||||
pub use bindings::CompressionType;
|
pub use self::compression_type::CompressionType;
|
||||||
pub use bindings::DecorationType;
|
pub use self::decoration_type::DecorationType;
|
||||||
pub use bindings::DirectionType;
|
pub use self::direction_type::DirectionType;
|
||||||
pub use bindings::DisposeType;
|
pub use self::dispose_type::DisposeType;
|
||||||
pub use bindings::DitherMethod;
|
pub use self::dither_method::DitherMethod;
|
||||||
pub use bindings::EndianType;
|
pub use self::endian_type::EndianType;
|
||||||
pub use bindings::FillRule;
|
pub use self::fill_rule::FillRule;
|
||||||
pub use bindings::FilterType;
|
pub use self::filter_type::FilterType;
|
||||||
pub use self::geometry_info::GeometryInfo;
|
pub use self::geometry_info::GeometryInfo;
|
||||||
pub use bindings::GravityType;
|
pub use self::gravity_type::GravityType;
|
||||||
pub use self::image::Image;
|
pub use self::image::Image;
|
||||||
pub use bindings::ImageType;
|
pub use self::image_type::ImageType;
|
||||||
pub use bindings::InterlaceType;
|
pub use self::interlace_type::InterlaceType;
|
||||||
pub use bindings::KernelInfoType;
|
pub use self::kernel::*;
|
||||||
pub use self::kernel::{KernelBuilder, KernelInfo};
|
pub use self::layer_method::LayerMethod;
|
||||||
pub use bindings::LayerMethod;
|
pub use self::line_cap::LineCap;
|
||||||
pub use bindings::LineCap;
|
pub use self::line_join::LineJoin;
|
||||||
pub use bindings::LineJoin;
|
pub use self::magick_evaluate_operator::MagickEvaluateOperator;
|
||||||
pub use bindings::MagickEvaluateOperator;
|
pub use self::magick_function::MagickFunction;
|
||||||
pub use bindings::MagickFunction;
|
pub use self::metric_type::MetricType;
|
||||||
pub use bindings::MetricType;
|
pub use self::orientation_type::OrientationType;
|
||||||
pub use bindings::MorphologyMethod;
|
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
||||||
pub use bindings::OrientationType;
|
pub use self::pixel_mask::PixelMask;
|
||||||
pub use bindings::PixelInterpolateMethod;
|
pub use self::rendering_intent::RenderingIntent;
|
||||||
pub use bindings::PixelMask;
|
pub use self::resolution_type::ResolutionType;
|
||||||
pub use bindings::RenderingIntent;
|
pub use self::resource_type::ResourceType;
|
||||||
pub use bindings::ResolutionType;
|
pub use self::statistic_type::StatisticType;
|
||||||
pub use bindings::ResourceType;
|
pub use self::stretch_type::StretchType;
|
||||||
pub use bindings::StatisticType;
|
pub use self::style_type::StyleType;
|
||||||
pub use bindings::StretchType;
|
|
||||||
pub use bindings::StyleType;
|
|
||||||
|
|||||||
59
src/types/orientation_type.rs
Normal file
59
src/types/orientation_type.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/types/pixel_interpolate_method.rs
Normal file
62
src/types/pixel_interpolate_method.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/types/pixel_mask.rs
Normal file
37
src/types/pixel_mask.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
55
src/types/rendering_intent.rs
Normal file
55
src/types/rendering_intent.rs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/types/resolution_type.rs
Normal file
53
src/types/resolution_type.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
39
src/types/resource_type.rs
Normal file
39
src/types/resource_type.rs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
61
src/types/statistic_type.rs
Normal file
61
src/types/statistic_type.rs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
61
src/types/stretch_type.rs
Normal file
61
src/types/stretch_type.rs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
56
src/types/style_type.rs
Normal file
56
src/types/style_type.rs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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,6 +21,7 @@ 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;
|
||||||
@ -34,10 +35,8 @@ use crate::{
|
|||||||
CompressionType, DisposeType, DitherMethod, EndianType, FilterType, GravityType, Image,
|
CompressionType, DisposeType, DitherMethod, EndianType, FilterType, GravityType, Image,
|
||||||
ImageType, InterlaceType, KernelInfo, LayerMethod, MagickEvaluateOperator, MagickFunction,
|
ImageType, InterlaceType, KernelInfo, LayerMethod, MagickEvaluateOperator, MagickFunction,
|
||||||
MetricType, MorphologyMethod, OrientationType, PixelInterpolateMethod, PixelMask,
|
MetricType, MorphologyMethod, OrientationType, PixelInterpolateMethod, PixelMask,
|
||||||
RenderingIntent, ResolutionType, StatisticType,
|
RenderingIntent, ResolutionType, ResourceType, StatisticType,
|
||||||
};
|
};
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
|
||||||
use crate::ResourceType;
|
|
||||||
|
|
||||||
wand_common!(
|
wand_common!(
|
||||||
MagickWand,
|
MagickWand,
|
||||||
@ -139,7 +138,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.into()) };
|
let result = unsafe { bindings::MagickAppendImages(self.wand, stack.to_magick()) };
|
||||||
|
|
||||||
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()));
|
||||||
@ -159,7 +158,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.into()) };
|
unsafe { bindings::MagickWriteImages(self.wand, c_name.as_ptr(), adjoin.to_magick()) };
|
||||||
match result {
|
match result {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
_ => Err(MagickError(self.get_exception()?.0)),
|
_ => Err(MagickError(self.get_exception()?.0)),
|
||||||
@ -477,7 +476,7 @@ impl MagickWand {
|
|||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
bindings::MagickSigmoidalContrastImage(
|
bindings::MagickSigmoidalContrastImage(
|
||||||
self.wand,
|
self.wand,
|
||||||
sharpen.into(),
|
sharpen.to_magick(),
|
||||||
strength,
|
strength,
|
||||||
midpoint * quantum_range,
|
midpoint * quantum_range,
|
||||||
)
|
)
|
||||||
@ -960,7 +959,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
|
||||||
{
|
{
|
||||||
@ -992,7 +991,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
|
||||||
{
|
{
|
||||||
@ -1137,7 +1136,7 @@ impl MagickWand {
|
|||||||
self.wand,
|
self.wand,
|
||||||
new_width.into(),
|
new_width.into(),
|
||||||
new_height.into(),
|
new_height.into(),
|
||||||
FilterType::Lanczos,
|
bindings::FilterType_LanczosFilter,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1313,7 +1312,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,
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
@ -1340,8 +1339,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 c_void,
|
pixels.as_ptr() as *const libc::c_void,
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
@ -1400,7 +1399,7 @@ impl MagickWand {
|
|||||||
colorspace.into(),
|
colorspace.into(),
|
||||||
tree_depth.into(),
|
tree_depth.into(),
|
||||||
dither_method.into(),
|
dither_method.into(),
|
||||||
measure_error.into(),
|
measure_error.to_magick(),
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
MagickTrue => Ok(()),
|
MagickTrue => Ok(()),
|
||||||
@ -1424,7 +1423,7 @@ impl MagickWand {
|
|||||||
colorspace.into(),
|
colorspace.into(),
|
||||||
tree_depth.into(),
|
tree_depth.into(),
|
||||||
dither_method.into(),
|
dither_method.into(),
|
||||||
measure_error.into(),
|
measure_error.to_magick(),
|
||||||
)
|
)
|
||||||
} {
|
} {
|
||||||
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