Update to latest release of bindgen

Note that all of the enum definitions changed (again?), and now they are
flattened into the 'bindings' namespace. This breaks the API in a way that
is relatively easy to fix, albeit annoying. Attempts to change the enum
generation using default_enum_style() resulted in endless compiler errors.

cargo test passes
This commit is contained in:
Nathan Fiedler 2018-10-06 15:05:16 -07:00
parent 336606f121
commit 8a4fced836
10 changed files with 86 additions and 93 deletions

View file

@ -5,6 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This file follows the convention described at
[Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Changed
- Updated `bindgen` dependency to latest release and fixed compiler issues.
Enum definitions changed again, default in bindgen is different now, and
using `default_enum_style()` caused endless compiler errors.
## [0.10.0] - 2018-08-11
### Added
- Mewp: Add ping_image and ping_image_blob functions.

View file

@ -14,5 +14,5 @@ build = "build.rs"
libc = ">=0.2"
[build-dependencies]
bindgen = "0.29"
pkg-config = "0.3.9"
bindgen = "0.42"
pkg-config = "0.3"

View file

@ -20,7 +20,7 @@ A somewhat safe Rust interface to the [ImageMagick](http://www.imagemagick.org/)
Pretty simple for now.
```
```shell
$ cargo build
$ cargo test
```
@ -38,7 +38,7 @@ It can be found in *Start menu -> Visual Studio < VERSION > -> Visual Studio Too
Choose the architecture corresponding to architecture of your rust compiler.
This is required for the proper functioning of `rust-bindgen`.
```
```shell
> set IMAGE_MAGICK_DIR=<path to ImageMagick installation directory>
> cargo build
> cargo test
@ -77,7 +77,7 @@ 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
$ docker-compose run magick-rust

View file

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 Nathan Fiedler
* Copyright 2016-2018 Nathan Fiedler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -91,16 +91,16 @@ fn main() {
.raw_line("extern crate libc;")
.header(gen_h_path.to_str().unwrap())
// https://github.com/rust-lang-nursery/rust-bindgen/issues/687
.hide_type("FP_NAN")
.hide_type("FP_INFINITE")
.hide_type("FP_ZERO")
.hide_type("FP_SUBNORMAL")
.hide_type("FP_NORMAL")
.hide_type("FP_INT_UPWARD")
.hide_type("FP_INT_DOWNWARD")
.hide_type("FP_INT_TOWARDZERO")
.hide_type("FP_INT_TONEARESTFROMZERO")
.hide_type("FP_INT_TONEAREST");
.blacklist_type("FP_NAN")
.blacklist_type("FP_INFINITE")
.blacklist_type("FP_ZERO")
.blacklist_type("FP_SUBNORMAL")
.blacklist_type("FP_NORMAL")
.blacklist_type("FP_INT_UPWARD")
.blacklist_type("FP_INT_DOWNWARD")
.blacklist_type("FP_INT_TOWARDZERO")
.blacklist_type("FP_INT_TONEARESTFROMZERO")
.blacklist_type("FP_INT_TONEAREST");
for d in include_dirs {
builder = builder.clang_arg(format!("-I{}", d.to_string_lossy()));

View file

@ -22,9 +22,9 @@ pub trait FromRust<T> {
impl FromRust<bool> for bindings::MagickBooleanType {
fn from_rust(b: bool) -> Self {
if b {
bindings::MagickBooleanType::MagickTrue
bindings::MagickBooleanType_MagickTrue
} else {
bindings::MagickBooleanType::MagickFalse
bindings::MagickBooleanType_MagickFalse
}
}
}

View file

@ -49,7 +49,7 @@ use libc::ssize_t;
pub fn magick_wand_genesis() {
unsafe {
match bindings::IsMagickWandInstantiated() {
bindings::MagickBooleanType::MagickTrue => (),
bindings::MagickBooleanType_MagickTrue => (),
_ => bindings::MagickWandGenesis()
}
}
@ -60,7 +60,7 @@ pub fn magick_wand_genesis() {
pub fn magick_wand_terminus() {
unsafe {
match bindings::IsMagickWandInstantiated() {
bindings::MagickBooleanType::MagickTrue => bindings::MagickWandTerminus(),
bindings::MagickBooleanType_MagickTrue => bindings::MagickWandTerminus(),
_ => ()
}
}

View file

@ -35,7 +35,7 @@ macro_rules! wand_common {
fn clear_exception(&mut self) -> Result<(), &'static str> {
match unsafe { ::bindings::$clear_exc(self.wand) } {
::bindings::MagickBooleanType::MagickTrue => Ok(()),
::bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(concat!("failed to clear", stringify!($wand), "exception"))
}
}
@ -45,7 +45,7 @@ macro_rules! wand_common {
}
fn get_exception(&self) -> Result<(String, ::bindings::ExceptionType), &'static str> {
let mut severity: ::bindings::ExceptionType = ::bindings::ExceptionType::UndefinedException;
let mut severity: ::bindings::ExceptionType = ::bindings::ExceptionType_UndefinedException;
// TODO: memory management
let ptr = unsafe { ::bindings::$get_exc(self.wand, &mut severity as *mut _) };
if ptr.is_null() {
@ -58,7 +58,7 @@ macro_rules! wand_common {
pub fn is_wand(&self) -> Result<(), &'static str> {
match unsafe { ::bindings::$is_wand(self.wand) } {
::bindings::MagickBooleanType::MagickTrue => Ok(()),
::bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(concat!(stringify!($wand), " not a wand"))
}
}
@ -101,7 +101,7 @@ macro_rules! set_get {
}
pub fn $set(&mut self, v: $typ) -> Result<(), &'static str> {
match unsafe { ::bindings::$c_set(self.wand, v) } {
::bindings::MagickBooleanType::MagickTrue => Ok(()),
::bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(concat!(stringify!($set), " returned false"))
}
}
@ -153,7 +153,7 @@ macro_rules! string_set_get {
pub fn $set(&mut self, s: &str) -> Result<(), &'static str> {
let c_string = try!(::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(concat!(stringify!($set), " returned false"))
}
}
@ -245,7 +245,7 @@ macro_rules! mutations {
$(#[$attr])*
pub fn $fun(&self $(, $arg: $ty)*) -> Result<(), &'static str> {
match unsafe { bindings::$c_fun(self.wand $(, $arg)*) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(concat!(stringify!($c_fun), " invocation failed"))
}
}

View file

@ -41,7 +41,7 @@ impl MagickWand {
pub fn new_image(&self, columns: size_t, rows: size_t, pixel_wand: &PixelWand) -> Result<(), &'static str> {
match unsafe { bindings::MagickNewImage(self.wand, columns, rows, pixel_wand.wand) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("Could not create image"),
}
}
@ -53,7 +53,7 @@ impl MagickWand {
bindings::MagickSetOption(self.wand, c_key.as_ptr(), c_value.as_ptr())
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to set option"),
}
}
@ -61,7 +61,7 @@ impl MagickWand {
pub fn annotate_image(&mut self, drawing_wand: &DrawingWand, x: f64, y: f64, angle: f64, text: &str) -> Result<(), &'static str> {
let c_string = try!(CString::new(text).map_err(|_| "could not convert to cstring"));
match unsafe { bindings::MagickAnnotateImage(self.wand, drawing_wand.wand, x, y, angle, c_string.as_ptr() as *const _) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("unable to annotate image")
}
}
@ -69,7 +69,7 @@ impl MagickWand {
/// Add all images from another wand to this wand at the current index.
pub fn add_image(&mut self, other_wand: &MagickWand) -> Result<(), &'static str> {
match unsafe { bindings::MagickAddImage(self.wand, other_wand.wand) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("unable to add images from another wand")
}
}
@ -87,7 +87,7 @@ impl MagickWand {
bindings::MagickLabelImage(self.wand, c_label.as_ptr())
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to add label")
}
}
@ -98,7 +98,7 @@ impl MagickWand {
bindings::MagickWriteImages(self.wand, c_name.as_ptr(), adjoin.to_magick())
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to write images")
}
}
@ -110,7 +110,7 @@ impl MagickWand {
bindings::MagickReadImage(self.wand, c_name.as_ptr())
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to read image")
}
}
@ -124,7 +124,7 @@ impl MagickWand {
self.wand, int_slice.as_ptr() as *const c_void, size as size_t)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to read image")
}
}
@ -137,7 +137,7 @@ impl MagickWand {
bindings::MagickPingImage(self.wand, c_name.as_ptr())
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to ping image")
}
}
@ -152,7 +152,7 @@ impl MagickWand {
self.wand, int_slice.as_ptr() as *const c_void, size as size_t)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to ping image")
}
}
@ -175,14 +175,18 @@ impl MagickWand {
/// Compose another image onto self at (x, y) using composition_operator
pub fn compose_images(&self, reference: &MagickWand, composition_operator: bindings::CompositeOperator, clip_to_self: bool, x: isize, y: isize) -> Result<(), &'static str> {
let native_clip_to_self = if clip_to_self {
bindings::MagickBooleanType_MagickTrue
} else {
bindings::MagickBooleanType_MagickFalse
};
let result = unsafe {
bindings::MagickCompositeImage(self.wand, reference.wand,
composition_operator, bindings::MagickBooleanType::from_rust(clip_to_self),
x, y
composition_operator, native_clip_to_self, x, y
)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to compose images")
}
}
@ -194,7 +198,7 @@ impl MagickWand {
bindings::MagickExtentImage(self.wand, width, height, x, y)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to extend image")
}
}
@ -214,7 +218,7 @@ impl MagickWand {
bindings::MagickProfileImage(self.wand, c_name.as_ptr(), profile_ptr, profile_len)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to profile image")
}
}
@ -224,7 +228,7 @@ impl MagickWand {
bindings::MagickFlipImage(self.wand)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to flip image")
}
}
@ -234,7 +238,7 @@ impl MagickWand {
bindings::MagickFlopImage(self.wand)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to flip image")
}
}
@ -242,7 +246,7 @@ impl MagickWand {
/// Adaptively resize the currently selected image.
pub fn adaptive_resize_image(&self, width: usize, height: usize) -> Result<(), &'static str> {
match unsafe { bindings::MagickAdaptiveResizeImage(self.wand, width, height)} {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to adaptive-resize image")
}
}
@ -251,7 +255,7 @@ impl MagickWand {
/// filling any empty space with the background color of a given PixelWand
pub fn rotate_image(&self, background: &PixelWand, degrees: f64) -> Result<(), &'static str> {
match unsafe { bindings::MagickRotateImage(self.wand, background.wand, degrees) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to rotate image")
}
}
@ -262,7 +266,7 @@ impl MagickWand {
bindings::MagickTrimImage(self.wand, fuzz)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to trim image")
}
}
@ -296,7 +300,7 @@ impl MagickWand {
let result = unsafe {
bindings::MagickResetImagePage(self.wand, c_page_geometry.as_ptr())
};
if result == bindings::MagickBooleanType::MagickTrue {
if result == bindings::MagickBooleanType_MagickTrue {
Ok(())
} else {
Err("Resetting page geometry failed.")
@ -329,7 +333,7 @@ impl MagickWand {
let result = unsafe {
bindings::MagickSetImageProperty(self.wand, c_name.as_ptr(), c_value.as_ptr())
};
if result == bindings::MagickBooleanType::MagickTrue {
if result == bindings::MagickBooleanType_MagickTrue {
Ok(())
} else {
Err("Setting image property failed.")
@ -341,7 +345,7 @@ impl MagickWand {
let pw = PixelWand::new();
unsafe {
if bindings::MagickGetImagePixelColor(self.wand, x, y, pw.wand) == bindings::MagickBooleanType::MagickTrue {
if bindings::MagickGetImagePixelColor(self.wand, x, y, pw.wand) == bindings::MagickBooleanType_MagickTrue {
Some(pw)
} else {
None
@ -354,7 +358,7 @@ impl MagickWand {
/// samplingFactors: An array of floats representing the sampling factor for each color component (in RGB order).
pub fn set_sampling_factors(&self, samplingFactors: &[f64]) -> Result<(), &'static str> {
match unsafe { bindings::MagickSetSamplingFactors(self.wand, samplingFactors.len(), &samplingFactors[0]) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("SetSamplingFactors returned false")
}
}
@ -384,7 +388,7 @@ impl MagickWand {
pub fn sharpen_image(&self, radius: f64, sigma: f64) -> Result<(), &'static str> {
match unsafe { bindings::MagickSharpenImage(self.wand, radius, sigma) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("SharpenImage returned false")
@ -396,7 +400,7 @@ impl MagickWand {
match unsafe { bindings::MagickSetImageBackgroundColor(self.wand, pixel_wand.wand) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("SetImageBackgroundColor returned false")
@ -409,7 +413,7 @@ impl MagickWand {
let mut x_resolution = 0f64;
let mut y_resolution = 0f64;
unsafe {
if bindings::MagickGetImageResolution(self.wand, &mut x_resolution, &mut y_resolution) == bindings::MagickBooleanType::MagickTrue {
if bindings::MagickGetImageResolution(self.wand, &mut x_resolution, &mut y_resolution) == bindings::MagickBooleanType_MagickTrue {
Ok((x_resolution, y_resolution))
} else {
Err("GetImageResolution returned false")
@ -420,7 +424,7 @@ impl MagickWand {
/// Sets the image resolution
pub fn set_image_resolution(&self, x_resolution: f64, y_resolution: f64) -> Result<(), &'static str> {
unsafe {
if bindings::MagickSetImageResolution(self.wand, x_resolution, y_resolution) == bindings::MagickBooleanType::MagickTrue {
if bindings::MagickSetImageResolution(self.wand, x_resolution, y_resolution) == bindings::MagickBooleanType_MagickTrue {
Ok(())
} else {
Err("SetImageResolution returned false")
@ -431,7 +435,7 @@ impl MagickWand {
/// Sets the wand resolution
pub fn set_resolution(&self, x_resolution: f64, y_resolution: f64) -> Result<(), &'static str> {
unsafe {
if bindings::MagickSetResolution(self.wand, x_resolution, y_resolution) == bindings::MagickBooleanType::MagickTrue {
if bindings::MagickSetResolution(self.wand, x_resolution, y_resolution) == bindings::MagickBooleanType_MagickTrue {
Ok(())
} else {
Err("SetResolution returned false")
@ -442,7 +446,7 @@ impl MagickWand {
/// Returns the image resolution as a pair (horizontal resolution, vertical resolution)
pub fn sepia_tone_image(&self, threshold: f64) -> Result<(), &'static str> {
unsafe {
if bindings::MagickSepiaToneImage(self.wand, threshold * bindings::QuantumRange) == bindings::MagickBooleanType::MagickTrue {
if bindings::MagickSepiaToneImage(self.wand, threshold * bindings::QuantumRange) == bindings::MagickBooleanType_MagickTrue {
Ok(())
} else {
Err("SepiaToneImage returned false")
@ -460,7 +464,7 @@ impl MagickWand {
unsafe {
pixels.set_len(capacity as usize);
if bindings::MagickExportImagePixels(self.wand, x, y, width, height, c_map.as_ptr(),
bindings::StorageType::CharPixel, pixels.as_mut_ptr() as *mut c_void) == bindings::MagickBooleanType::MagickTrue {
bindings::StorageType_CharPixel, pixels.as_mut_ptr() as *mut c_void) == bindings::MagickBooleanType_MagickTrue {
Some(pixels)
} else {
None
@ -486,7 +490,7 @@ impl MagickWand {
bindings::MagickCropImage(self.wand, width, height, x, y)
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to crop image")
}
}
@ -520,9 +524,9 @@ impl MagickWand {
}
unsafe {
bindings::MagickResetIterator(self.wand);
while bindings::MagickNextImage(self.wand) != bindings::MagickBooleanType::MagickFalse {
while bindings::MagickNextImage(self.wand) != bindings::MagickBooleanType_MagickFalse {
bindings::MagickResizeImage(self.wand, new_width, new_height,
bindings::FilterType::LanczosFilter);
bindings::FilterType_LanczosFilter);
}
}
}
@ -531,7 +535,7 @@ impl MagickWand {
/// hence should be "auto" oriented so it is suitable for viewing.
pub fn requires_orientation(&self) -> bool {
unsafe {
bindings::MagickGetImageOrientation(self.wand) != bindings::OrientationType::TopLeftOrientation
bindings::MagickGetImageOrientation(self.wand) != bindings::OrientationType_TopLeftOrientation
}
}
@ -541,7 +545,7 @@ impl MagickWand {
/// Returns `true` if successful or `false` if an error occurred.
pub fn auto_orient(&self) -> bool {
unsafe {
bindings::MagickAutoOrientImage(self.wand) == bindings::MagickBooleanType::MagickTrue
bindings::MagickAutoOrientImage(self.wand) == bindings::MagickBooleanType_MagickTrue
}
}
@ -552,7 +556,7 @@ impl MagickWand {
bindings::MagickWriteImage(self.wand, c_name.as_ptr())
};
match result {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to write image")
}
}

View file

@ -37,7 +37,7 @@ wand_common!(
impl PixelWand {
pub fn is_similar(&self, other: &PixelWand, fuzz: f64) -> Result<(), &'static str> {
match unsafe { bindings::IsPixelWandSimilar(self.wand, other.wand, fuzz) } {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("not similar")
}
}
@ -76,7 +76,7 @@ impl PixelWand {
pub fn set_color(&mut self, s: &str) -> Result<(), &'static str> {
let c_string = try!(CString::new(s).map_err(|_| "could not convert to cstring"));
match unsafe { bindings::PixelSetColor(self.wand, c_string.as_ptr())} {
bindings::MagickBooleanType::MagickTrue => Ok(()),
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to set color")
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 Nathan Fiedler
* Copyright 2015-2018 Nathan Fiedler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
extern crate magick_rust;
use magick_rust::{MagickWand, magick_wand_genesis, MetricType, ColorspaceType, FilterType, DitherMethod, PixelWand, bindings};
use magick_rust::{MagickWand, magick_wand_genesis, PixelWand, bindings};
use std::error::Error;
use std::fs::File;
@ -54,7 +54,7 @@ fn test_resize_image() {
1 => 1,
height => height / 2
};
wand.resize_image(halfwidth, halfheight, FilterType::LanczosFilter);
wand.resize_image(halfwidth, halfheight, bindings::FilterType_LanczosFilter);
assert_eq!(256, wand.get_image_width());
assert_eq!(192, wand.get_image_height());
}
@ -186,7 +186,7 @@ fn test_compare_images() {
assert!(wand2.read_image("tests/data/IMG_5745_rotl.JPG").is_ok());
wand2.auto_orient();
let (distortion, diff) = wand1.compare_images(&wand2, MetricType::RootMeanSquaredErrorMetric);
let (distortion, diff) = wand1.compare_images(&wand2, bindings::MetricType_RootMeanSquaredErrorMetric);
assert!(distortion < 0.01);
assert!(diff.is_some());
}
@ -225,13 +225,13 @@ fn test_transform_image_colorspace() {
});
let wand = MagickWand::new();
assert!(wand.read_image("tests/data/IMG_5745.JPG").is_ok());
assert_eq!(wand.get_image_colorspace(), ColorspaceType::sRGBColorspace);
assert_eq!(wand.get_image_colorspace(), bindings::ColorspaceType_sRGBColorspace);
let pixel_color = wand.get_image_pixel_color(10, 10).unwrap();
assert_ne!(pixel_color.get_hsl().hue, 0.0);
assert!(wand.transform_image_colorspace(ColorspaceType::GRAYColorspace).is_ok());
assert_eq!(wand.get_image_colorspace(), ColorspaceType::GRAYColorspace);
assert!(wand.transform_image_colorspace(bindings::ColorspaceType_GRAYColorspace).is_ok());
assert_eq!(wand.get_image_colorspace(), bindings::ColorspaceType_GRAYColorspace);
let pixel_grayscale = wand.get_image_pixel_color(10, 10).unwrap();
assert_eq!(pixel_grayscale.get_hsl().hue, 0.0);
@ -254,8 +254,8 @@ fn test_color_reduction() {
let image_colors = wand.get_image_colors();
assert!(image_colors > 38000 || image_colors < 40000);
assert!(wand.quantize_image(6, ColorspaceType::RGBColorspace, 1,
DitherMethod::UndefinedDitherMethod, false.to_magick()).is_ok());
assert!(wand.quantize_image(6, bindings::ColorspaceType_RGBColorspace, 1,
bindings::DitherMethod_UndefinedDitherMethod, false.to_magick()).is_ok());
assert_eq!(6, wand.get_image_colors());
let histogram = wand.get_image_histogram().unwrap();
@ -267,33 +267,16 @@ fn test_color_reduction() {
#[test]
fn test_set_image_background_color() {
START.call_once(|| {
magick_wand_genesis();
});
let wand = MagickWand::new();
assert!(wand.read_image("tests/data/rust.png").is_ok());
let mut pw = PixelWand::new();
pw.set_color("#0000FF").unwrap();
wand.set_image_background_color(&pw).unwrap();
wand.set_image_alpha_channel(bindings::AlphaChannelOption::RemoveAlphaChannel).unwrap();
wand.set_image_alpha_channel(bindings::AlphaChannelOption_RemoveAlphaChannel).unwrap();
let blob = wand.write_image_blob("rgb").unwrap();
assert_eq!(0u8, blob[0]);
assert_eq!(0u8, blob[1]);
assert_eq!(255u8, blob[2]);
}
}