// Last updated 2008/11/25 08:31
// https://imagemagick.org.cn/discourse-server/viewtopic.php?f=18&t=12118
/*
magick convert cyclops.gif -bordercolor white -border 1x1 -matte \
-fill none -fuzz 20% -draw "matte 0,0 floodfill" \
-shave 1x1 cyclops_flood_3.png
*/
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(void)
{
MagickWand *mw = NULL;
PixelWand *bg = NULL;
PixelWand *fg = NULL;
DrawingWand *dw = NULL;
ChannelType channel;
MagickWandGenesis();
mw = NewMagickWand();
// Uses Anthony's image from https://imagemagick.org.cn/Usage/images/cyclops_sm.gif
MagickReadImage(mw,"cyclops_sm.gif");
// "background" wand for the Border and then for the floodfill
bg = NewPixelWand();
PixelSetColor(bg,"white");
MagickBorderImage(mw,bg,1,1);
// -matte is the same as -alpha on
MagickSetImageAlphaChannel(mw,SetAlphaChannel);
// "foreground" wand
fg = NewPixelWand();
PixelSetColor(fg,"none");
// Set up the channels required for the floodfill
// Must have "a" channel here too!
channel = ParseChannelOption("rgba");
// Floodfill the "background" colour with the "foreground" colour
// starting at coordinate 0,0 using a fuzz of 20
MagickFloodfillPaintImage(mw,channel,fg,20,bg,0,0,MagickFalse);
MagickShaveImage(mw,1,1);
MagickWriteImage(mw,"cyclops_sm_flood.png");
DestroyMagickWand(mw);
DestroyPixelWand(fg);
DestroyPixelWand(bg);
MagickWandTerminus();
}