Skip to content

Commit

Permalink
add negate_image() operation
Browse files Browse the repository at this point in the history
Signed-off-by: Nikola Pajkovsky <[email protected]>
  • Loading branch information
Nikola Pajkovsky committed May 21, 2020
1 parent 92b1290 commit 415ad30
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/wand/magick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}

0 comments on commit 415ad30

Please sign in to comment.