When built with "ImageMagick 6.3.2 01/19/07 Q16" it produces the following image:
Please let me know if you need more information.
Code: Select all
/*
gcc `Magick-config --cflags --cppflags` texturefilltoborder.c `Magick-config --ldflags --libs` -o texturefilltoborder
*/
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <magick/api.h>
int main(int argc,char **argv)
{
Image *image, *rose;
ImageInfo *image_info;
PixelPacket black;
DrawInfo *draw;
ExceptionInfo exception;
const char * const primitives =
"fill transparent\n"
"stroke black\n"
"stroke-width 2\n"
"circle 100,100,180,100\n"
"fill plum1\n"
"stroke transparent\n"
"circle 60,100,40,100\n"
"circle 140,100,120,100\n"
"circle 100,60,100,40\n"
"circle 100,140,100,120\n"
;
InitializeMagick("TextureFillToBorderTest");
image_info=CloneImageInfo((ImageInfo *) NULL);
image_info->size = AcquireMemory(sizeof("200x200"));
strcpy(image_info->size, "200x200");
image=AllocateImage(image_info);
if (image == (Image *) NULL)
MagickError(ResourceLimitError,"Unable to display image",
"Memory allocation failed");
SetImage(image, OpaqueOpacity);
draw = CloneDrawInfo(image_info, NULL);
CloneString(&(draw->primitive), primitives);
DrawImage(image, draw);
if (image->exception.severity != UndefinedException)
{
printf("%s: %s", image->exception.reason, image->exception.description);
exit(1);
}
//DisplayImages(image_info, image);
DestroyImageInfo(image_info);
image_info=CloneImageInfo((ImageInfo *) NULL);
strcpy(image_info->filename, "rose:");
SetImageInfoFile(image_info, NULL);
GetExceptionInfo(&exception);
rose = ReadImage(image_info, &exception);
if (exception.severity != UndefinedException)
{
printf("%s: %s", exception.reason, exception.description);
exit(1);
}
draw->fill_pattern = rose;
draw->fill.red = MaxRGB;
draw->fill.green = MaxRGB;
draw->fill.blue = MaxRGB;
draw->fill.opacity = OpaqueOpacity;
black.red = 0;
black.green = 0;
black.blue = 0;
black.opacity = OpaqueOpacity;
ColorFloodfillImage(image, draw, black, 100, 100, FillToBorderMethod);
if (image->exception.severity != UndefinedException)
{
printf("%s: %s", image->exception.reason, image->exception.description);
exit(1);
}
//memset(image_info->filename, 0, sizeof(image_info->filename));
//DisplayImages(image_info,image);
strcpy(image_info->filename, "texturefilltoborder.jpg");
strcpy(image->filename, image_info->filename);
WriteImage(image_info, image);
/*
Free resources.
*/
DestroyExceptionInfo(&exception);
DestroyDrawInfo(draw);
DestroyImage(image);
DestroyImageInfo(image_info);
DestroyMagick();
return 0;
}