add negate_image() operation

Signed-off-by: Nikola Pajkovsky <nikola.pajkovsky@livesporttv.cz>
This commit is contained in:
Nikola Pajkovsky
2020-05-21 12:07:47 +02:00
parent 92b12900ab
commit 415ad30bd0
2 changed files with 25 additions and 0 deletions

View File

@ -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 {

View File

@ -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()
);
}