From 415ad30bd06f68faccecf3330f7ad77e27e99a51 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Thu, 21 May 2020 12:07:47 +0200 Subject: [PATCH] add negate_image() operation Signed-off-by: Nikola Pajkovsky --- src/wand/magick.rs | 10 ++++++++++ tests/lib.rs | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 6f48704..5afd34d 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -335,6 +335,16 @@ impl MagickWand { } } + pub fn negate_image(&self) -> Result<(), &'static str> { + let result = unsafe { + bindings::MagickNegateImage(self.wand, bindings::MagickBooleanType_MagickTrue) + }; + match result { + bindings::MagickBooleanType_MagickTrue => Ok(()), + _ => Err("failed to flip image"), + } + } + pub fn flop_image(&self) -> Result<(), &'static str> { let result = unsafe { bindings::MagickFlopImage(self.wand) }; match result { diff --git a/tests/lib.rs b/tests/lib.rs index 91482ee..afa4e80 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -346,3 +346,18 @@ fn test_clut_image() { ) .is_ok()); } + +#[test] +fn test_negate_image() { + START.call_once(|| { + magick_wand_genesis(); + }); + let wand = MagickWand::new(); + assert!(wand.read_image("tests/data/rust.png").is_ok()); + wand.negate_image().unwrap(); + let pixel_color = wand.get_image_pixel_color(0, 0).unwrap(); + assert_eq!( + "srgb(255,255,255)", + pixel_color.get_color_as_string().unwrap() + ); +}