- MagickSetImageType(wand, BilevelType);
Save a "Bilevel" TIFF image ?
We tried this program with ImageMagick 6.3.0 and produced a bilevel group4-compressed TIFF image:
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);
}
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
[EDIT: I'm using ImageMagick 6.3.0 10/14/06 Q8 binary]
I've been playing with the original code and I also get problems. It produces a TIF which crashes PSP X. When I identify the TIF, it has 3 colours:
I've tried Magick's most recent code and that works but adding the Annotate blows it up again.
Try adding this code immediately before the MagickSetImageType:
and if that doesn't cause problems then change the MagickReadImage filename to:
When I use this image and Annotate it, PSPX shows the output GIF as a black image with white spots down one side.
Also, change the output name to image.png and do a verbose identify. The type is GrayScaleMatte instead of Bilevel. If you just create a plain, white image, change it to Bilevel and write it as PNG, the output will be Bilevel.
Pete
I've been playing with the original code and I also get problems. It produces a TIF which crashes PSP X. When I identify the TIF, it has 3 colours:
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
Try adding this code immediately before the MagickSetImageType:
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
Also, change the output name to image.png and do a verbose identify. The type is GrayScaleMatte instead of Bilevel. If you just create a plain, white image, change it to Bilevel and write it as PNG, the output will be Bilevel.
Pete