// Last updated 2008/12/11 09:49
// Replace the white background area of logo: with transparent and don't forget
// that for this the channel must be "rgba" and the output image must be PNG
// or other format which supports transparency
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
MagickWand *m_wand = NULL;
PixelWand *fc_wand = NULL;
PixelWand *bc_wand = NULL;
ChannelType channel;
MagickWandGenesis();
m_wand = NewMagickWand();
// PixelWands for the fill and bordercolour
fc_wand = NewPixelWand();
bc_wand = NewPixelWand();
MagickReadImage(m_wand,"logo:");
PixelSetColor(fc_wand,"none");
PixelSetColor(bc_wand,"white");
// Convert "rgba" to the enumerated ChannelType required by the floodfill function
channel = ParseChannelOption("rgba");
// The bordercolor=bc_wand (with fuzz of 20 applied) is replaced
// by the fill colour=fc_wand starting at the given coordinate - in this case 0,0.
// Normally the last argument is MagickFalse so that the colours are matched but
// if it is MagickTrue then it floodfills any pixel that does *not* match
// the target color
MagickFloodfillPaintImage(m_wand,channel,fc_wand,20,bc_wand,0,0,MagickFalse);
MagickWriteImage(m_wand,"logo_paintflood.png");
/* and we're done so destroy the magick wand etc.*/
fc_wand = DestroyPixelWand(fc_wand);
bc_wand = DestroyPixelWand(bc_wand);
m_wand = DestroyMagickWand(m_wand);
MagickWandTerminus();
}