When I build the example program with 6.3.3-1 Q8 it produces this image:
Is this the expected behavior? If so, is there a workaround to get the Q8 version to produce an image closer to the Q16 version of the image?
Here's the input image "bolilla.png" for this test:
Code: Select all
/*
gcc `Magick-config --cflags --cppflags` tbe.c `Magick-config --ldflags --libs` -o tbe
*/
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <magick/api.h>
int main(int argc, char **argv)
{
Image *click_image, *image;
ImageInfo *image_info;
ExceptionInfo exception;
MagickBooleanType okay;
PixelPacket white;
unsigned long version;
char name[50];
int x;
InitializeMagick("Test");
(void) GetMagickVersion(&version);
GetExceptionInfo(&exception);
okay = QueryColorDatabase("white", &white, &exception);
if (!okay)
{
MagickFatalError(exception.severity, exception.reason, exception.description);
}
image_info=CloneImageInfo((ImageInfo *) NULL);
strcpy(image_info->filename, "bolilla.png");
GetExceptionInfo(&exception);
click_image = ReadImage(image_info, &exception);
if (exception.severity != UndefinedException)
{
MagickFatalError(exception.severity, exception.reason, exception.description);
}
image = ColorizeImage(click_image, "97/97/97", white, &exception);
if (!image)
{
MagickFatalError(exception.severity, exception.reason, exception.description);
}
DestroyImage(click_image);
click_image = image;
DestroyImageInfo(image_info);
image_info=CloneImageInfo((ImageInfo *) NULL);
image_info->size = AcquireMemory(sizeof("100x300"));
strcpy(image_info->size, "100x300");
okay = QueryColorDatabase("white", &image_info->background_color, &exception);
if (!okay)
{
MagickFatalError(exception.severity, exception.reason, exception.description);
}
image_info->background_color = white;
image = AllocateImage(image_info);
if (image == (Image *) NULL)
{
MagickFatalError(ResourceLimitError, "Unable to allocate image", "Memory allocation failed");
}
// (void) SetImageBackgroundColor(image); not available in 6.0.6
(void) SetImage(image, OpaqueOpacity);
// Here's the meat
for (x = 0; x < 50; x++)
{
(void) CompositeImage(image, MultiplyCompositeOp, click_image, 20, 30);
if (exception.severity != UndefinedException)
{
MagickFatalError(exception.severity, exception.reason, exception.description);
}
}
NegateImage(image, MagickFalse);
DestroyImageInfo(image_info);
image_info = CloneImageInfo((ImageInfo *) NULL);
sprintf(name, "tbe_output-%3lx.png", version);
strcpy(image_info->filename, name);
strcpy(image->filename, image_info->filename);
WriteImage(image_info, image);
(void) DestroyExceptionInfo(&exception);
(void) DestroyImage(image);
(void) DestroyImage(click_image);
(void) DestroyImageInfo(image_info);
(void) DestroyMagick();
return 0;
}