drawsetresolution and drawgetresolution

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
George

drawsetresolution and drawgetresolution

Post by George »

Relating to viewtopic.php?t=17486&p=65761 i think it'd make more sense if a drawsetresolution and drawgetresolution to set and retrieve the density was added to the api. This would allow much simpler access to the density property.

To set the resolution:

Code: Select all

WandExport MagickBooleanType DrawSetResolution(DrawingWand *wand,  const double x_resolution,const double y_resolution)
{
  char
    density[MaxTextExtent];

    assert(wand != (DrawingWand *) NULL);
  assert(wand->signature == WandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);

  (void) FormatMagickString(density,MaxTextExtent,"%gx%g",x_resolution, y_resolution);
  (void) CloneString(&CurrentContext->density,density);
  return(MagickTrue);
}
and to retrieve the resolution, I'm not sure of a "magick" way to split the x and y vars

Code: Select all

WandExport MagickBooleanType DrawGetResolution(DrawingWand *wand, double *x,double *y)
{
  assert(wand != (DrawingWand *) NULL);
  assert(wand->signature == WandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
 
  // density needs to be split here unless there's a helper function?
  // not sure how to extract first resolution part *x=;
  // as above *y=;

  return(MagickTrue);
}
thanks
mkoppanen
Posts: 309
Joined: 2007-06-09T07:06:32-07:00

Re: drawsetresolution and drawgetresolution

Post by mkoppanen »

For the getting something like the following should work:

Code: Select all


WandExport MagickBooleanType DrawGetResolution(DrawingWand *wand, double *x,double *y)
{
  assert(wand != (DrawingWand *) NULL);
  assert(wand->signature == WandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
  
  if (draw_info->density != (char *)NULL) {
    MagickStatusType
      flags;

    GeometryInfo
      geometry_info;

    flags=ParseGeometry(draw_info->density, &geometry_info);
    *x=geometry_info.rho;
    *y=geometry_info.sigma;

    if ((flags & SigmaValue) == 0)
      *y=*x;
      
    return(MagickTrue);  
  }
  return(MagickFalse);
}
Mikko Koppanen
My blog: http://valokuva.org
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: drawsetresolution and drawgetresolution

Post by magick »

We'll add DrawSetFontResolution()/DrawGetFontResolution() in the next point release of ImageMagick. Thanks.
Post Reply