Bug in ColorFloodfillImage in 6.3.2

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Bug in ColorFloodfillImage in 6.3.2

Post by rmagick »

The C program below uses ColorFloodfillImage with the FilltoBorderMethod to fill with an image. It produces the expected image when built with "ImageMagick 6.2.9 10/19/06 Q16"
Image

When built with "ImageMagick 6.3.2 01/19/07 Q16" it produces the following image:
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;
}
[/code]
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Bug was picked up in IM examples and has been fixed in the current alpha test release. The beta of this fix may already be available.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Post by rmagick »

Good deal! Thanks!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

The problem is fixed in ImageMagick-6.3.2-1 Beta. It will be available by tommorrow. In the mean-time you can call
  • (void) SetImageVirtualPixelMethod(draw->fill_pattern,TileVirtualPixelMethod);
rmagick
Posts: 245
Joined: 2006-03-16T17:30:48-07:00
Location: Durham, NC, USA

Post by rmagick »

I built all the RMagick samples with the beta and everything worked perfectly. Thanks!
Post Reply