Compare commits
20 Commits
pkg-config
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| dfd8df0dd1 | |||
| eaf8c333e0 | |||
| 0b174a7e8a | |||
| f796041b2f | |||
| b92bed025f | |||
| b0f5154384 | |||
| b62c9f4e17 | |||
| a741f853c2 | |||
| 7029d040b2 | |||
| b4442b61fe | |||
| 958e3f6bde | |||
| e399e0de40 | |||
| 2377d7b872 | |||
| 6a84932ffe | |||
| 3b1b7a502e | |||
| e7e7f5eb87 | |||
| 7494c1d174 | |||
| d50f01b49f | |||
| 459e392068 | |||
| a133fe4a21 |
10
.github/workflows/test-msys2.yaml
vendored
10
.github/workflows/test-msys2.yaml
vendored
@ -1,4 +1,4 @@
|
||||
name: Run tests on Windows
|
||||
name: Run tests on Windows (MSYS2)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@ -14,12 +14,12 @@ jobs:
|
||||
- name: Install dependencies
|
||||
shell: C:\msys64\usr\bin\bash.exe --login '{0}'
|
||||
run: |
|
||||
export PATH="/mingw64/bin:$PATH"
|
||||
pacman --noconfirm -S mingw-w64-x86_64-imagemagick mingw-w64-x86_64-pkg-config
|
||||
export PATH="/ucrt64/bin:$PATH"
|
||||
pacman --noconfirm -S mingw-w64-ucrt-x86_64-imagemagick mingw-w64-ucrt-x86_64-pkg-config
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-on-failure: true
|
||||
- name: Test
|
||||
run: |
|
||||
$env:PATH = "C:\msys64\usr\bin;C:\msys64\mingw64\bin;$env:PATH"
|
||||
cargo test -- --skip background --skip negate_image
|
||||
$env:PATH = "C:\msys64\usr\bin;C:\msys64\ucrt64\bin;$env:PATH"
|
||||
cargo test -- --skip test_set_background_color
|
||||
|
||||
48
INSTALL.md
48
INSTALL.md
@ -43,6 +43,50 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||
. "$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\Artifacts
|
||||
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.
|
||||
|
||||
```shell
|
||||
@ -90,7 +134,9 @@ cargo run
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
* [Rust](https://www.rust-lang.org) stable
|
||||
* [ImageMagick](https://imagemagick.org) (version 7.0.10-36 to 7.1.x)
|
||||
* [ImageMagick](https://imagemagick.org) (version 7.1.1-26 or later)
|
||||
- Does _not_ work with ImageMagick **6.x** due to backward incompatible changes.
|
||||
- [FreeBSD](https://www.freebsd.org): `sudo pkg install ImageMagick7`
|
||||
- [Homebrew](http://brew.sh): `brew install imagemagick`
|
||||
- Linux may require building ImageMagick from source, see the [INSTALL.md](./INSTALL.md) guide
|
||||
- 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.
|
||||
- Windows currently requires building from source, see [INSTALL.md](./INSTALL.md#installing-on-windows)
|
||||
* [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
|
||||
- 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.
|
||||
|
||||
```shell
|
||||
$ cargo build
|
||||
$ cargo test
|
||||
cargo build
|
||||
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.
|
||||
@ -38,13 +38,7 @@ If `pkg-config` is not available, or you wish to override its behavior, you can
|
||||
|
||||
### Build on Windows
|
||||
|
||||
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
|
||||
```
|
||||
At the moment, building on Windows requires building from source. See [INSTALL.md](./INSTALL.md#installing-on-windows) for guidance.
|
||||
|
||||
## Documentation
|
||||
|
||||
@ -63,10 +57,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.
|
||||
|
||||
```shell
|
||||
$ cd docker
|
||||
$ docker compose build --pull
|
||||
$ docker compose run magick-rust
|
||||
$ cargo clean
|
||||
$ cargo build
|
||||
$ cargo test
|
||||
cd docker
|
||||
docker compose build --pull
|
||||
docker compose run magick-rust
|
||||
cargo clean
|
||||
cargo build
|
||||
cargo test
|
||||
```
|
||||
|
||||
210
build.rs
210
build.rs
@ -16,14 +16,14 @@
|
||||
extern crate bindgen;
|
||||
extern crate pkg_config;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
const MIN_VERSION: &str = "7.0";
|
||||
const MIN_VERSION: &str = "7.1.1";
|
||||
const MAX_VERSION: &str = "7.2";
|
||||
|
||||
#[cfg(windows)]
|
||||
@ -47,19 +47,80 @@ 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() {
|
||||
let check_cppflags = if cfg!(target_os = "windows") {
|
||||
// Resolve bash from directories listed in the PATH environment variable in the
|
||||
// order they appear.
|
||||
Command::new("cmd")
|
||||
.arg("/C")
|
||||
.arg("bash")
|
||||
.arg("MagickCore-config")
|
||||
.arg("--cppflags")
|
||||
.output()
|
||||
} else {
|
||||
Command::new("MagickCore-config").arg("--cppflags").output()
|
||||
};
|
||||
let check_cppflags = Command::new("MagickCore-config")
|
||||
.arg("--cppflags")
|
||||
.output()
|
||||
.or_else(|_| {
|
||||
Command::new("pkg-config")
|
||||
.args(["--cflags", "MagickCore"])
|
||||
.output()
|
||||
});
|
||||
if let Ok(ok_cppflags) = check_cppflags {
|
||||
let cppflags = ok_cppflags.stdout;
|
||||
let cppflags = String::from_utf8(cppflags).unwrap();
|
||||
@ -94,7 +155,7 @@ fn main() {
|
||||
Ok(ref v) => v.split(PATH_SEPARATOR).map(|x| x.to_owned()).collect(),
|
||||
Err(_) => {
|
||||
if target.contains("windows") {
|
||||
vec!["CORE_RL_MagickWand_".to_string()]
|
||||
vec!["CORE_RL_MagickWand_".to_string(), "CORE_RL_MagickCore_".to_string()]
|
||||
} else if target.contains("freebsd") {
|
||||
vec!["MagickWand-7".to_string()]
|
||||
} else {
|
||||
@ -112,36 +173,92 @@ fn main() {
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
let bindings_path_str = out_dir.join("bindings.rs");
|
||||
|
||||
#[derive(Debug)]
|
||||
struct IgnoreMacros(HashSet<String>);
|
||||
let ignored_macros = IgnoreMacros::from_iter([
|
||||
"FP_INFINITE",
|
||||
"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",
|
||||
]);
|
||||
|
||||
impl bindgen::callbacks::ParseCallbacks for IgnoreMacros {
|
||||
fn will_parse_macro(&self, name: &str) -> bindgen::callbacks::MacroParsingBehavior {
|
||||
if self.0.contains(name) {
|
||||
bindgen::callbacks::MacroParsingBehavior::Ignore
|
||||
} else {
|
||||
bindgen::callbacks::MacroParsingBehavior::Default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ignored_macros = IgnoreMacros(
|
||||
vec![
|
||||
"FP_INFINITE".into(),
|
||||
"FP_NAN".into(),
|
||||
"FP_NORMAL".into(),
|
||||
"FP_SUBNORMAL".into(),
|
||||
"FP_ZERO".into(),
|
||||
"IPPORT_RESERVED".into(),
|
||||
"FP_INT_UPWARD".into(),
|
||||
"FP_INT_DOWNWARD".into(),
|
||||
"FP_INT_TOWARDZERO".into(),
|
||||
"FP_INT_TONEARESTFROMZERO".into(),
|
||||
"FP_INT_TONEAREST".into(),
|
||||
]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
);
|
||||
let remove_enum_suffixes = RemoveEnumVariantSuffixes::from_iter([
|
||||
("ClassType", "Class"),
|
||||
("CompositeOperator", "CompositeOp"),
|
||||
("GravityType", "Gravity"),
|
||||
("ImageType", "Type"),
|
||||
("InterlaceType", "Interlace"),
|
||||
("OrientationType", "Orientation"),
|
||||
("ResolutionType", "Resolution"),
|
||||
("TransmitType", "TransmitType"),
|
||||
("MapMode", "Mode"),
|
||||
("ColorspaceType", "Colorspace"),
|
||||
("ChannelType", "Channel"),
|
||||
("PixelChannel", "PixelChannel"),
|
||||
("PixelIntensityMethod", "PixelIntensityMethod"),
|
||||
("PixelInterpolateMethod", "InterpolatePixel"),
|
||||
("PixelMask", "PixelMask"),
|
||||
("PixelTrait", "PixelTrait"),
|
||||
("VirtualPixelMethod", "VirtualPixelMethod"),
|
||||
("ComplianceType", "Compliance"),
|
||||
("IlluminantType", "Illuminant"),
|
||||
("CompressionType", "Compression"),
|
||||
("KernelInfoType", "Kernel"),
|
||||
("MorphologyMethod", "Morphology"),
|
||||
("PreviewType", "Preview"),
|
||||
("DisposeType", "Dispose"),
|
||||
("LayerMethod", "Layer"),
|
||||
("RenderingIntent", "Intent"),
|
||||
("EndianType", "Endian"),
|
||||
("QuantumAlphaType", "QuantumAlpha"),
|
||||
("QuantumFormat", "QuantumFormat"),
|
||||
("QuantumType", "Quantum"),
|
||||
("FilterType", "Filter"),
|
||||
("TimerState", "TimerState"),
|
||||
("StretchType", "Stretch"),
|
||||
("StyleType", "Style"),
|
||||
("AlignType", "Align"),
|
||||
("DecorationType", "Decoration"),
|
||||
("DirectionType", "Direction"),
|
||||
("FillRule", "Rule"),
|
||||
("GradientType", "Gradient"),
|
||||
("LineCap", "Cap"),
|
||||
("LineJoin", "Join"),
|
||||
("PaintMethod", "Method"),
|
||||
("PrimitiveType", "Primitive"),
|
||||
("ReferenceType", "Reference"),
|
||||
("SpreadMethod", "Spread"),
|
||||
("WordBreakType", "WordBreakType"),
|
||||
("CacheType", "Cache"),
|
||||
("AlphaChannelOption", "AlphaChannel"),
|
||||
("MetricType", "ErrorMetric"),
|
||||
("MagickFormatType", "FormatType"),
|
||||
("MagickInfoFlag", "Flag"),
|
||||
("DistortMethod", "Distortion"),
|
||||
("SparseColorMethod", "ColorInterpolate"),
|
||||
("ComplexOperator", "ComplexOperator"),
|
||||
("MontageMode", "Mode"),
|
||||
("MagickCLDeviceType", "DeviceType"),
|
||||
("CommandOption", "Options"),
|
||||
("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() {
|
||||
// Create the header file that rust-bindgen needs as input.
|
||||
@ -159,8 +276,11 @@ fn main() {
|
||||
.header(gen_h_path.to_str().unwrap())
|
||||
.size_t_is_usize(true)
|
||||
.parse_callbacks(Box::new(ignored_macros))
|
||||
.parse_callbacks(Box::new(remove_enum_suffixes))
|
||||
.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 {
|
||||
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));
|
||||
|
||||
33
examples/add-border.rs
Normal file
33
examples/add-border.rs
Normal file
@ -0,0 +1,33 @@
|
||||
extern crate magick_rust;
|
||||
use magick_rust::{magick_wand_genesis, CompositeOperator, MagickError, MagickWand, PixelWand};
|
||||
use std::fs;
|
||||
use std::sync::Once;
|
||||
|
||||
// Used to make sure MagickWand is initialized exactly once. Note that we do not
|
||||
// bother shutting down, we simply exit when we're done.
|
||||
static START: Once = Once::new();
|
||||
|
||||
// Read the named file and add a 10 pixel border around the image
|
||||
fn add_border(filepath: &str, border_color: &str) -> Result<Vec<u8>, MagickError> {
|
||||
START.call_once(|| {
|
||||
magick_wand_genesis();
|
||||
});
|
||||
|
||||
let wand = MagickWand::new();
|
||||
wand.read_image(filepath)?;
|
||||
|
||||
let mut border = PixelWand::new();
|
||||
border.set_color(border_color)?;
|
||||
|
||||
wand.border_image(&border, 10, 10, CompositeOperator::Over)?;
|
||||
wand.write_image_blob("jpeg")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match add_border("tests/fixtures/snow-covered-cat.jpg", "red") {
|
||||
Ok(bytes) => {
|
||||
fs::write("border-cat.jpg", bytes).expect("write failed");
|
||||
}
|
||||
Err(err) => println!("error: {}", err),
|
||||
}
|
||||
}
|
||||
@ -15,29 +15,20 @@
|
||||
*/
|
||||
use super::bindings;
|
||||
|
||||
pub trait FromRust<T> {
|
||||
fn from_rust(t: T) -> Self;
|
||||
}
|
||||
|
||||
impl FromRust<bool> for bindings::MagickBooleanType {
|
||||
fn from_rust(b: bool) -> Self {
|
||||
if b {
|
||||
bindings::MagickBooleanType_MagickTrue
|
||||
} else {
|
||||
bindings::MagickBooleanType_MagickFalse
|
||||
impl From<bindings::MagickBooleanType> for bool {
|
||||
fn from(value: bindings::MagickBooleanType) -> Self {
|
||||
match value {
|
||||
bindings::MagickBooleanType::MagickFalse => false,
|
||||
bindings::MagickBooleanType::MagickTrue => true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ToMagick<T> {
|
||||
fn to_magick(self) -> T;
|
||||
}
|
||||
|
||||
impl<T, E> ToMagick<T> for E
|
||||
where
|
||||
T: FromRust<E>,
|
||||
{
|
||||
fn to_magick(self) -> T {
|
||||
<T as FromRust<E>>::from_rust(self)
|
||||
impl From<bool> for bindings::MagickBooleanType {
|
||||
fn from(value: bool) -> Self {
|
||||
match value {
|
||||
true => bindings::MagickBooleanType::MagickTrue,
|
||||
false => bindings::MagickBooleanType::MagickFalse
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
src/lib.rs
11
src/lib.rs
@ -34,7 +34,6 @@ extern crate libc;
|
||||
|
||||
use libc::size_t;
|
||||
|
||||
pub use conversions::ToMagick;
|
||||
pub use result::MagickError;
|
||||
use result::Result;
|
||||
pub use types::*;
|
||||
@ -51,7 +50,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
pub fn magick_wand_genesis() {
|
||||
unsafe {
|
||||
match bindings::IsMagickWandInstantiated() {
|
||||
bindings::MagickBooleanType_MagickTrue => (),
|
||||
bindings::MagickBooleanType::MagickTrue => (),
|
||||
_ => bindings::MagickWandGenesis(),
|
||||
}
|
||||
}
|
||||
@ -61,7 +60,7 @@ pub fn magick_wand_genesis() {
|
||||
/// This function is safe to be called repeatedly.
|
||||
pub fn magick_wand_terminus() {
|
||||
unsafe {
|
||||
if let bindings::MagickBooleanType_MagickTrue = bindings::IsMagickWandInstantiated() {
|
||||
if let bindings::MagickBooleanType::MagickTrue = bindings::IsMagickWandInstantiated() {
|
||||
bindings::MagickWandTerminus();
|
||||
}
|
||||
}
|
||||
@ -69,7 +68,7 @@ pub fn magick_wand_terminus() {
|
||||
|
||||
pub fn magick_query_fonts(pattern: &str) -> Result<Vec<String>> {
|
||||
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 =
|
||||
unsafe { bindings::MagickQueryFonts(c_string.as_ptr(), &mut number_fonts as *mut size_t) };
|
||||
if ptr.is_null() {
|
||||
@ -78,9 +77,9 @@ pub fn magick_query_fonts(pattern: &str) -> Result<Vec<String>> {
|
||||
))
|
||||
} else {
|
||||
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 {
|
||||
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())
|
||||
}
|
||||
Ok(v)
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum AlignType {
|
||||
Undefined = bindings::AlignType_UndefinedAlign,
|
||||
Left = bindings::AlignType_LeftAlign,
|
||||
Center = bindings::AlignType_CenterAlign,
|
||||
Right = bindings::AlignType_RightAlign,
|
||||
}
|
||||
|
||||
impl Default for AlignType {
|
||||
fn default() -> Self {
|
||||
return AlignType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AlignType> for bindings::AlignType {
|
||||
fn from(value: AlignType) -> Self {
|
||||
return value as bindings::AlignType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::AlignType> for AlignType {
|
||||
fn from(value: bindings::AlignType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `AlignType` has the same repr as `bindings::AlignType` - u32
|
||||
*
|
||||
* If `value` is less than Right than it is in the vaild range and can be safely
|
||||
* reinterpreted as `AlignType`
|
||||
*/
|
||||
if value <= bindings::AlignType_RightAlign {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return AlignType::default();
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum AlphaChannelOption {
|
||||
Undefined = bindings::AlphaChannelOption_UndefinedAlphaChannel,
|
||||
Activate = bindings::AlphaChannelOption_ActivateAlphaChannel,
|
||||
Associate = bindings::AlphaChannelOption_AssociateAlphaChannel,
|
||||
Background = bindings::AlphaChannelOption_BackgroundAlphaChannel,
|
||||
Copy = bindings::AlphaChannelOption_CopyAlphaChannel,
|
||||
Deactivate = bindings::AlphaChannelOption_DeactivateAlphaChannel,
|
||||
Discrete = bindings::AlphaChannelOption_DiscreteAlphaChannel,
|
||||
Disassociate = bindings::AlphaChannelOption_DisassociateAlphaChannel,
|
||||
Extract = bindings::AlphaChannelOption_ExtractAlphaChannel,
|
||||
Off = bindings::AlphaChannelOption_OffAlphaChannel,
|
||||
On = bindings::AlphaChannelOption_OnAlphaChannel,
|
||||
Opaque = bindings::AlphaChannelOption_OpaqueAlphaChannel,
|
||||
Remove = bindings::AlphaChannelOption_RemoveAlphaChannel,
|
||||
Set = bindings::AlphaChannelOption_SetAlphaChannel,
|
||||
Shape = bindings::AlphaChannelOption_ShapeAlphaChannel,
|
||||
Transparent = bindings::AlphaChannelOption_TransparentAlphaChannel,
|
||||
OffIfOpaque = bindings::AlphaChannelOption_OffIfOpaqueAlphaChannel,
|
||||
}
|
||||
|
||||
impl Default for AlphaChannelOption {
|
||||
fn default() -> Self {
|
||||
return AlphaChannelOption::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AlphaChannelOption> for bindings::AlphaChannelOption {
|
||||
fn from(value: AlphaChannelOption) -> Self {
|
||||
return value as bindings::AlphaChannelOption;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::AlphaChannelOption> for AlphaChannelOption {
|
||||
fn from(value: bindings::AlphaChannelOption) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `AlphaChannelOption` has the same repr as `bindings::AlphaChannelOption` - u32
|
||||
*
|
||||
* If `value` is less than OffIfOpaque than it is in the vaild range and can be safely
|
||||
* reinterpreted as `AlphaChannelOption`
|
||||
*/
|
||||
if value <= bindings::AlphaChannelOption_OffIfOpaqueAlphaChannel {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return AlphaChannelOption::default();
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum AutoThresholdMethod {
|
||||
Undefined = bindings::AutoThresholdMethod_UndefinedThresholdMethod,
|
||||
Kapur = bindings::AutoThresholdMethod_KapurThresholdMethod,
|
||||
OTSU = bindings::AutoThresholdMethod_OTSUThresholdMethod,
|
||||
Triangle = bindings::AutoThresholdMethod_TriangleThresholdMethod,
|
||||
}
|
||||
|
||||
impl Default for AutoThresholdMethod {
|
||||
fn default() -> Self {
|
||||
return AutoThresholdMethod::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AutoThresholdMethod> for bindings::AutoThresholdMethod {
|
||||
fn from(value: AutoThresholdMethod) -> Self {
|
||||
return value as bindings::AutoThresholdMethod;
|
||||
}
|
||||
}
|
||||
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ChannelType {
|
||||
Undefined,
|
||||
RedChannel,
|
||||
GrayChannel,
|
||||
CyanChannel,
|
||||
LChannel,
|
||||
GreenChannel,
|
||||
MagentaChannel,
|
||||
aChannel,
|
||||
BlueChannel,
|
||||
bChannel,
|
||||
YellowChannel,
|
||||
BlackChannel,
|
||||
AlphaChannel,
|
||||
OpacityChannel,
|
||||
IndexChannel,
|
||||
ReadMaskChannel,
|
||||
WriteMaskChannel,
|
||||
MetaChannel,
|
||||
CompositeMaskChannel,
|
||||
CompositeChannels,
|
||||
AllChannels,
|
||||
TrueAlphaChannel,
|
||||
RGBChannels,
|
||||
GrayChannels,
|
||||
SyncChannels,
|
||||
DefaultChannels,
|
||||
}
|
||||
|
||||
impl Default for ChannelType {
|
||||
fn default() -> Self {
|
||||
return ChannelType::DefaultChannels;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ChannelType> for bindings::ChannelType {
|
||||
fn from(value: ChannelType) -> Self {
|
||||
match value {
|
||||
ChannelType::Undefined => bindings::ChannelType_UndefinedChannel,
|
||||
ChannelType::RedChannel => bindings::ChannelType_RedChannel,
|
||||
ChannelType::GrayChannel => bindings::ChannelType_GrayChannel,
|
||||
ChannelType::CyanChannel => bindings::ChannelType_CyanChannel,
|
||||
ChannelType::LChannel => bindings::ChannelType_LChannel,
|
||||
ChannelType::GreenChannel => bindings::ChannelType_GreenChannel,
|
||||
ChannelType::MagentaChannel => bindings::ChannelType_MagentaChannel,
|
||||
ChannelType::aChannel => bindings::ChannelType_aChannel,
|
||||
ChannelType::BlueChannel => bindings::ChannelType_BlueChannel,
|
||||
ChannelType::bChannel => bindings::ChannelType_bChannel,
|
||||
ChannelType::YellowChannel => bindings::ChannelType_YellowChannel,
|
||||
ChannelType::BlackChannel => bindings::ChannelType_BlackChannel,
|
||||
ChannelType::AlphaChannel => bindings::ChannelType_AlphaChannel,
|
||||
ChannelType::OpacityChannel => bindings::ChannelType_OpacityChannel,
|
||||
ChannelType::IndexChannel => bindings::ChannelType_IndexChannel,
|
||||
ChannelType::ReadMaskChannel => bindings::ChannelType_ReadMaskChannel,
|
||||
ChannelType::WriteMaskChannel => bindings::ChannelType_WriteMaskChannel,
|
||||
ChannelType::MetaChannel => bindings::ChannelType_MetaChannel,
|
||||
ChannelType::CompositeMaskChannel => bindings::ChannelType_CompositeMaskChannel,
|
||||
ChannelType::CompositeChannels => bindings::ChannelType_CompositeChannels,
|
||||
ChannelType::AllChannels => bindings::ChannelType_AllChannels,
|
||||
ChannelType::TrueAlphaChannel => bindings::ChannelType_TrueAlphaChannel,
|
||||
ChannelType::RGBChannels => bindings::ChannelType_RGBChannels,
|
||||
ChannelType::GrayChannels => bindings::ChannelType_GrayChannels,
|
||||
ChannelType::SyncChannels => bindings::ChannelType_SyncChannels,
|
||||
ChannelType::DefaultChannels => bindings::ChannelType_DefaultChannels,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::ChannelType> for ChannelType {
|
||||
fn from(value: bindings::ChannelType) -> Self {
|
||||
// Unreachable match arms commented out
|
||||
match value {
|
||||
bindings::ChannelType_UndefinedChannel => ChannelType::Undefined,
|
||||
bindings::ChannelType_RedChannel => ChannelType::RedChannel,
|
||||
// bindings::ChannelType_GrayChannel => { ChannelType::GrayChannel },
|
||||
// bindings::ChannelType_CyanChannel => { ChannelType::CyanChannel },
|
||||
// bindings::ChannelType_LChannel => { ChannelType::LChannel },
|
||||
bindings::ChannelType_GreenChannel => ChannelType::GreenChannel,
|
||||
// bindings::ChannelType_MagentaChannel => { ChannelType::MagentaChannel },
|
||||
// bindings::ChannelType_aChannel => { ChannelType::aChannel },
|
||||
bindings::ChannelType_BlueChannel => ChannelType::BlueChannel,
|
||||
// bindings::ChannelType_bChannel => { ChannelType::bChannel },
|
||||
// bindings::ChannelType_YellowChannel => { ChannelType::YellowChannel },
|
||||
bindings::ChannelType_BlackChannel => ChannelType::BlackChannel,
|
||||
bindings::ChannelType_AlphaChannel => ChannelType::AlphaChannel,
|
||||
// bindings::ChannelType_OpacityChannel => { ChannelType::OpacityChannel },
|
||||
bindings::ChannelType_IndexChannel => ChannelType::IndexChannel,
|
||||
bindings::ChannelType_ReadMaskChannel => ChannelType::ReadMaskChannel,
|
||||
bindings::ChannelType_WriteMaskChannel => ChannelType::WriteMaskChannel,
|
||||
bindings::ChannelType_MetaChannel => ChannelType::MetaChannel,
|
||||
bindings::ChannelType_CompositeMaskChannel => ChannelType::CompositeMaskChannel,
|
||||
bindings::ChannelType_CompositeChannels => ChannelType::CompositeChannels,
|
||||
bindings::ChannelType_AllChannels => ChannelType::AllChannels,
|
||||
// bindings::ChannelType_TrueAlphaChannel => { ChannelType::TrueAlphaChannel },
|
||||
// bindings::ChannelType_RGBChannels => { ChannelType::RGBChannels },
|
||||
bindings::ChannelType_GrayChannels => ChannelType::GrayChannels,
|
||||
bindings::ChannelType_SyncChannels => ChannelType::SyncChannels,
|
||||
// bindings::ChannelType_DefaultChannels => { ChannelType::DefaultChannels },
|
||||
_ => ChannelType::Undefined,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum ClipPathUnits {
|
||||
Undefined = bindings::ClipPathUnits_UndefinedPathUnits,
|
||||
UserSpace = bindings::ClipPathUnits_UserSpace,
|
||||
UserSpaceOnUse = bindings::ClipPathUnits_UserSpaceOnUse,
|
||||
ObjectBoundingBox = bindings::ClipPathUnits_ObjectBoundingBox,
|
||||
}
|
||||
|
||||
impl Default for ClipPathUnits {
|
||||
fn default() -> Self {
|
||||
return ClipPathUnits::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ClipPathUnits> for bindings::ClipPathUnits {
|
||||
fn from(value: ClipPathUnits) -> Self {
|
||||
return value as bindings::ClipPathUnits;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::ClipPathUnits> for ClipPathUnits {
|
||||
fn from(value: bindings::ClipPathUnits) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `ClipPathUnits` has the same repr as `bindings::ClipPathUnits` - u32
|
||||
*
|
||||
* If `value` is less than ObjectBoundingBox than it is in the vaild range and can be safely
|
||||
* reinterpreted as `ClipPathUnits`
|
||||
*/
|
||||
if value <= bindings::ClipPathUnits_ObjectBoundingBox {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return ClipPathUnits::default();
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum ColorspaceType {
|
||||
Undefined = bindings::ColorspaceType_UndefinedColorspace,
|
||||
CMY = bindings::ColorspaceType_CMYColorspace,
|
||||
CMYK = bindings::ColorspaceType_CMYKColorspace,
|
||||
GRAY = bindings::ColorspaceType_GRAYColorspace,
|
||||
HCL = bindings::ColorspaceType_HCLColorspace,
|
||||
HCLp = bindings::ColorspaceType_HCLpColorspace,
|
||||
HSB = bindings::ColorspaceType_HSBColorspace,
|
||||
HSI = bindings::ColorspaceType_HSIColorspace,
|
||||
HSL = bindings::ColorspaceType_HSLColorspace,
|
||||
HSV = bindings::ColorspaceType_HSVColorspace,
|
||||
HWB = bindings::ColorspaceType_HWBColorspace,
|
||||
Lab = bindings::ColorspaceType_LabColorspace,
|
||||
LCH = bindings::ColorspaceType_LCHColorspace,
|
||||
LCHab = bindings::ColorspaceType_LCHabColorspace,
|
||||
LCHuv = bindings::ColorspaceType_LCHuvColorspace,
|
||||
Log = bindings::ColorspaceType_LogColorspace,
|
||||
LMS = bindings::ColorspaceType_LMSColorspace,
|
||||
Luv = bindings::ColorspaceType_LuvColorspace,
|
||||
OHTA = bindings::ColorspaceType_OHTAColorspace,
|
||||
Rec601YCbCr = bindings::ColorspaceType_Rec601YCbCrColorspace,
|
||||
Rec709YCbCr = bindings::ColorspaceType_Rec709YCbCrColorspace,
|
||||
RGB = bindings::ColorspaceType_RGBColorspace,
|
||||
scRGB = bindings::ColorspaceType_scRGBColorspace,
|
||||
sRGB = bindings::ColorspaceType_sRGBColorspace,
|
||||
Transparent = bindings::ColorspaceType_TransparentColorspace,
|
||||
xyY = bindings::ColorspaceType_xyYColorspace,
|
||||
XYZ = bindings::ColorspaceType_XYZColorspace,
|
||||
YCbCr = bindings::ColorspaceType_YCbCrColorspace,
|
||||
YCC = bindings::ColorspaceType_YCCColorspace,
|
||||
YDbDr = bindings::ColorspaceType_YDbDrColorspace,
|
||||
YIQ = bindings::ColorspaceType_YIQColorspace,
|
||||
YPbPr = bindings::ColorspaceType_YPbPrColorspace,
|
||||
YUV = bindings::ColorspaceType_YUVColorspace,
|
||||
LinearGRAY = bindings::ColorspaceType_LinearGRAYColorspace,
|
||||
Jzazbz = bindings::ColorspaceType_JzazbzColorspace,
|
||||
DisplayP3 = bindings::ColorspaceType_DisplayP3Colorspace,
|
||||
Adobe98 = bindings::ColorspaceType_Adobe98Colorspace,
|
||||
ProPhoto = bindings::ColorspaceType_ProPhotoColorspace,
|
||||
Oklab = bindings::ColorspaceType_OklabColorspace,
|
||||
Oklch = bindings::ColorspaceType_OklchColorspace,
|
||||
}
|
||||
|
||||
impl Default for ColorspaceType {
|
||||
fn default() -> Self {
|
||||
return ColorspaceType::RGB;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ColorspaceType> for bindings::ColorspaceType {
|
||||
fn from(value: ColorspaceType) -> Self {
|
||||
return value as bindings::ColorspaceType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::ColorspaceType> for ColorspaceType {
|
||||
fn from(value: bindings::ColorspaceType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `ColorspaceType` has the same repr as `bindings::ColorspaceType` - u32
|
||||
*
|
||||
* If `value` is less than Oklch than it is in the vaild range and can be safely
|
||||
* reinterpreted as `ColorspaceType`
|
||||
*/
|
||||
if value <= bindings::ColorspaceType_OklchColorspace {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return ColorspaceType::default();
|
||||
}
|
||||
}
|
||||
@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum CompositeOperator {
|
||||
Undefined = bindings::CompositeOperator_UndefinedCompositeOp,
|
||||
Alpha = bindings::CompositeOperator_AlphaCompositeOp,
|
||||
Atop = bindings::CompositeOperator_AtopCompositeOp,
|
||||
Blend = bindings::CompositeOperator_BlendCompositeOp,
|
||||
Blur = bindings::CompositeOperator_BlurCompositeOp,
|
||||
Bumpmap = bindings::CompositeOperator_BumpmapCompositeOp,
|
||||
ChangeMask = bindings::CompositeOperator_ChangeMaskCompositeOp,
|
||||
Clear = bindings::CompositeOperator_ClearCompositeOp,
|
||||
ColorBurn = bindings::CompositeOperator_ColorBurnCompositeOp,
|
||||
ColorDodge = bindings::CompositeOperator_ColorDodgeCompositeOp,
|
||||
Colorize = bindings::CompositeOperator_ColorizeCompositeOp,
|
||||
CopyBlack = bindings::CompositeOperator_CopyBlackCompositeOp,
|
||||
CopyBlue = bindings::CompositeOperator_CopyBlueCompositeOp,
|
||||
Copy = bindings::CompositeOperator_CopyCompositeOp,
|
||||
CopyCyan = bindings::CompositeOperator_CopyCyanCompositeOp,
|
||||
CopyGreen = bindings::CompositeOperator_CopyGreenCompositeOp,
|
||||
CopyMagenta = bindings::CompositeOperator_CopyMagentaCompositeOp,
|
||||
CopyAlpha = bindings::CompositeOperator_CopyAlphaCompositeOp,
|
||||
CopyRed = bindings::CompositeOperator_CopyRedCompositeOp,
|
||||
CopyYellow = bindings::CompositeOperator_CopyYellowCompositeOp,
|
||||
Darken = bindings::CompositeOperator_DarkenCompositeOp,
|
||||
DarkenIntensity = bindings::CompositeOperator_DarkenIntensityCompositeOp,
|
||||
Difference = bindings::CompositeOperator_DifferenceCompositeOp,
|
||||
Displace = bindings::CompositeOperator_DisplaceCompositeOp,
|
||||
Dissolve = bindings::CompositeOperator_DissolveCompositeOp,
|
||||
Distort = bindings::CompositeOperator_DistortCompositeOp,
|
||||
DivideDst = bindings::CompositeOperator_DivideDstCompositeOp,
|
||||
DivideSrc = bindings::CompositeOperator_DivideSrcCompositeOp,
|
||||
DstAtop = bindings::CompositeOperator_DstAtopCompositeOp,
|
||||
Dst = bindings::CompositeOperator_DstCompositeOp,
|
||||
DstIn = bindings::CompositeOperator_DstInCompositeOp,
|
||||
DstOut = bindings::CompositeOperator_DstOutCompositeOp,
|
||||
DstOver = bindings::CompositeOperator_DstOverCompositeOp,
|
||||
Exclusion = bindings::CompositeOperator_ExclusionCompositeOp,
|
||||
HardLight = bindings::CompositeOperator_HardLightCompositeOp,
|
||||
HardMix = bindings::CompositeOperator_HardMixCompositeOp,
|
||||
Hue = bindings::CompositeOperator_HueCompositeOp,
|
||||
In = bindings::CompositeOperator_InCompositeOp,
|
||||
Intensity = bindings::CompositeOperator_IntensityCompositeOp,
|
||||
Lighten = bindings::CompositeOperator_LightenCompositeOp,
|
||||
LightenIntensity = bindings::CompositeOperator_LightenIntensityCompositeOp,
|
||||
LinearBurn = bindings::CompositeOperator_LinearBurnCompositeOp,
|
||||
LinearDodge = bindings::CompositeOperator_LinearDodgeCompositeOp,
|
||||
LinearLight = bindings::CompositeOperator_LinearLightCompositeOp,
|
||||
Luminize = bindings::CompositeOperator_LuminizeCompositeOp,
|
||||
Mathematics = bindings::CompositeOperator_MathematicsCompositeOp,
|
||||
MinusDst = bindings::CompositeOperator_MinusDstCompositeOp,
|
||||
MinusSrc = bindings::CompositeOperator_MinusSrcCompositeOp,
|
||||
Modulate = bindings::CompositeOperator_ModulateCompositeOp,
|
||||
ModulusAdd = bindings::CompositeOperator_ModulusAddCompositeOp,
|
||||
ModulusSubtract = bindings::CompositeOperator_ModulusSubtractCompositeOp,
|
||||
Multiply = bindings::CompositeOperator_MultiplyCompositeOp,
|
||||
No = bindings::CompositeOperator_NoCompositeOp,
|
||||
Out = bindings::CompositeOperator_OutCompositeOp,
|
||||
Over = bindings::CompositeOperator_OverCompositeOp,
|
||||
Overlay = bindings::CompositeOperator_OverlayCompositeOp,
|
||||
PegtopLight = bindings::CompositeOperator_PegtopLightCompositeOp,
|
||||
PinLight = bindings::CompositeOperator_PinLightCompositeOp,
|
||||
Plus = bindings::CompositeOperator_PlusCompositeOp,
|
||||
Replace = bindings::CompositeOperator_ReplaceCompositeOp,
|
||||
Saturate = bindings::CompositeOperator_SaturateCompositeOp,
|
||||
Screen = bindings::CompositeOperator_ScreenCompositeOp,
|
||||
SoftLight = bindings::CompositeOperator_SoftLightCompositeOp,
|
||||
SrcAtop = bindings::CompositeOperator_SrcAtopCompositeOp,
|
||||
Src = bindings::CompositeOperator_SrcCompositeOp,
|
||||
SrcIn = bindings::CompositeOperator_SrcInCompositeOp,
|
||||
SrcOut = bindings::CompositeOperator_SrcOutCompositeOp,
|
||||
SrcOver = bindings::CompositeOperator_SrcOverCompositeOp,
|
||||
Threshold = bindings::CompositeOperator_ThresholdCompositeOp,
|
||||
VividLight = bindings::CompositeOperator_VividLightCompositeOp,
|
||||
Xor = bindings::CompositeOperator_XorCompositeOp,
|
||||
Stereo = bindings::CompositeOperator_StereoCompositeOp,
|
||||
Freeze = bindings::CompositeOperator_FreezeCompositeOp,
|
||||
Interpolate = bindings::CompositeOperator_InterpolateCompositeOp,
|
||||
Negate = bindings::CompositeOperator_NegateCompositeOp,
|
||||
Reflect = bindings::CompositeOperator_ReflectCompositeOp,
|
||||
SoftBurn = bindings::CompositeOperator_SoftBurnCompositeOp,
|
||||
SoftDodge = bindings::CompositeOperator_SoftDodgeCompositeOp,
|
||||
Stamp = bindings::CompositeOperator_StampCompositeOp,
|
||||
RMSE = bindings::CompositeOperator_RMSECompositeOp,
|
||||
SaliencyBlend = bindings::CompositeOperator_SaliencyBlendCompositeOp,
|
||||
SeamlessBlend = bindings::CompositeOperator_SeamlessBlendCompositeOp,
|
||||
}
|
||||
|
||||
impl Default for CompositeOperator {
|
||||
fn default() -> Self {
|
||||
return CompositeOperator::Over;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CompositeOperator> for bindings::CompositeOperator {
|
||||
fn from(value: CompositeOperator) -> Self {
|
||||
return value as bindings::CompositeOperator;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::CompositeOperator> for CompositeOperator {
|
||||
fn from(value: bindings::CompositeOperator) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `CompositeOperator` has the same repr as `bindings::CompositeOperator` - u32
|
||||
*
|
||||
* If `value` is less than SeamlessBlend than it is in the vaild range and can be safely
|
||||
* reinterpreted as `CompositeOperator`
|
||||
*/
|
||||
if value <= bindings::CompositeOperator_SeamlessBlendCompositeOp {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return CompositeOperator::default();
|
||||
}
|
||||
}
|
||||
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum CompressionType {
|
||||
Undefined = bindings::CompressionType_UndefinedCompression,
|
||||
B44A = bindings::CompressionType_B44ACompression,
|
||||
B44 = bindings::CompressionType_B44Compression,
|
||||
BZip = bindings::CompressionType_BZipCompression,
|
||||
DXT1 = bindings::CompressionType_DXT1Compression,
|
||||
DXT3 = bindings::CompressionType_DXT3Compression,
|
||||
DXT5 = bindings::CompressionType_DXT5Compression,
|
||||
Fax = bindings::CompressionType_FaxCompression,
|
||||
Group4 = bindings::CompressionType_Group4Compression,
|
||||
JBIG1 = bindings::CompressionType_JBIG1Compression,
|
||||
JBIG2 = bindings::CompressionType_JBIG2Compression,
|
||||
JPEG2000 = bindings::CompressionType_JPEG2000Compression,
|
||||
JPEG = bindings::CompressionType_JPEGCompression,
|
||||
LosslessJPEG = bindings::CompressionType_LosslessJPEGCompression,
|
||||
LZMA = bindings::CompressionType_LZMACompression,
|
||||
LZW = bindings::CompressionType_LZWCompression,
|
||||
No = bindings::CompressionType_NoCompression,
|
||||
Piz = bindings::CompressionType_PizCompression,
|
||||
Pxr24 = bindings::CompressionType_Pxr24Compression,
|
||||
RLE = bindings::CompressionType_RLECompression,
|
||||
Zip = bindings::CompressionType_ZipCompression,
|
||||
ZipS = bindings::CompressionType_ZipSCompression,
|
||||
Zstd = bindings::CompressionType_ZstdCompression,
|
||||
WebP = bindings::CompressionType_WebPCompression,
|
||||
DWAA = bindings::CompressionType_DWAACompression,
|
||||
DWAB = bindings::CompressionType_DWABCompression,
|
||||
BC7 = bindings::CompressionType_BC7Compression,
|
||||
BC5 = bindings::CompressionType_BC5Compression,
|
||||
LERC = bindings::CompressionType_LERCCompression,
|
||||
}
|
||||
|
||||
impl Default for CompressionType {
|
||||
fn default() -> Self {
|
||||
return CompressionType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CompressionType> for bindings::CompressionType {
|
||||
fn from(value: CompressionType) -> Self {
|
||||
return value as bindings::CompressionType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::CompressionType> for CompressionType {
|
||||
fn from(value: bindings::CompressionType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `CompressionType` has the same repr as `bindings::CompressionType` - u32
|
||||
*
|
||||
* If `value` is less than LERC than it is in the vaild range and can be safely
|
||||
* reinterpreted as `CompressionType`
|
||||
*/
|
||||
if value <= bindings::CompressionType_LERCCompression {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return CompressionType::default();
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum DecorationType {
|
||||
Undefined = bindings::DecorationType_UndefinedDecoration,
|
||||
No = bindings::DecorationType_NoDecoration,
|
||||
Underline = bindings::DecorationType_UnderlineDecoration,
|
||||
Overline = bindings::DecorationType_OverlineDecoration,
|
||||
LineThrough = bindings::DecorationType_LineThroughDecoration,
|
||||
}
|
||||
|
||||
impl Default for DecorationType {
|
||||
fn default() -> Self {
|
||||
return DecorationType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DecorationType> for bindings::DecorationType {
|
||||
fn from(value: DecorationType) -> Self {
|
||||
return value as bindings::DecorationType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::DecorationType> for DecorationType {
|
||||
fn from(value: bindings::DecorationType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `DecorationType` has the same repr as `bindings::DecorationType` - u32
|
||||
*
|
||||
* If `value` is less than LineThrough than it is in the vaild range and can be safely
|
||||
* reinterpreted as `DecorationType`
|
||||
*/
|
||||
if value <= bindings::DecorationType_LineThroughDecoration {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return DecorationType::default();
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum DirectionType {
|
||||
Undefined = bindings::DirectionType_UndefinedDirection,
|
||||
RightToLeft = bindings::DirectionType_RightToLeftDirection,
|
||||
LeftToRight = bindings::DirectionType_LeftToRightDirection,
|
||||
TopToBottom = bindings::DirectionType_TopToBottomDirection,
|
||||
}
|
||||
|
||||
impl Default for DirectionType {
|
||||
fn default() -> Self {
|
||||
return DirectionType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DirectionType> for bindings::DirectionType {
|
||||
fn from(value: DirectionType) -> Self {
|
||||
return value as bindings::DirectionType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::DirectionType> for DirectionType {
|
||||
fn from(value: bindings::DirectionType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `DirectionType` has the same repr as `bindings::DirectionType` - u32
|
||||
*
|
||||
* If `value` is less than TopToBottom than it is in the vaild range and can be safely
|
||||
* reinterpreted as `DirectionType`
|
||||
*/
|
||||
if value <= bindings::DirectionType_TopToBottomDirection {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return DirectionType::default();
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum DisposeType {
|
||||
/*
|
||||
* Identical to `Undefined`
|
||||
*/
|
||||
// Unrecognized = bindings::DisposeType_UnrecognizedDispose,
|
||||
Undefined = bindings::DisposeType_UndefinedDispose,
|
||||
None = bindings::DisposeType_NoneDispose,
|
||||
Background = bindings::DisposeType_BackgroundDispose,
|
||||
Previous = bindings::DisposeType_PreviousDispose,
|
||||
}
|
||||
|
||||
impl Default for DisposeType {
|
||||
fn default() -> Self {
|
||||
return DisposeType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DisposeType> for bindings::DisposeType {
|
||||
fn from(value: DisposeType) -> Self {
|
||||
return value as bindings::DisposeType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::DisposeType> for DisposeType {
|
||||
fn from(value: bindings::DisposeType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `DisposeType` has the same repr as `bindings::DisposeType` - u32
|
||||
*
|
||||
* If `value` is less than Previous than it is in the vaild range and can be safely
|
||||
* reinterpreted as `DisposeType`
|
||||
*/
|
||||
if value <= bindings::DisposeType_PreviousDispose {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return DisposeType::default();
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum DitherMethod {
|
||||
Undefined = bindings::DitherMethod_UndefinedDitherMethod,
|
||||
No = bindings::DitherMethod_NoDitherMethod,
|
||||
Riemersma = bindings::DitherMethod_RiemersmaDitherMethod,
|
||||
FloydSteinberg = bindings::DitherMethod_FloydSteinbergDitherMethod,
|
||||
}
|
||||
|
||||
impl Default for DitherMethod {
|
||||
fn default() -> Self {
|
||||
return DitherMethod::No;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DitherMethod> for bindings::DitherMethod {
|
||||
fn from(value: DitherMethod) -> Self {
|
||||
return value as bindings::DitherMethod;
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum EndianType {
|
||||
Undefined = bindings::EndianType_UndefinedEndian,
|
||||
LSB = bindings::EndianType_LSBEndian,
|
||||
MSB = bindings::EndianType_MSBEndian,
|
||||
}
|
||||
|
||||
impl Default for EndianType {
|
||||
fn default() -> Self {
|
||||
return EndianType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EndianType> for bindings::EndianType {
|
||||
fn from(value: EndianType) -> Self {
|
||||
return value as bindings::EndianType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::EndianType> for EndianType {
|
||||
fn from(value: bindings::EndianType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `EndianType` has the same repr as `bindings::EndianType` - u32
|
||||
*
|
||||
* If `value` is less than MSB than it is in the vaild range and can be safely
|
||||
* reinterpreted as `EndianType`
|
||||
*/
|
||||
if value <= bindings::EndianType_MSBEndian {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return EndianType::default();
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum FillRule {
|
||||
Undefined = bindings::FillRule_UndefinedRule,
|
||||
EvenOdd = bindings::FillRule_EvenOddRule,
|
||||
NonZero = bindings::FillRule_NonZeroRule,
|
||||
}
|
||||
|
||||
impl Default for FillRule {
|
||||
fn default() -> Self {
|
||||
return FillRule::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FillRule> for bindings::FillRule {
|
||||
fn from(value: FillRule) -> Self {
|
||||
return value as bindings::FillRule;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::FillRule> for FillRule {
|
||||
fn from(value: bindings::FillRule) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `FillRule` has the same repr as `bindings::FillRule` - u32
|
||||
*
|
||||
* If `value` is less than NonZero than it is in the vaild range and can be safely
|
||||
* reinterpreted as `FillRule`
|
||||
*/
|
||||
if value <= bindings::FillRule_NonZeroRule {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return FillRule::default();
|
||||
}
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum FilterType {
|
||||
Undefined = bindings::FilterType_UndefinedFilter,
|
||||
Point = bindings::FilterType_PointFilter,
|
||||
Box = bindings::FilterType_BoxFilter,
|
||||
Triangle = bindings::FilterType_TriangleFilter,
|
||||
Hermite = bindings::FilterType_HermiteFilter,
|
||||
Hann = bindings::FilterType_HannFilter,
|
||||
Hamming = bindings::FilterType_HammingFilter,
|
||||
Blackman = bindings::FilterType_BlackmanFilter,
|
||||
Gaussian = bindings::FilterType_GaussianFilter,
|
||||
Quadratic = bindings::FilterType_QuadraticFilter,
|
||||
Cubic = bindings::FilterType_CubicFilter,
|
||||
Catrom = bindings::FilterType_CatromFilter,
|
||||
Mitchell = bindings::FilterType_MitchellFilter,
|
||||
Jinc = bindings::FilterType_JincFilter,
|
||||
Sinc = bindings::FilterType_SincFilter,
|
||||
SincFast = bindings::FilterType_SincFastFilter,
|
||||
Kaiser = bindings::FilterType_KaiserFilter,
|
||||
Welch = bindings::FilterType_WelchFilter,
|
||||
Parzen = bindings::FilterType_ParzenFilter,
|
||||
Bohman = bindings::FilterType_BohmanFilter,
|
||||
Bartlett = bindings::FilterType_BartlettFilter,
|
||||
Lagrange = bindings::FilterType_LagrangeFilter,
|
||||
Lanczos = bindings::FilterType_LanczosFilter,
|
||||
LanczosSharp = bindings::FilterType_LanczosSharpFilter,
|
||||
Lanczos2 = bindings::FilterType_Lanczos2Filter,
|
||||
Lanczos2Sharp = bindings::FilterType_Lanczos2SharpFilter,
|
||||
Robidoux = bindings::FilterType_RobidouxFilter,
|
||||
RobidouxSharp = bindings::FilterType_RobidouxSharpFilter,
|
||||
Cosine = bindings::FilterType_CosineFilter,
|
||||
Spline = bindings::FilterType_SplineFilter,
|
||||
LanczosRadius = bindings::FilterType_LanczosRadiusFilter,
|
||||
CubicSpline = bindings::FilterType_CubicSplineFilter,
|
||||
Sentinel = bindings::FilterType_SentinelFilter,
|
||||
}
|
||||
|
||||
impl From<FilterType> for bindings::FilterType {
|
||||
fn from(value: FilterType) -> Self {
|
||||
return value as bindings::FilterType;
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum GravityType {
|
||||
Undefined = bindings::GravityType_UndefinedGravity,
|
||||
/*
|
||||
* Identical to `Undefined`
|
||||
*/
|
||||
// Forget = bindings::GravityType_ForgetGravity,
|
||||
NorthWest = bindings::GravityType_NorthWestGravity,
|
||||
North = bindings::GravityType_NorthGravity,
|
||||
NorthEast = bindings::GravityType_NorthEastGravity,
|
||||
West = bindings::GravityType_WestGravity,
|
||||
Center = bindings::GravityType_CenterGravity,
|
||||
East = bindings::GravityType_EastGravity,
|
||||
SouthWest = bindings::GravityType_SouthWestGravity,
|
||||
South = bindings::GravityType_SouthGravity,
|
||||
SouthEast = bindings::GravityType_SouthEastGravity,
|
||||
}
|
||||
|
||||
impl Default for GravityType {
|
||||
fn default() -> Self {
|
||||
return GravityType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GravityType> for bindings::GravityType {
|
||||
fn from(value: GravityType) -> Self {
|
||||
return value as bindings::GravityType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::GravityType> for GravityType {
|
||||
fn from(value: bindings::GravityType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `GravityType` has the same repr as `bindings::GravityType` - u32
|
||||
*
|
||||
* If `value` is less than SouthEast than it is in the vaild range and can be safely
|
||||
* reinterpreted as `GravityType`
|
||||
*/
|
||||
if value <= bindings::GravityType_SouthEastGravity {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return GravityType::default();
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum ImageType {
|
||||
Undefined = bindings::ImageType_UndefinedType,
|
||||
Bilevel = bindings::ImageType_BilevelType,
|
||||
Grayscale = bindings::ImageType_GrayscaleType,
|
||||
GrayscaleAlpha = bindings::ImageType_GrayscaleAlphaType,
|
||||
Palette = bindings::ImageType_PaletteType,
|
||||
PaletteAlpha = bindings::ImageType_PaletteAlphaType,
|
||||
TrueColor = bindings::ImageType_TrueColorType,
|
||||
TrueColorAlpha = bindings::ImageType_TrueColorAlphaType,
|
||||
ColorSeparation = bindings::ImageType_ColorSeparationType,
|
||||
ColorSeparationAlpha = bindings::ImageType_ColorSeparationAlphaType,
|
||||
Optimize = bindings::ImageType_OptimizeType,
|
||||
PaletteBilevelAlpha = bindings::ImageType_PaletteBilevelAlphaType,
|
||||
}
|
||||
|
||||
impl Default for ImageType {
|
||||
fn default() -> Self {
|
||||
return ImageType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ImageType> for bindings::ImageType {
|
||||
fn from(value: ImageType) -> Self {
|
||||
return value as bindings::ImageType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::ImageType> for ImageType {
|
||||
fn from(value: bindings::ImageType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `ImageType` has the same repr as `bindings::ImageType` - u32
|
||||
*
|
||||
* If `value` is less than SouthEast than it is in the vaild range and can be safely
|
||||
* reinterpreted as `ImageType`
|
||||
*/
|
||||
if value <= bindings::ImageType_PaletteBilevelAlphaType {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return ImageType::default();
|
||||
}
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum InterlaceType {
|
||||
Undefined = bindings::InterlaceType_UndefinedInterlace,
|
||||
No = bindings::InterlaceType_NoInterlace,
|
||||
Line = bindings::InterlaceType_LineInterlace,
|
||||
Plane = bindings::InterlaceType_PlaneInterlace,
|
||||
Partition = bindings::InterlaceType_PartitionInterlace,
|
||||
GIF = bindings::InterlaceType_GIFInterlace,
|
||||
JPEG = bindings::InterlaceType_JPEGInterlace,
|
||||
PNG = bindings::InterlaceType_PNGInterlace,
|
||||
}
|
||||
|
||||
impl Default for InterlaceType {
|
||||
fn default() -> Self {
|
||||
return InterlaceType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<InterlaceType> for bindings::InterlaceType {
|
||||
fn from(value: InterlaceType) -> Self {
|
||||
return value as bindings::InterlaceType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::InterlaceType> for InterlaceType {
|
||||
fn from(value: bindings::InterlaceType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `InterlaceType` has the same repr as `bindings::InterlaceType` - u32
|
||||
*
|
||||
* If `value` is less than PNG than it is in the vaild range and can be safely
|
||||
* reinterpreted as `InterlaceType`
|
||||
*/
|
||||
if value <= bindings::InterlaceType_PNGInterlace {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return InterlaceType::default();
|
||||
}
|
||||
}
|
||||
@ -18,101 +18,6 @@ use std::ffi::CString;
|
||||
use crate::bindings;
|
||||
use crate::{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)
|
||||
///
|
||||
/// # Examples
|
||||
@ -171,7 +76,7 @@ pub struct KernelBuilder {
|
||||
center: Option<(usize, usize)>,
|
||||
values: Option<Vec<f64>>,
|
||||
|
||||
info_type: Option<KernelInfoType>,
|
||||
info_type: Option<crate::KernelInfoType>,
|
||||
geom_info: Option<crate::GeometryInfo>,
|
||||
}
|
||||
|
||||
@ -250,7 +155,7 @@ impl KernelBuilder {
|
||||
}
|
||||
|
||||
/// Used for builtin kernels
|
||||
pub fn set_info_type(mut self, info_type: KernelInfoType) -> KernelBuilder {
|
||||
pub fn set_info_type(mut self, info_type: crate::KernelInfoType) -> KernelBuilder {
|
||||
self.info_type = Some(info_type);
|
||||
return self;
|
||||
}
|
||||
@ -295,7 +200,7 @@ impl KernelInfo {
|
||||
|
||||
/// The values within the kernel is scaled directly using given scaling factor without change.
|
||||
pub fn scale(&mut self, factor: f64) {
|
||||
unsafe { bindings::ScaleKernelInfo(self.kernel_info, factor, 0) }
|
||||
unsafe { bindings::ScaleKernelInfo(self.kernel_info, factor, bindings::GeometryFlags::NoValue) }
|
||||
}
|
||||
|
||||
/// Kernel normalization is designed to ensure that any use of the kernel scaling factor with
|
||||
@ -319,7 +224,7 @@ impl KernelInfo {
|
||||
bindings::ScaleKernelInfo(
|
||||
self.kernel_info,
|
||||
1.0,
|
||||
bindings::GeometryFlags_NormalizeValue,
|
||||
bindings::GeometryFlags::NormalizeValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -333,7 +238,7 @@ impl KernelInfo {
|
||||
bindings::ScaleKernelInfo(
|
||||
self.kernel_info,
|
||||
1.0,
|
||||
bindings::GeometryFlags_CorrelateNormalizeValue,
|
||||
bindings::GeometryFlags::CorrelateNormalizeValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum LayerMethod {
|
||||
Undefined = bindings::LayerMethod_UndefinedLayer,
|
||||
Coalesce = bindings::LayerMethod_CoalesceLayer,
|
||||
CompareAny = bindings::LayerMethod_CompareAnyLayer,
|
||||
CompareClear = bindings::LayerMethod_CompareClearLayer,
|
||||
CompareOverlay = bindings::LayerMethod_CompareOverlayLayer,
|
||||
Dispose = bindings::LayerMethod_DisposeLayer,
|
||||
Optimize = bindings::LayerMethod_OptimizeLayer,
|
||||
OptimizeImage = bindings::LayerMethod_OptimizeImageLayer,
|
||||
OptimizePlus = bindings::LayerMethod_OptimizePlusLayer,
|
||||
OptimizeTrans = bindings::LayerMethod_OptimizeTransLayer,
|
||||
RemoveDups = bindings::LayerMethod_RemoveDupsLayer,
|
||||
RemoveZero = bindings::LayerMethod_RemoveZeroLayer,
|
||||
Composite = bindings::LayerMethod_CompositeLayer,
|
||||
Merge = bindings::LayerMethod_MergeLayer,
|
||||
Flatten = bindings::LayerMethod_FlattenLayer,
|
||||
Mosaic = bindings::LayerMethod_MosaicLayer,
|
||||
TrimBounds = bindings::LayerMethod_TrimBoundsLayer,
|
||||
}
|
||||
|
||||
impl Default for LayerMethod {
|
||||
fn default() -> Self {
|
||||
return LayerMethod::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LayerMethod> for bindings::LayerMethod {
|
||||
fn from(value: LayerMethod) -> Self {
|
||||
return value as bindings::LayerMethod;
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum LineCap {
|
||||
Undefined = bindings::LineCap_UndefinedCap,
|
||||
Butt = bindings::LineCap_ButtCap,
|
||||
Round = bindings::LineCap_RoundCap,
|
||||
Square = bindings::LineCap_SquareCap,
|
||||
}
|
||||
|
||||
impl Default for LineCap {
|
||||
fn default() -> Self {
|
||||
return LineCap::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LineCap> for bindings::LineCap {
|
||||
fn from(value: LineCap) -> Self {
|
||||
return value as bindings::LineCap;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::LineCap> for LineCap {
|
||||
fn from(value: bindings::LineCap) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `LineCap` has the same repr as `bindings::LineCap` - u32
|
||||
*
|
||||
* If `value` is less than Square than it is in the vaild range and can be safely
|
||||
* reinterpreted as `LineCap`
|
||||
*/
|
||||
if value <= bindings::LineCap_SquareCap {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return LineCap::default();
|
||||
}
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum LineJoin {
|
||||
Undefined = bindings::LineJoin_UndefinedJoin,
|
||||
Miter = bindings::LineJoin_MiterJoin,
|
||||
Round = bindings::LineJoin_RoundJoin,
|
||||
Bevel = bindings::LineJoin_BevelJoin,
|
||||
}
|
||||
|
||||
impl Default for LineJoin {
|
||||
fn default() -> Self {
|
||||
return LineJoin::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LineJoin> for bindings::LineJoin {
|
||||
fn from(value: LineJoin) -> Self {
|
||||
return value as bindings::LineJoin;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::LineJoin> for LineJoin {
|
||||
fn from(value: bindings::LineJoin) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `LineJoin` has the same repr as `bindings::LineJoin` - u32
|
||||
*
|
||||
* If `value` is less than Bevel than it is in the vaild range and can be safely
|
||||
* reinterpreted as `LineJoin`
|
||||
*/
|
||||
if value <= bindings::LineJoin_BevelJoin {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return LineJoin::default();
|
||||
}
|
||||
}
|
||||
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum MagickEvaluateOperator {
|
||||
Undefined = bindings::MagickEvaluateOperator_UndefinedEvaluateOperator,
|
||||
Abs = bindings::MagickEvaluateOperator_AbsEvaluateOperator,
|
||||
Add = bindings::MagickEvaluateOperator_AddEvaluateOperator,
|
||||
AddModulus = bindings::MagickEvaluateOperator_AddModulusEvaluateOperator,
|
||||
And = bindings::MagickEvaluateOperator_AndEvaluateOperator,
|
||||
Cosine = bindings::MagickEvaluateOperator_CosineEvaluateOperator,
|
||||
Divide = bindings::MagickEvaluateOperator_DivideEvaluateOperator,
|
||||
Exponential = bindings::MagickEvaluateOperator_ExponentialEvaluateOperator,
|
||||
GaussianNoise = bindings::MagickEvaluateOperator_GaussianNoiseEvaluateOperator,
|
||||
ImpulseNoise = bindings::MagickEvaluateOperator_ImpulseNoiseEvaluateOperator,
|
||||
LaplacianNoise = bindings::MagickEvaluateOperator_LaplacianNoiseEvaluateOperator,
|
||||
LeftShift = bindings::MagickEvaluateOperator_LeftShiftEvaluateOperator,
|
||||
Log = bindings::MagickEvaluateOperator_LogEvaluateOperator,
|
||||
Max = bindings::MagickEvaluateOperator_MaxEvaluateOperator,
|
||||
Mean = bindings::MagickEvaluateOperator_MeanEvaluateOperator,
|
||||
Median = bindings::MagickEvaluateOperator_MedianEvaluateOperator,
|
||||
Min = bindings::MagickEvaluateOperator_MinEvaluateOperator,
|
||||
MultiplicativeNoise = bindings::MagickEvaluateOperator_MultiplicativeNoiseEvaluateOperator,
|
||||
Multiply = bindings::MagickEvaluateOperator_MultiplyEvaluateOperator,
|
||||
Or = bindings::MagickEvaluateOperator_OrEvaluateOperator,
|
||||
PoissonNoise = bindings::MagickEvaluateOperator_PoissonNoiseEvaluateOperator,
|
||||
Pow = bindings::MagickEvaluateOperator_PowEvaluateOperator,
|
||||
RightShift = bindings::MagickEvaluateOperator_RightShiftEvaluateOperator,
|
||||
RootMeanSquare = bindings::MagickEvaluateOperator_RootMeanSquareEvaluateOperator,
|
||||
Set = bindings::MagickEvaluateOperator_SetEvaluateOperator,
|
||||
Sine = bindings::MagickEvaluateOperator_SineEvaluateOperator,
|
||||
Subtract = bindings::MagickEvaluateOperator_SubtractEvaluateOperator,
|
||||
Sum = bindings::MagickEvaluateOperator_SumEvaluateOperator,
|
||||
ThresholdBlack = bindings::MagickEvaluateOperator_ThresholdBlackEvaluateOperator,
|
||||
Threshold = bindings::MagickEvaluateOperator_ThresholdEvaluateOperator,
|
||||
ThresholdWhite = bindings::MagickEvaluateOperator_ThresholdWhiteEvaluateOperator,
|
||||
UniformNoise = bindings::MagickEvaluateOperator_UniformNoiseEvaluateOperator,
|
||||
Xor = bindings::MagickEvaluateOperator_XorEvaluateOperator,
|
||||
InverseLog = bindings::MagickEvaluateOperator_InverseLogEvaluateOperator,
|
||||
}
|
||||
|
||||
impl Default for MagickEvaluateOperator {
|
||||
fn default() -> Self {
|
||||
return MagickEvaluateOperator::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MagickEvaluateOperator> for bindings::MagickEvaluateOperator {
|
||||
fn from(value: MagickEvaluateOperator) -> Self {
|
||||
return value as bindings::MagickEvaluateOperator;
|
||||
}
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum MagickFunction {
|
||||
Undefined = bindings::MagickFunction_UndefinedFunction,
|
||||
Arcsin = bindings::MagickFunction_ArcsinFunction,
|
||||
Arctan = bindings::MagickFunction_ArctanFunction,
|
||||
Polynomial = bindings::MagickFunction_PolynomialFunction,
|
||||
Sinusoid = bindings::MagickFunction_SinusoidFunction,
|
||||
}
|
||||
|
||||
impl Default for MagickFunction {
|
||||
fn default() -> Self {
|
||||
return MagickFunction::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MagickFunction> for bindings::MagickFunction {
|
||||
fn from(value: MagickFunction) -> Self {
|
||||
return value as bindings::MagickFunction;
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
pub enum MetricType {
|
||||
Undefined = bindings::MetricType_UndefinedErrorMetric as isize,
|
||||
Absolute = bindings::MetricType_AbsoluteErrorMetric as isize,
|
||||
Fuzz = bindings::MetricType_FuzzErrorMetric as isize,
|
||||
MeanAbsolute = bindings::MetricType_MeanAbsoluteErrorMetric as isize,
|
||||
MeanErrorPerPixel = bindings::MetricType_MeanErrorPerPixelErrorMetric as isize,
|
||||
MeanSquared = bindings::MetricType_MeanSquaredErrorMetric as isize,
|
||||
NormalizedCrossCorrelation =
|
||||
bindings::MetricType_NormalizedCrossCorrelationErrorMetric as isize,
|
||||
PeakAbsolute = bindings::MetricType_PeakAbsoluteErrorMetric as isize,
|
||||
PeakSignalToNoiseRatio = bindings::MetricType_PeakSignalToNoiseRatioErrorMetric as isize,
|
||||
PerceptualHash = bindings::MetricType_PerceptualHashErrorMetric as isize,
|
||||
RootMeanSquared = bindings::MetricType_RootMeanSquaredErrorMetric as isize,
|
||||
StructuralSimilarity = bindings::MetricType_StructuralSimilarityErrorMetric as isize,
|
||||
StructuralDissimilarity = bindings::MetricType_StructuralDissimilarityErrorMetric as isize,
|
||||
}
|
||||
|
||||
impl Default for MetricType {
|
||||
fn default() -> Self {
|
||||
return MetricType::Absolute;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MetricType> for bindings::MetricType {
|
||||
fn from(value: MetricType) -> Self {
|
||||
return value as bindings::MetricType;
|
||||
}
|
||||
}
|
||||
110
src/types/mod.rs
110
src/types/mod.rs
@ -13,76 +13,46 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
mod align_type;
|
||||
mod alpha_channel_option;
|
||||
mod auto_threshold_method;
|
||||
mod channel_type;
|
||||
mod clip_path_units;
|
||||
mod colorspace_type;
|
||||
mod composite_operator;
|
||||
mod compression_type;
|
||||
mod decoration_type;
|
||||
mod direction_type;
|
||||
mod dispose_type;
|
||||
mod dither_method;
|
||||
mod endian_type;
|
||||
mod fill_rule;
|
||||
mod filter_type;
|
||||
mod geometry_info;
|
||||
mod gravity_type;
|
||||
mod image;
|
||||
mod image_type;
|
||||
mod interlace_type;
|
||||
mod kernel;
|
||||
mod layer_method;
|
||||
mod line_cap;
|
||||
mod line_join;
|
||||
mod magick_evaluate_operator;
|
||||
mod magick_function;
|
||||
mod metric_type;
|
||||
mod orientation_type;
|
||||
mod pixel_interpolate_method;
|
||||
mod pixel_mask;
|
||||
mod rendering_intent;
|
||||
mod resolution_type;
|
||||
mod resource_type;
|
||||
mod statistic_type;
|
||||
mod stretch_type;
|
||||
mod style_type;
|
||||
|
||||
pub use self::align_type::AlignType;
|
||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||
pub use self::auto_threshold_method::AutoThresholdMethod;
|
||||
pub use self::channel_type::ChannelType;
|
||||
pub use self::clip_path_units::ClipPathUnits;
|
||||
pub use self::colorspace_type::ColorspaceType;
|
||||
pub use self::composite_operator::CompositeOperator;
|
||||
pub use self::compression_type::CompressionType;
|
||||
pub use self::decoration_type::DecorationType;
|
||||
pub use self::direction_type::DirectionType;
|
||||
pub use self::dispose_type::DisposeType;
|
||||
pub use self::dither_method::DitherMethod;
|
||||
pub use self::endian_type::EndianType;
|
||||
pub use self::fill_rule::FillRule;
|
||||
pub use self::filter_type::FilterType;
|
||||
mod geometry_info;
|
||||
mod image;
|
||||
mod kernel;
|
||||
|
||||
pub use bindings::AlignType;
|
||||
pub use bindings::AlphaChannelOption;
|
||||
pub use bindings::AutoThresholdMethod;
|
||||
pub use bindings::ChannelType;
|
||||
pub use bindings::ClipPathUnits;
|
||||
pub use bindings::CompositeOperator;
|
||||
pub use bindings::ColorspaceType;
|
||||
pub use bindings::CompressionType;
|
||||
pub use bindings::DecorationType;
|
||||
pub use bindings::DirectionType;
|
||||
pub use bindings::DisposeType;
|
||||
pub use bindings::DitherMethod;
|
||||
pub use bindings::EndianType;
|
||||
pub use bindings::FillRule;
|
||||
pub use bindings::FilterType;
|
||||
pub use self::geometry_info::GeometryInfo;
|
||||
pub use self::gravity_type::GravityType;
|
||||
pub use bindings::GravityType;
|
||||
pub use self::image::Image;
|
||||
pub use self::image_type::ImageType;
|
||||
pub use self::interlace_type::InterlaceType;
|
||||
pub use self::kernel::*;
|
||||
pub use self::layer_method::LayerMethod;
|
||||
pub use self::line_cap::LineCap;
|
||||
pub use self::line_join::LineJoin;
|
||||
pub use self::magick_evaluate_operator::MagickEvaluateOperator;
|
||||
pub use self::magick_function::MagickFunction;
|
||||
pub use self::metric_type::MetricType;
|
||||
pub use self::orientation_type::OrientationType;
|
||||
pub use self::pixel_interpolate_method::PixelInterpolateMethod;
|
||||
pub use self::pixel_mask::PixelMask;
|
||||
pub use self::rendering_intent::RenderingIntent;
|
||||
pub use self::resolution_type::ResolutionType;
|
||||
pub use self::resource_type::ResourceType;
|
||||
pub use self::statistic_type::StatisticType;
|
||||
pub use self::stretch_type::StretchType;
|
||||
pub use self::style_type::StyleType;
|
||||
pub use bindings::ImageType;
|
||||
pub use bindings::InterlaceType;
|
||||
pub use bindings::KernelInfoType;
|
||||
pub use self::kernel::{KernelBuilder, KernelInfo};
|
||||
pub use bindings::LayerMethod;
|
||||
pub use bindings::LineCap;
|
||||
pub use bindings::LineJoin;
|
||||
pub use bindings::MagickEvaluateOperator;
|
||||
pub use bindings::MagickFunction;
|
||||
pub use bindings::MetricType;
|
||||
pub use bindings::MorphologyMethod;
|
||||
pub use bindings::OrientationType;
|
||||
pub use bindings::PixelInterpolateMethod;
|
||||
pub use bindings::PixelMask;
|
||||
pub use bindings::RenderingIntent;
|
||||
pub use bindings::ResolutionType;
|
||||
pub use bindings::ResourceType;
|
||||
pub use bindings::StatisticType;
|
||||
pub use bindings::StretchType;
|
||||
pub use bindings::StyleType;
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum OrientationType {
|
||||
Undefined = bindings::OrientationType_UndefinedOrientation,
|
||||
TopLeft = bindings::OrientationType_TopLeftOrientation,
|
||||
TopRight = bindings::OrientationType_TopRightOrientation,
|
||||
BottomRight = bindings::OrientationType_BottomRightOrientation,
|
||||
BottomLeft = bindings::OrientationType_BottomLeftOrientation,
|
||||
LeftTop = bindings::OrientationType_LeftTopOrientation,
|
||||
RightTop = bindings::OrientationType_RightTopOrientation,
|
||||
RightBottom = bindings::OrientationType_RightBottomOrientation,
|
||||
LeftBottom = bindings::OrientationType_LeftBottomOrientation,
|
||||
}
|
||||
|
||||
impl Default for OrientationType {
|
||||
fn default() -> Self {
|
||||
return OrientationType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OrientationType> for bindings::OrientationType {
|
||||
fn from(value: OrientationType) -> Self {
|
||||
return value as bindings::OrientationType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::OrientationType> for OrientationType {
|
||||
fn from(value: bindings::OrientationType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `OrientationType` has the same repr as `bindings::OrientationType` - u32
|
||||
*
|
||||
* If `value` is less than LeftBottom than it is in the vaild range and can be safely
|
||||
* reinterpreted as `OrientationType`
|
||||
*/
|
||||
if value <= bindings::OrientationType_LeftBottomOrientation {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return OrientationType::default();
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum PixelInterpolateMethod {
|
||||
Undefined = bindings::PixelInterpolateMethod_UndefinedInterpolatePixel,
|
||||
Average = bindings::PixelInterpolateMethod_AverageInterpolatePixel,
|
||||
Average9 = bindings::PixelInterpolateMethod_Average9InterpolatePixel,
|
||||
Average16 = bindings::PixelInterpolateMethod_Average16InterpolatePixel,
|
||||
Background = bindings::PixelInterpolateMethod_BackgroundInterpolatePixel,
|
||||
Bilinear = bindings::PixelInterpolateMethod_BilinearInterpolatePixel,
|
||||
Blend = bindings::PixelInterpolateMethod_BlendInterpolatePixel,
|
||||
Catrom = bindings::PixelInterpolateMethod_CatromInterpolatePixel,
|
||||
Integer = bindings::PixelInterpolateMethod_IntegerInterpolatePixel,
|
||||
Mesh = bindings::PixelInterpolateMethod_MeshInterpolatePixel,
|
||||
Nearest = bindings::PixelInterpolateMethod_NearestInterpolatePixel,
|
||||
Spline = bindings::PixelInterpolateMethod_SplineInterpolatePixel,
|
||||
}
|
||||
|
||||
impl Default for PixelInterpolateMethod {
|
||||
fn default() -> Self {
|
||||
return PixelInterpolateMethod::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PixelInterpolateMethod> for bindings::PixelInterpolateMethod {
|
||||
fn from(value: PixelInterpolateMethod) -> Self {
|
||||
return value as bindings::PixelInterpolateMethod;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::PixelInterpolateMethod> for PixelInterpolateMethod {
|
||||
fn from(value: bindings::PixelInterpolateMethod) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `PixelInterpolateMethod` has the same repr as `bindings::PixelInterpolateMethod` - u32
|
||||
*
|
||||
* If `value` is less than Spline than it is in the vaild range and can be safely
|
||||
* reinterpreted as `PixelInterpolateMethod`
|
||||
*/
|
||||
if value <= bindings::PixelInterpolateMethod_SplineInterpolatePixel {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return PixelInterpolateMethod::default();
|
||||
}
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum PixelMask {
|
||||
Undefined = bindings::PixelMask_UndefinedPixelMask,
|
||||
Read = bindings::PixelMask_ReadPixelMask,
|
||||
Write = bindings::PixelMask_WritePixelMask,
|
||||
Composite = bindings::PixelMask_CompositePixelMask,
|
||||
}
|
||||
|
||||
impl Default for PixelMask {
|
||||
fn default() -> Self {
|
||||
return PixelMask::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PixelMask> for bindings::PixelMask {
|
||||
fn from(value: PixelMask) -> Self {
|
||||
return value as bindings::PixelMask;
|
||||
}
|
||||
}
|
||||
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum RenderingIntent {
|
||||
Undefined = bindings::RenderingIntent_UndefinedIntent,
|
||||
Saturation = bindings::RenderingIntent_SaturationIntent,
|
||||
Perceptual = bindings::RenderingIntent_PerceptualIntent,
|
||||
Absolute = bindings::RenderingIntent_AbsoluteIntent,
|
||||
Relative = bindings::RenderingIntent_RelativeIntent,
|
||||
}
|
||||
|
||||
impl Default for RenderingIntent {
|
||||
fn default() -> Self {
|
||||
return RenderingIntent::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RenderingIntent> for bindings::RenderingIntent {
|
||||
fn from(value: RenderingIntent) -> Self {
|
||||
return value as bindings::RenderingIntent;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::RenderingIntent> for RenderingIntent {
|
||||
fn from(value: bindings::RenderingIntent) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `RenderingIntent` has the same repr as `bindings::RenderingIntent` - u32
|
||||
*
|
||||
* If `value` is less than Relative than it is in the vaild range and can be safely
|
||||
* reinterpreted as `RenderingIntent`
|
||||
*/
|
||||
if value <= bindings::RenderingIntent_RelativeIntent {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return RenderingIntent::default();
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum ResolutionType {
|
||||
Undefined = bindings::ResolutionType_UndefinedResolution,
|
||||
PixelsPerInch = bindings::ResolutionType_PixelsPerInchResolution,
|
||||
PixelsPerCentimeter = bindings::ResolutionType_PixelsPerCentimeterResolution,
|
||||
}
|
||||
|
||||
impl Default for ResolutionType {
|
||||
fn default() -> Self {
|
||||
return ResolutionType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ResolutionType> for bindings::ResolutionType {
|
||||
fn from(value: ResolutionType) -> Self {
|
||||
return value as bindings::ResolutionType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::ResolutionType> for ResolutionType {
|
||||
fn from(value: bindings::ResolutionType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `ResolutionType` has the same repr as `bindings::ResolutionType` - u32
|
||||
*
|
||||
* If `value` is less than PixelsPerCentimeter than it is in the vaild range and can be safely
|
||||
* reinterpreted as `ResolutionType`
|
||||
*/
|
||||
if value <= bindings::ResolutionType_PixelsPerCentimeterResolution {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return ResolutionType::default();
|
||||
}
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
/// Resource type to use with [set_resource_limit](crate::MagickWand::set_resource_limit)
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ResourceType {
|
||||
Undefined = bindings::ResourceType_UndefinedResource as isize,
|
||||
Area = bindings::ResourceType_AreaResource as isize,
|
||||
Disk = bindings::ResourceType_DiskResource as isize,
|
||||
File = bindings::ResourceType_FileResource as isize,
|
||||
Height = bindings::ResourceType_HeightResource as isize,
|
||||
Map = bindings::ResourceType_MapResource as isize,
|
||||
Memory = bindings::ResourceType_MemoryResource as isize,
|
||||
Thread = bindings::ResourceType_ThreadResource as isize,
|
||||
Throttle = bindings::ResourceType_ThrottleResource as isize,
|
||||
Time = bindings::ResourceType_TimeResource as isize,
|
||||
Width = bindings::ResourceType_WidthResource as isize,
|
||||
ListLength = bindings::ResourceType_ListLengthResource as isize,
|
||||
}
|
||||
|
||||
impl From<ResourceType> for bindings::ResourceType {
|
||||
fn from(value: ResourceType) -> Self {
|
||||
return value as bindings::ResourceType;
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum StatisticType {
|
||||
Undefined = bindings::StatisticType_UndefinedStatistic,
|
||||
Gradient = bindings::StatisticType_GradientStatistic,
|
||||
Maximum = bindings::StatisticType_MaximumStatistic,
|
||||
Mean = bindings::StatisticType_MeanStatistic,
|
||||
Median = bindings::StatisticType_MedianStatistic,
|
||||
Minimum = bindings::StatisticType_MinimumStatistic,
|
||||
Mode = bindings::StatisticType_ModeStatistic,
|
||||
Nonpeak = bindings::StatisticType_NonpeakStatistic,
|
||||
RootMeanSquare = bindings::StatisticType_RootMeanSquareStatistic,
|
||||
StandardDeviation = bindings::StatisticType_StandardDeviationStatistic,
|
||||
Contrast = bindings::StatisticType_ContrastStatistic,
|
||||
}
|
||||
|
||||
impl Default for StatisticType {
|
||||
fn default() -> Self {
|
||||
return StatisticType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StatisticType> for bindings::StatisticType {
|
||||
fn from(value: StatisticType) -> Self {
|
||||
return value as bindings::StatisticType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::StatisticType> for StatisticType {
|
||||
fn from(value: bindings::StatisticType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `StatisticType` has the same repr as `bindings::StatisticType` - u32
|
||||
*
|
||||
* If `value` is less than Contrast than it is in the vaild range and can be safely
|
||||
* reinterpreted as `StatisticType`
|
||||
*/
|
||||
if value <= bindings::StatisticType_ContrastStatistic {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return StatisticType::default();
|
||||
}
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum StretchType {
|
||||
Undefined = bindings::StretchType_UndefinedStretch,
|
||||
Normal = bindings::StretchType_NormalStretch,
|
||||
UltraCondensed = bindings::StretchType_UltraCondensedStretch,
|
||||
ExtraCondensed = bindings::StretchType_ExtraCondensedStretch,
|
||||
Condensed = bindings::StretchType_CondensedStretch,
|
||||
SemiCondensed = bindings::StretchType_SemiCondensedStretch,
|
||||
SemiExpanded = bindings::StretchType_SemiExpandedStretch,
|
||||
Expanded = bindings::StretchType_ExpandedStretch,
|
||||
ExtraExpanded = bindings::StretchType_ExtraExpandedStretch,
|
||||
UltraExpanded = bindings::StretchType_UltraExpandedStretch,
|
||||
Any = bindings::StretchType_AnyStretch,
|
||||
}
|
||||
|
||||
impl Default for StretchType {
|
||||
fn default() -> Self {
|
||||
return StretchType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StretchType> for bindings::StretchType {
|
||||
fn from(value: StretchType) -> Self {
|
||||
return value as bindings::StretchType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::StretchType> for StretchType {
|
||||
fn from(value: bindings::StretchType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `StretchType` has the same repr as `bindings::StretchType` - u32
|
||||
*
|
||||
* If `value` is less than Any than it is in the vaild range and can be safely
|
||||
* reinterpreted as `StretchType`
|
||||
*/
|
||||
if value <= bindings::StretchType_AnyStretch {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return StretchType::default();
|
||||
}
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 5ohue
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum StyleType {
|
||||
Undefined = bindings::StyleType_UndefinedStyle,
|
||||
Normal = bindings::StyleType_NormalStyle,
|
||||
Italic = bindings::StyleType_ItalicStyle,
|
||||
Oblique = bindings::StyleType_ObliqueStyle,
|
||||
Any = bindings::StyleType_AnyStyle,
|
||||
Bold = bindings::StyleType_BoldStyle,
|
||||
}
|
||||
|
||||
impl Default for StyleType {
|
||||
fn default() -> Self {
|
||||
return StyleType::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StyleType> for bindings::StyleType {
|
||||
fn from(value: StyleType) -> Self {
|
||||
return value as bindings::StyleType;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::StyleType> for StyleType {
|
||||
fn from(value: bindings::StyleType) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `StyleType` has the same repr as `bindings::StyleType` - u32
|
||||
*
|
||||
* If `value` is less than Bold than it is in the vaild range and can be safely
|
||||
* reinterpreted as `StyleType`
|
||||
*/
|
||||
if value <= bindings::StyleType_BoldStyle {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return StyleType::default();
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ macro_rules! wand_common {
|
||||
|
||||
pub fn clear_exception(&mut self) -> Result<()> {
|
||||
match unsafe { ::bindings::$clear_exc(self.wand) } {
|
||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
||||
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||
_ => Err(MagickError(
|
||||
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)> {
|
||||
let mut severity: ::bindings::ExceptionType =
|
||||
::bindings::ExceptionType_UndefinedException;
|
||||
::bindings::ExceptionType::UndefinedException;
|
||||
|
||||
let ptr = unsafe { ::bindings::$get_exc(self.wand, &mut severity as *mut _) };
|
||||
if ptr.is_null() {
|
||||
@ -70,7 +70,7 @@ macro_rules! wand_common {
|
||||
|
||||
pub fn is_wand(&self) -> Result<()> {
|
||||
match unsafe { ::bindings::$is_wand(self.wand) } {
|
||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
||||
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||
_ => Err(MagickError(
|
||||
concat!(stringify!($wand), " not a wand").to_string(),
|
||||
)),
|
||||
@ -122,7 +122,7 @@ macro_rules! set_get {
|
||||
}
|
||||
pub fn $set(&mut self, v: $typ) -> Result<()> {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
@ -176,7 +176,7 @@ macro_rules! string_set_get {
|
||||
pub fn $set(&mut self, s: &str) -> Result<()> {
|
||||
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()) } {
|
||||
::bindings::MagickBooleanType_MagickTrue => Ok(()),
|
||||
::bindings::MagickBooleanType::MagickTrue => Ok(()),
|
||||
_ => Err(MagickError(concat!(stringify!($set), " returned false").to_string()))
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ macro_rules! mutations {
|
||||
$(#[$attr])*
|
||||
pub fn $fun(&self $(, $arg: $ty)*) -> Result<()> {
|
||||
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()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ use libc::c_void;
|
||||
use libc::size_t;
|
||||
|
||||
use bindings;
|
||||
use conversions::*;
|
||||
use result::MagickError;
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
use size_t;
|
||||
@ -35,8 +34,10 @@ use crate::{
|
||||
CompressionType, DisposeType, DitherMethod, EndianType, FilterType, GravityType, Image,
|
||||
ImageType, InterlaceType, KernelInfo, LayerMethod, MagickEvaluateOperator, MagickFunction,
|
||||
MetricType, MorphologyMethod, OrientationType, PixelInterpolateMethod, PixelMask,
|
||||
RenderingIntent, ResolutionType, ResourceType, StatisticType,
|
||||
RenderingIntent, ResolutionType, StatisticType,
|
||||
};
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use crate::ResourceType;
|
||||
|
||||
wand_common!(
|
||||
MagickWand,
|
||||
@ -138,7 +139,7 @@ impl MagickWand {
|
||||
|
||||
pub fn append_all(&mut self, stack: bool) -> Result<MagickWand> {
|
||||
unsafe { bindings::MagickResetIterator(self.wand) };
|
||||
let result = unsafe { bindings::MagickAppendImages(self.wand, stack.to_magick()) };
|
||||
let result = unsafe { bindings::MagickAppendImages(self.wand, stack.into()) };
|
||||
|
||||
if result.is_null() {
|
||||
return Err(MagickError("failed to append image".to_string()));
|
||||
@ -158,7 +159,7 @@ impl MagickWand {
|
||||
pub fn write_images(&self, path: &str, adjoin: bool) -> Result<()> {
|
||||
let c_name = CString::new(path).map_err(|_| "path string contains null byte")?;
|
||||
let result =
|
||||
unsafe { bindings::MagickWriteImages(self.wand, c_name.as_ptr(), adjoin.to_magick()) };
|
||||
unsafe { bindings::MagickWriteImages(self.wand, c_name.as_ptr(), adjoin.into()) };
|
||||
match result {
|
||||
MagickTrue => Ok(()),
|
||||
_ => Err(MagickError(self.get_exception()?.0)),
|
||||
@ -476,7 +477,7 @@ impl MagickWand {
|
||||
let result = unsafe {
|
||||
bindings::MagickSigmoidalContrastImage(
|
||||
self.wand,
|
||||
sharpen.to_magick(),
|
||||
sharpen.into(),
|
||||
strength,
|
||||
midpoint * quantum_range,
|
||||
)
|
||||
@ -959,7 +960,7 @@ impl MagickWand {
|
||||
width,
|
||||
height,
|
||||
c_map.as_ptr(),
|
||||
bindings::StorageType_CharPixel,
|
||||
bindings::StorageType::CharPixel,
|
||||
pixels.as_mut_ptr() as *mut c_void,
|
||||
) == MagickTrue
|
||||
{
|
||||
@ -991,7 +992,7 @@ impl MagickWand {
|
||||
width,
|
||||
height,
|
||||
c_map.as_ptr(),
|
||||
bindings::StorageType_DoublePixel,
|
||||
bindings::StorageType::DoublePixel,
|
||||
pixels.as_mut_ptr() as *mut c_void,
|
||||
) == MagickTrue
|
||||
{
|
||||
@ -1136,7 +1137,7 @@ impl MagickWand {
|
||||
self.wand,
|
||||
new_width.into(),
|
||||
new_height.into(),
|
||||
bindings::FilterType_LanczosFilter,
|
||||
FilterType::Lanczos,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1312,7 +1313,7 @@ impl MagickWand {
|
||||
columns,
|
||||
rows,
|
||||
pixel_map.as_ptr(),
|
||||
bindings::StorageType_CharPixel,
|
||||
bindings::StorageType::CharPixel,
|
||||
pixels.as_ptr() as *const libc::c_void,
|
||||
)
|
||||
} {
|
||||
@ -1339,8 +1340,8 @@ impl MagickWand {
|
||||
columns,
|
||||
rows,
|
||||
pixel_map.as_ptr(),
|
||||
bindings::StorageType_DoublePixel,
|
||||
pixels.as_ptr() as *const libc::c_void,
|
||||
bindings::StorageType::DoublePixel,
|
||||
pixels.as_ptr() as *const c_void,
|
||||
)
|
||||
} {
|
||||
MagickTrue => Ok(()),
|
||||
@ -1399,7 +1400,7 @@ impl MagickWand {
|
||||
colorspace.into(),
|
||||
tree_depth.into(),
|
||||
dither_method.into(),
|
||||
measure_error.to_magick(),
|
||||
measure_error.into(),
|
||||
)
|
||||
} {
|
||||
MagickTrue => Ok(()),
|
||||
@ -1423,7 +1424,7 @@ impl MagickWand {
|
||||
colorspace.into(),
|
||||
tree_depth.into(),
|
||||
dither_method.into(),
|
||||
measure_error.to_magick(),
|
||||
measure_error.into(),
|
||||
)
|
||||
} {
|
||||
MagickTrue => Ok(()),
|
||||
|
||||
@ -23,5 +23,5 @@ pub use self::drawing::DrawingWand;
|
||||
pub use self::magick::MagickWand;
|
||||
pub use self::pixel::{PixelWand, HSL};
|
||||
|
||||
use bindings::MagickBooleanType_MagickFalse as MagickFalse;
|
||||
use bindings::MagickBooleanType_MagickTrue as MagickTrue;
|
||||
use bindings::MagickBooleanType::MagickFalse as MagickFalse;
|
||||
use bindings::MagickBooleanType::MagickTrue as MagickTrue;
|
||||
|
||||
@ -93,7 +93,7 @@ impl PixelWand {
|
||||
|
||||
set_get_unchecked!(
|
||||
get_color_count, set_color_count, PixelGetColorCount, PixelSetColorCount, usize
|
||||
get_index, set_index, PixelGetIndex, PixelSetIndex, f32
|
||||
get_index, set_index, PixelGetIndex, PixelSetIndex, bindings::Quantum
|
||||
get_fuzz, set_fuzz, PixelGetFuzz, PixelSetFuzz, f64
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user