Posted: 2006-10-18T09:34:08-07:00
To generate a bilevel image, add
- MagickSetImageType(wand, BilevelType);
Use https://github.com/ImageMagick/ImageMagick/discussions instead.
https://imagemagick.com/discourse-server/
https://imagemagick.com/discourse-server/viewtopic.php?t=6717
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>
int main(int argc,char **argv)
{
#define ThrowWandException(wand) \
{ \
char \
*description; \
\
ExceptionType \
severity; \
\
description=MagickGetException(wand,&severity); \
(void) fprintf(stderr,"%s %s %ld %s\n",GetMagickModule(),description); \
description=(char *) MagickRelinquishMemory(description); \
exit(-1); \
}
MagickBooleanType
status;
MagickWand
*magick_wand;
/*
Read an image.
*/
MagickWandGenesis();
magick_wand=NewMagickWand();
status=MagickReadImage(magick_wand,"image.gif");
if (status == MagickFalse)
ThrowWandException(magick_wand);
/*
Write as a bilvel group4-compressed TIFF image.
*/
MagickSetImageType(magick_wand,BilevelType);
MagickSetImageCompression(magick_wand,Group4Compression);
status=MagickWriteImages(magick_wand,"image.tif",MagickTrue);
if (status == MagickFalse)
ThrowWandException(magick_wand);
magick_wand=DestroyMagickWand(magick_wand);
MagickWandTerminus();
return(0);
}
Code: Select all
Histogram:
16: none #000000FF
94000: white #FFFFFF00
155984: rgba(255,255,255,0) #FFFFFFFF
Colormap: 2
0: black #00000000
1: white #FFFFFF00
Code: Select all
{
DrawingWand *dw;
PixelWand *pw;
pw = NewPixelWand();
PixelSetColor(pw,"black");
dw = NewDrawingWand();
DrawSetFont(dw, "Arial");
DrawAnnotation(dw, 10, 10, "test");
MagickDrawImage(magick_wand, dw);
dw = DestroyDrawingWand(dw);
pw = DestroyPixelWand(pw);
}
Code: Select all
http://members.shaw.ca/el_supremo/animate-2.gif