Page 1 of 1

drawsetresolution and drawgetresolution

Posted: 2010-11-21T16:07:40-07:00
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

Re: drawsetresolution and drawgetresolution

Posted: 2010-11-21T16:18:05-07:00
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);
}

Re: drawsetresolution and drawgetresolution

Posted: 2010-11-21T16:32:35-07:00
by magick
We'll add DrawSetFontResolution()/DrawGetFontResolution() in the next point release of ImageMagick. Thanks.