Hi,
Please you could you either say or add to the documentation, what format the density string should take for the DrawSetDensity() function, and what it is used for?
cheers
Dan
DrawSetDensity example
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: DrawSetDensity example
What API contains a DrawSetDensity() function? I can't find it in the Core or Wand APIs.
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: DrawSetDensity example
Okay, I've found it in v7 drawing-wand.c.
draw.c function DrawBoundingRectangles() suggests the string should be two numbers separated by comma or "x".
draw.c function DrawBoundingRectangles() suggests the string should be two numbers separated by comma or "x".
snibgo's IM pages: im.snibgo.com
Re: DrawSetDensity example
It's also in ImageMagick 6 since at least 6.9.2-0
I've tried using it with numbers separated by either x or a comma. Trying to render the drawing wand into an image, using the example code below, gives an error "ThrowWandException 11 non-conforming drawing primitive definition `density' @ error/draw.c/DrawImage/3169"
For the record I'm just trying to add it to the PHP Imagick extension, so would like to be able to describe what it does for the manual, as well as be able to write a test for it.
I've tried using it with numbers separated by either x or a comma. Trying to render the drawing wand into an image, using the example code below, gives an error "ThrowWandException 11 non-conforming drawing primitive definition `density' @ error/draw.c/DrawImage/3169"
For the record I'm just trying to add it to the PHP Imagick extension, so would like to be able to describe what it does for the manual, as well as be able to write a test for it.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wand/MagickWand.h>
void ThrowWandException(MagickWand *wand) {
char *description;
ExceptionType severity;
description = MagickGetException(wand, &severity);
(void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
description=(char *) MagickRelinquishMemory(description);
exit(-1);
}
PixelWand *makePixelWand(char *string) {
PixelWand *pixel_wand;
pixel_wand = NewPixelWand();
if (PixelSetColor (pixel_wand, string) == MagickFalse) {
printf("Failed to set color");
exit(-1);
}
return pixel_wand;
}
int main(int argc,char **argv)
{
DrawingWand *drawing_wand;
MagickWand *magick_wand;
PixelWand *background_color_wand;
MagickBooleanType status;
MagickWandGenesis();
drawing_wand = NewDrawingWand();
//DrawSetDensity(drawing_wand,"200x200");
DrawSetDensity(drawing_wand,"200,200");
magick_wand = NewMagickWand();
background_color_wand = makePixelWand("red");
MagickNewImage(magick_wand, 500, 500, background_color_wand);
DrawRectangle(drawing_wand, 100, 100, 400, 400);
status = MagickDrawImage(magick_wand, drawing_wand);
if (status == MagickFalse) {
ThrowWandException(magick_wand);
}
MagickWriteImages(magick_wand, "./output/setDensity.png", MagickTrue);
MagickWandTerminus();
return (0);
}
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: DrawSetDensity example
Ah, that explains it. My v6 source is v6.9.0-0. As far as I can see (in v7 source), it is used only in draw.c DrawBoundingRectangles(), which "is only useful for developers debugging the rendering algorithm".
But a developer might comment.
But a developer might comment.
snibgo's IM pages: im.snibgo.com