Magick++  7.0.7
Convert, Edit, Or Compose Bitmap Images
Options.cpp
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2014-2016
5 //
6 // Implementation of Options
7 //
8 // A wrapper around DrawInfo, ImageInfo, and QuantizeInfo
9 //
10 
11 #define MAGICKCORE_IMPLEMENTATION 1
12 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
13 
14 #include "Magick++/Include.h"
15 #include <string>
16 #include <string.h>
17 #include <stdlib.h>
18 #include <math.h>
19 
20 #include "Magick++/Options.h"
21 #include "Magick++/Functions.h"
22 #include "Magick++/Exception.h"
23 
24 #define MagickPI 3.14159265358979323846264338327950288419716939937510
25 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
26 
28  : _imageInfo(static_cast<ImageInfo*>(AcquireMagickMemory(
29  sizeof(ImageInfo)))),
30  _quantizeInfo(static_cast<QuantizeInfo*>(AcquireMagickMemory(
31  sizeof(QuantizeInfo)))),
32  _drawInfo(static_cast<DrawInfo*>(AcquireMagickMemory(sizeof(DrawInfo)))),
33  _quiet(false)
34 {
35  // Initialize image info with defaults
36  GetImageInfo(_imageInfo);
37 
38  // Initialize quantization info
39  GetQuantizeInfo(_quantizeInfo);
40 
41  // Initialize drawing info
42  GetDrawInfo(_imageInfo,_drawInfo);
43 }
44 
46  : _imageInfo(CloneImageInfo(options_._imageInfo)),
47  _quantizeInfo(CloneQuantizeInfo(options_._quantizeInfo)),
48  _drawInfo(CloneDrawInfo(_imageInfo,options_._drawInfo)),
49  _quiet(options_._quiet)
50 {
51 }
52 
54 {
55  // Destroy image info
56  _imageInfo=DestroyImageInfo(_imageInfo);
57 
58  // Destroy quantization info
59  _quantizeInfo=DestroyQuantizeInfo(_quantizeInfo);
60 
61  // Destroy drawing info
62  _drawInfo=DestroyDrawInfo(_drawInfo);
63 }
64 
65 void Magick::Options::adjoin(const bool flag_)
66 {
67  _imageInfo->adjoin=static_cast<MagickBooleanType>(
68  flag_ ? MagickTrue : MagickFalse);
69 }
70 
71 bool Magick::Options::adjoin(void) const
72 {
73  return(static_cast<bool>(_imageInfo->adjoin));
74 }
75 
76 void Magick::Options::matteColor(const Color &matteColor_)
77 {
78  _imageInfo->matte_color=matteColor_;
79 }
80 
82 {
83  return(Magick::Color(_imageInfo->matte_color));
84 }
85 
87 {
88  _imageInfo->background_color=color_;
89 }
90 
92 {
93  return(Color(_imageInfo->background_color));
94 }
95 
96 void Magick::Options::backgroundTexture(const std::string &backgroundTexture_)
97 {
98  if (backgroundTexture_.length() == 0)
99  _imageInfo->texture=(char *) RelinquishMagickMemory(_imageInfo->texture);
100  else
101  Magick::CloneString(&_imageInfo->texture,backgroundTexture_);
102 }
103 
104 std::string Magick::Options::backgroundTexture(void) const
105 {
106  if (_imageInfo->texture)
107  return(std::string(_imageInfo->texture));
108  else
109  return(std::string());
110 }
111 
113 {
114  _imageInfo->border_color=color_;
115  _drawInfo->border_color=color_;
116 }
117 
119 {
120  return(Color(_imageInfo->border_color));
121 }
122 
123 void Magick::Options::boxColor(const Color &boxColor_)
124 {
125  _drawInfo->undercolor=boxColor_;
126 }
127 
129 {
130  return(Color(_drawInfo->undercolor));
131 }
132 
133 void Magick::Options::colorspaceType(const ColorspaceType colorspace_)
134 {
135  _imageInfo->colorspace=colorspace_;
136 }
137 
138 Magick::ColorspaceType Magick::Options::colorspaceType(void) const
139 {
140  return(static_cast<Magick::ColorspaceType>(_imageInfo->colorspace));
141 }
142 
143 void Magick::Options::compressType(const CompressionType compressType_)
144 {
145  _imageInfo->compression=compressType_;
146 }
147 
148 Magick::CompressionType Magick::Options::compressType(void) const
149 {
150  return(static_cast<Magick::CompressionType>(_imageInfo->compression));
151 }
152 
153 void Magick::Options::colorFuzz(const double fuzz_)
154 {
155  _imageInfo->fuzz=fuzz_;
156 }
157 
158 double Magick::Options::colorFuzz(void) const
159 {
160  return(_imageInfo->fuzz);
161 }
162 
163 void Magick::Options::debug(const bool flag_)
164 {
165  if (flag_)
166  SetLogEventMask("All");
167  else
168  SetLogEventMask("None");
169 }
170 
171 bool Magick::Options::debug(void) const
172 {
173  if (IsEventLogging())
174  return(true);
175  return(false);
176 }
177 
178 void Magick::Options::density(const Point &density_)
179 {
180  if (!density_.isValid())
181  _imageInfo->density=(char *) RelinquishMagickMemory(_imageInfo->density);
182  else
183  CloneString(&_imageInfo->density,density_);
184 }
185 
187 {
188  if (_imageInfo->density)
189  return(Point(_imageInfo->density));
190 
191  return(Point());
192 }
193 
194 void Magick::Options::depth(const size_t depth_)
195 {
196  _imageInfo->depth=depth_;
197 }
198 
199 size_t Magick::Options::depth(void) const
200 {
201  return(_imageInfo->depth);
202 }
203 
204 void Magick::Options::endian(const Magick::EndianType endian_)
205 {
206  _imageInfo->endian=endian_;
207 }
208 
209 Magick::EndianType Magick::Options::endian(void) const
210 {
211  return(_imageInfo->endian);
212 }
213 
214 void Magick::Options::file(FILE *file_)
215 {
216  SetImageInfoFile(_imageInfo,file_);
217 }
218 
219 FILE *Magick::Options::file(void) const
220 {
221  return(GetImageInfoFile(_imageInfo));
222 }
223 
224 void Magick::Options::fileName(const std::string &fileName_)
225 {
226  fileName_.copy(_imageInfo->filename,MagickPathExtent-1);
227  if (fileName_.length() > MagickPathExtent-1)
228  _imageInfo->filename[MagickPathExtent-1]=0;
229  else
230  _imageInfo->filename[fileName_.length()]=0;
231 }
232 
233 std::string Magick::Options::fileName(void) const
234 {
235  return(std::string(_imageInfo->filename));
236 }
237 
238 void Magick::Options::fillColor(const Color &fillColor_)
239 {
240  _drawInfo->fill=fillColor_;
241  if (fillColor_ == Color())
242  fillPattern((const MagickCore::Image*) NULL);
243  setOption("fill",fillColor_);
244 }
245 
247 {
248  return(_drawInfo->fill);
249 }
250 
252 {
253  if (_drawInfo->fill_pattern)
254  _drawInfo->fill_pattern=DestroyImageList(_drawInfo->fill_pattern);
255 
256  if (fillPattern_)
257  {
259  _drawInfo->fill_pattern=CloneImage(const_cast<MagickCore::Image*>(
260  fillPattern_),0,0,static_cast<MagickBooleanType>(MagickTrue),
261  exceptionInfo);
262  ThrowPPException(_quiet);
263  }
264 }
265 
267 {
268  return(_drawInfo->fill_pattern);
269 }
270 
271 void Magick::Options::fillRule(const FillRule &fillRule_)
272 {
273  _drawInfo->fill_rule=fillRule_;
274 }
275 
276 Magick::FillRule Magick::Options::fillRule(void) const
277 {
278  return(_drawInfo->fill_rule);
279 }
280 
281 void Magick::Options::font(const std::string &font_)
282 {
283  if (font_.length() == 0)
284  {
285  _imageInfo->font=(char *) RelinquishMagickMemory(_imageInfo->font);
286  _drawInfo->font=(char *) RelinquishMagickMemory(_drawInfo->font);
287  }
288  else
289  {
290  Magick::CloneString(&_imageInfo->font,font_);
291  Magick::CloneString(&_drawInfo->font,font_);
292  }
293 }
294 
295 std::string Magick::Options::font(void) const
296 {
297  if (_imageInfo->font)
298  return(std::string(_imageInfo->font));
299 
300  return(std::string());
301 }
302 
303 void Magick::Options::fontFamily(const std::string &family_)
304 {
305  if (family_.length() == 0)
306  {
307  _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->font);
308  DestroyString(RemoveImageOption(imageInfo(),"family"));
309  }
310  else
311  {
312  Magick::CloneString(&_drawInfo->family,family_);
313  (void) SetImageOption(imageInfo(),"family",family_.c_str());
314  }
315 }
316 
317 std::string Magick::Options::fontFamily(void) const
318 {
319  if (_drawInfo->family)
320  return(std::string(_drawInfo->family));
321 
322  return(std::string());
323 }
324 
325 void Magick::Options::fontPointsize(const double pointSize_)
326 {
327  _imageInfo->pointsize=pointSize_;
328  _drawInfo->pointsize=pointSize_;
329 }
330 
332 {
333  return(_imageInfo->pointsize);
334 }
335 
336 void Magick::Options::fontStyle(const StyleType style_)
337 {
338  _drawInfo->style=style_;
339  (void) SetImageOption(_imageInfo,"style",CommandOptionToMnemonic(
340  MagickStyleOptions,(ssize_t) style_));
341 }
342 
343 Magick::StyleType Magick::Options::fontStyle(void) const
344 {
345  return(_drawInfo->style);
346 }
347 
348 void Magick::Options::fontWeight(const size_t weight_)
349 {
350  _drawInfo->weight=weight_;
351  setOption("weight",(double) weight_);
352 }
353 
354 size_t Magick::Options::fontWeight(void) const
355 {
356  return(_drawInfo->weight);
357 }
358 
359 std::string Magick::Options::format(void) const
360 {
361  const MagickInfo
362  *magick_info=0;
363 
365  if (*_imageInfo->magick != '\0' )
366  magick_info = GetMagickInfo(_imageInfo->magick,exceptionInfo);
367  ThrowPPException(_quiet);
368 
369  if ((magick_info != 0) && (*magick_info->description != '\0'))
370  return(std::string( magick_info->description));
371 
372  return(std::string());
373 }
374 
375 void Magick::Options::interlaceType(const InterlaceType interlace_)
376 {
377  _imageInfo->interlace=interlace_;
378 }
379 
380 Magick::InterlaceType Magick::Options::interlaceType(void) const
381 {
382  return(static_cast<Magick::InterlaceType>(_imageInfo->interlace));
383 }
384 
385 void Magick::Options::magick(const std::string &magick_)
386 {
387  if (magick_.empty())
388  {
389  _imageInfo->magick[0] = '\0';
390  return;
391  }
392 
393  FormatLocaleString(_imageInfo->filename,MagickPathExtent,"%.1024s:",
394  magick_.c_str());
396  SetImageInfo(_imageInfo,1,exceptionInfo);
397  if ( _imageInfo->magick[0] == '\0' )
398  throwExceptionExplicit(MagickCore::OptionError,"Unrecognized image format",
399  magick_.c_str());
400  ThrowPPException(_quiet);
401 }
402 
403 std::string Magick::Options::magick(void) const
404 {
405  if ( _imageInfo->magick[0] != '\0' )
406  return(std::string(_imageInfo->magick));
407 
408  return(std::string());
409 }
410 
411 void Magick::Options::monochrome(const bool monochromeFlag_)
412 {
413  _imageInfo->monochrome=(MagickBooleanType) monochromeFlag_;
414 }
415 
417 {
418  return(static_cast<bool>(_imageInfo->monochrome));
419 }
420 
421 void Magick::Options::page(const Geometry &pageSize_)
422 {
423  if (!pageSize_.isValid())
424  _imageInfo->page=(char *) RelinquishMagickMemory(_imageInfo->page);
425  else
426  Magick::CloneString(&_imageInfo->page,pageSize_);
427 }
428 
430 {
431  if (_imageInfo->page)
432  return(Geometry(_imageInfo->page));
433 
434  return(Geometry());
435 }
436 
437 void Magick::Options::quality(const size_t quality_)
438 {
439  _imageInfo->quality=quality_;
440 }
441 
442 size_t Magick::Options::quality(void) const
443 {
444  return(_imageInfo->quality);
445 }
446 
447 void Magick::Options::quantizeColors(const size_t colors_)
448 {
449  _quantizeInfo->number_colors=colors_;
450 }
451 
453 {
454  return(_quantizeInfo->number_colors);
455 }
456 
457 void Magick::Options::quantizeColorSpace(const ColorspaceType colorSpace_)
458 {
459  _quantizeInfo->colorspace=colorSpace_;
460 }
461 
462 Magick::ColorspaceType Magick::Options::quantizeColorSpace(void) const
463 {
464  return(static_cast<Magick::ColorspaceType>(_quantizeInfo->colorspace));
465 }
466 
467 void Magick::Options::quantizeDither(const bool ditherFlag_)
468 {
469  _imageInfo->dither=(MagickBooleanType) ditherFlag_;
470  _quantizeInfo->dither_method=ditherFlag_ ? RiemersmaDitherMethod :
471  NoDitherMethod;
472 }
473 
475 {
476  return(static_cast<bool>(_imageInfo->dither));
477 }
478 
479 void Magick::Options::quantizeDitherMethod(const DitherMethod ditherMethod_)
480 {
481  _quantizeInfo->dither_method=ditherMethod_;
482 }
483 
484 MagickCore::DitherMethod Magick::Options::quantizeDitherMethod(void) const
485 {
486  return(_quantizeInfo->dither_method);
487 }
488 
489 void Magick::Options::quantizeTreeDepth(const size_t treeDepth_)
490 {
491  _quantizeInfo->tree_depth=treeDepth_;
492 }
493 
495 {
496  return(_quantizeInfo->tree_depth);
497 }
498 
499 void Magick::Options::quiet(const bool quiet_)
500 {
501  _quiet=quiet_;
502 }
503 
504 bool Magick::Options::quiet(void) const
505 {
506  return(_quiet);
507 }
508 
509 void Magick::Options::resolutionUnits(const ResolutionType resolutionUnits_)
510 {
511  _imageInfo->units=resolutionUnits_;
512 }
513 
514 Magick::ResolutionType Magick::Options::resolutionUnits(void) const
515 {
516  return(_imageInfo->units);
517 }
518 
519 void Magick::Options::samplingFactor(const std::string &samplingFactor_)
520 {
521  if (samplingFactor_.length() == 0)
522  _imageInfo->sampling_factor=(char *) RelinquishMagickMemory(
523  _imageInfo->sampling_factor);
524  else
525  Magick::CloneString(&_imageInfo->sampling_factor,samplingFactor_);
526 }
527 
528 std::string Magick::Options::samplingFactor(void) const
529 {
530  if (_imageInfo->sampling_factor)
531  return(std::string(_imageInfo->sampling_factor));
532 
533  return(std::string());
534 }
535 
536 void Magick::Options::size(const Geometry &geometry_)
537 {
538  _imageInfo->size=(char *) RelinquishMagickMemory(_imageInfo->size);
539 
540  if (geometry_.isValid())
541  Magick::CloneString(&_imageInfo->size,geometry_);
542 }
543 
545 {
546  if (_imageInfo->size)
547  return(Geometry(_imageInfo->size));
548 
549  return(Geometry());
550 }
551 
552 void Magick::Options::strokeAntiAlias(const bool flag_)
553 {
554  flag_ ? _drawInfo->stroke_antialias=MagickTrue :
555  _drawInfo->stroke_antialias=MagickFalse;
556 }
557 
559 {
560  return(_drawInfo->stroke_antialias != 0 ? true : false);
561 }
562 
563 void Magick::Options::strokeColor(const Color &strokeColor_)
564 {
565  _drawInfo->stroke=strokeColor_;
566  if (strokeColor_ == Color())
567  strokePattern((const MagickCore::Image*) NULL);
568  setOption("stroke",strokeColor_);
569 }
570 
572 {
573  return(_drawInfo->stroke);
574 }
575 
576 void Magick::Options::strokeDashArray(const double *strokeDashArray_)
577 {
578  _drawInfo->dash_pattern=(double *) RelinquishMagickMemory(
579  _drawInfo->dash_pattern);
580 
581  if(strokeDashArray_)
582  {
583  size_t
584  x;
585  // Count elements in dash array
586  for (x=0; strokeDashArray_[x]; x++) ;
587  // Allocate elements
588  _drawInfo->dash_pattern=static_cast<double*>(AcquireMagickMemory((x+1)*
589  sizeof(double)));
590  if (!_drawInfo->dash_pattern)
591  throwExceptionExplicit(MagickCore::ResourceLimitError,
592  "Unable to allocate dash-pattern memory");
593  // Copy elements
594  memcpy(_drawInfo->dash_pattern,strokeDashArray_,(x+1)*sizeof(double));
595  _drawInfo->dash_pattern[x]=0.0;
596  }
597 }
598 
599 const double *Magick::Options::strokeDashArray(void) const
600 {
601  return(_drawInfo->dash_pattern);
602 }
603 
604 void Magick::Options::strokeDashOffset(const double strokeDashOffset_)
605 {
606  _drawInfo->dash_offset=strokeDashOffset_;
607 }
608 
610 {
611  return(_drawInfo->dash_offset);
612 }
613 
614 void Magick::Options::strokeLineCap(const LineCap lineCap_)
615 {
616  _drawInfo->linecap=lineCap_;
617 }
618 
619 Magick::LineCap Magick::Options::strokeLineCap(void) const
620 {
621  return(_drawInfo->linecap);
622 }
623 
624 void Magick::Options::strokeLineJoin(const LineJoin lineJoin_)
625 {
626  _drawInfo->linejoin=lineJoin_;
627 }
628 
629 Magick::LineJoin Magick::Options::strokeLineJoin(void) const
630 {
631  return(_drawInfo->linejoin);
632 }
633 
634 void Magick::Options::strokeMiterLimit(const size_t miterLimit_)
635 {
636  _drawInfo->miterlimit=miterLimit_;
637 }
638 
640 {
641  return(_drawInfo->miterlimit);
642 }
643 
645 {
646  if (_drawInfo->stroke_pattern)
647  _drawInfo->stroke_pattern=DestroyImageList(_drawInfo->stroke_pattern);
648 
649  if (strokePattern_)
650  {
652  _drawInfo->stroke_pattern=CloneImage(const_cast<MagickCore::Image*>(
653  strokePattern_),0,0,MagickTrue,exceptionInfo);
654  ThrowPPException(_quiet);
655  }
656 }
657 
659 {
660  return(_drawInfo->stroke_pattern);
661 }
662 
663 void Magick::Options::strokeWidth(const double strokeWidth_)
664 {
665  _drawInfo->stroke_width=strokeWidth_;
666  setOption("strokewidth",strokeWidth_);
667 }
668 
670 {
671  return(_drawInfo->stroke_width);
672 }
673 
674 void Magick::Options::subImage(const size_t subImage_)
675 {
676  _imageInfo->scene=subImage_;
677 }
678 
679 size_t Magick::Options::subImage(void) const
680 {
681  return(_imageInfo->scene);
682 }
683 
684 void Magick::Options::subRange(const size_t subRange_)
685 {
686  _imageInfo->number_scenes=subRange_;
687 }
688 
689 size_t Magick::Options::subRange(void) const
690 {
691  return(_imageInfo->number_scenes);
692 }
693 
694 void Magick::Options::textAntiAlias(const bool flag_)
695 {
696  _drawInfo->text_antialias=static_cast<MagickBooleanType>(
697  flag_ ? MagickTrue : MagickFalse);
698 }
699 
701 {
702  return(static_cast<bool>(_drawInfo->text_antialias));
703 }
704 
705 void Magick::Options::textDirection(const DirectionType direction_)
706 {
707  _drawInfo->direction=direction_;
708  (void) SetImageOption(_imageInfo,"direction",CommandOptionToMnemonic(
709  MagickDirectionOptions,(ssize_t) direction_));
710 }
711 
712 Magick::DirectionType Magick::Options::textDirection() const
713 {
714  return(_drawInfo->direction);
715 }
716 
717 void Magick::Options::textEncoding(const std::string &encoding_)
718 {
719  CloneString(&_drawInfo->encoding,encoding_.c_str());
720  (void) SetImageOption(imageInfo(),"encoding",encoding_.c_str());
721 }
722 
723 std::string Magick::Options::textEncoding(void) const
724 {
725  if (_drawInfo->encoding && *_drawInfo->encoding)
726  return(std::string(_drawInfo->encoding));
727 
728  return(std::string());
729 }
730 
731 void Magick::Options::textGravity(const GravityType gravity_)
732 {
733  _drawInfo->gravity=gravity_;
734  (void) SetImageOption(_imageInfo,"gravity",CommandOptionToMnemonic(
735  MagickGravityOptions,(ssize_t) gravity_));
736 }
737 
738 Magick::GravityType Magick::Options::textGravity() const
739 {
740  return(_drawInfo->gravity);
741 }
742 
743 void Magick::Options::textInterlineSpacing(const double spacing_)
744 {
745  _drawInfo->interline_spacing=spacing_;
746  setOption("interline-spacing",spacing_);
747 }
748 
750 {
751  return(_drawInfo->interline_spacing);
752 }
753 
754 void Magick::Options::textInterwordSpacing(const double spacing_)
755 {
756  _drawInfo->interword_spacing=spacing_;
757  setOption("interword-spacing",spacing_);
758 }
759 
761 {
762  return(_drawInfo->interword_spacing);
763 }
764 
765 void Magick::Options::textKerning(const double kerning_)
766 {
767  _drawInfo->kerning=kerning_;
768  setOption("kerning",kerning_);
769 }
770 
772 {
773  return(_drawInfo->kerning);
774 }
775 
776 void Magick::Options::textUnderColor(const Color &undercolor_)
777 {
778  _drawInfo->undercolor=undercolor_;
779  setOption("undercolor",undercolor_);
780 }
781 
783 {
784  return(_drawInfo->undercolor);
785 }
786 
787 void Magick::Options::transformOrigin(const double tx_,const double ty_)
788 {
789  AffineMatrix
790  affine,
791  current=_drawInfo->affine;
792 
793  affine.sx=1.0;
794  affine.rx=0.0;
795  affine.ry=0.0;
796  affine.sy=1.0;
797  affine.tx=0.0;
798  affine.ty=0.0;
799 
800  affine.tx=tx_;
801  affine.ty=ty_;
802 
803  _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
804  _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
805  _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
806  _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
807  _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
808  _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
809 }
810 
812 {
813  _drawInfo->affine.sx=1.0;
814  _drawInfo->affine.rx=0.0;
815  _drawInfo->affine.ry=0.0;
816  _drawInfo->affine.sy=1.0;
817  _drawInfo->affine.tx=0.0;
818  _drawInfo->affine.ty=0.0;
819 }
820 
821 void Magick::Options::transformRotation(const double angle_)
822 {
823  AffineMatrix
824  affine,
825  current=_drawInfo->affine;
826 
827  affine.sx=1.0;
828  affine.rx=0.0;
829  affine.ry=0.0;
830  affine.sy=1.0;
831  affine.tx=0.0;
832  affine.ty=0.0;
833 
834  affine.sx=cos(DegreesToRadians(fmod(angle_,360.0)));
835  affine.rx=(-sin(DegreesToRadians(fmod(angle_,360.0))));
836  affine.ry=sin(DegreesToRadians(fmod(angle_,360.0)));
837  affine.sy=cos(DegreesToRadians(fmod(angle_,360.0)));
838 
839  _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
840  _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
841  _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
842  _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
843  _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
844  _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
845 }
846 
847 void Magick::Options::transformScale(const double sx_,const double sy_)
848 {
849  AffineMatrix
850  affine,
851  current=_drawInfo->affine;
852 
853  affine.sx=1.0;
854  affine.rx=0.0;
855  affine.ry=0.0;
856  affine.sy=1.0;
857  affine.tx=0.0;
858  affine.ty=0.0;
859 
860  affine.sx=sx_;
861  affine.sy=sy_;
862 
863  _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
864  _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
865  _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
866  _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
867  _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
868  _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
869 }
870 
871 void Magick::Options::transformSkewX(const double skewx_)
872 {
873  AffineMatrix
874  affine,
875  current=_drawInfo->affine;
876 
877  affine.sx=1.0;
878  affine.rx=0.0;
879  affine.ry=0.0;
880  affine.sy=1.0;
881  affine.tx=0.0;
882  affine.ty=0.0;
883 
884  affine.sx=1.0;
885  affine.ry=tan(DegreesToRadians(fmod(skewx_,360.0)));
886  affine.sy=1.0;
887 
888  _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
889  _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
890  _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
891  _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
892  _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
893  _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
894 }
895 
896 void Magick::Options::transformSkewY(const double skewy_)
897 {
898  AffineMatrix
899  affine,
900  current=_drawInfo->affine;
901 
902  affine.sx=1.0;
903  affine.rx=0.0;
904  affine.ry=0.0;
905  affine.sy=1.0;
906  affine.tx=0.0;
907  affine.ty=0.0;
908 
909  affine.sx=1.0;
910  affine.rx=tan(DegreesToRadians(fmod(skewy_,360.0)));
911  affine.sy=1.0;
912 
913  _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
914  _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
915  _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
916  _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
917  _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
918  _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
919 }
920 
921 void Magick::Options::type(const ImageType type_)
922 {
923  _imageInfo->type=type_;
924 }
925 
926 Magick::ImageType Magick::Options::type(void) const
927 {
928  return(_imageInfo->type);
929 }
930 
931 void Magick::Options::verbose(const bool verboseFlag_)
932 {
933  _imageInfo->verbose=(MagickBooleanType) verboseFlag_;
934 }
935 
936 bool Magick::Options::verbose(void) const
937 {
938  return(static_cast<bool>(_imageInfo->verbose));
939 }
940 
941 void Magick::Options::x11Display(const std::string &display_)
942 {
943  if (display_.length() == 0)
944  _imageInfo->server_name=(char *) RelinquishMagickMemory(
945  _imageInfo->server_name);
946  else
947  Magick::CloneString(&_imageInfo->server_name,display_);
948 }
949 
950 std::string Magick::Options::x11Display(void) const
951 {
952  if (_imageInfo->server_name)
953  return(std::string( _imageInfo->server_name));
954 
955  return(std::string());
956 }
957 
958 MagickCore::DrawInfo *Magick::Options::drawInfo(void)
959 {
960  return(_drawInfo);
961 }
962 
963 MagickCore::ImageInfo *Magick::Options::imageInfo(void)
964 {
965  return(_imageInfo);
966 }
967 
968 MagickCore::QuantizeInfo *Magick::Options::quantizeInfo(void)
969 {
970  return(_quantizeInfo);
971 }
972 
973 Magick::Options::Options(const MagickCore::ImageInfo* imageInfo_,
974  const MagickCore::QuantizeInfo* quantizeInfo_,
975  const MagickCore::DrawInfo* drawInfo_)
976 : _imageInfo((MagickCore::ImageInfo* ) NULL),
977  _quantizeInfo((MagickCore::QuantizeInfo* ) NULL),
978  _drawInfo((MagickCore::DrawInfo* ) NULL),
979  _quiet(false)
980 {
981  _imageInfo=CloneImageInfo(imageInfo_);
982  _quantizeInfo=CloneQuantizeInfo(quantizeInfo_);
983  _drawInfo=CloneDrawInfo(imageInfo_,drawInfo_);
984 }
985 
986 void Magick::Options::setOption(const char *name,const Color &value_)
987 {
988  std::string
989  option;
990 
991  option=value_;
992  (void) SetImageOption(imageInfo(),name,option.c_str());
993 }
994 
995 void Magick::Options::setOption(const char *name,const double value_)
996 {
997  char
998  option[MagickPathExtent];
999 
1000  (void) FormatLocaleString(option,MagickPathExtent,"%.20g",value_);
1001  (void) SetImageOption(_imageInfo,name,option);
1002 }
1003 
class MagickPPExport Color
Definition: Color.h:16
size_t fontWeight(void) const
Definition: Options.cpp:354
double strokeDashOffset(void) const
Definition: Options.cpp:609
double textKerning(void) const
Definition: Options.cpp:771
EndianType endian(void) const
Definition: Options.cpp:209
Color borderColor(void) const
Definition: Options.cpp:118
#define DegreesToRadians(x)
Definition: Options.cpp:25
MagickCore::QuantizeInfo * quantizeInfo(void)
Definition: Options.cpp:968
size_t quality(void) const
Definition: Options.cpp:442
std::string font(void) const
Definition: Options.cpp:295
Geometry page(void) const
Definition: Options.cpp:429
bool quantizeDither(void) const
Definition: Options.cpp:474
MagickCore::ImageInfo * imageInfo(void)
Definition: Options.cpp:963
bool isValid() const
Definition: Geometry.cpp:696
Point density(void) const
Definition: Options.cpp:186
void transformReset(void)
Definition: Options.cpp:811
void transformRotation(const double angle_)
Definition: Options.cpp:821
double colorFuzz(void) const
Definition: Options.cpp:158
DirectionType textDirection() const
Definition: Options.cpp:712
size_t subRange(void) const
Definition: Options.cpp:689
size_t strokeMiterLimit(void) const
Definition: Options.cpp:639
std::string fileName(void) const
Definition: Options.cpp:233
Color backgroundColor(void) const
Definition: Options.cpp:91
std::string fontFamily(void) const
Definition: Options.cpp:317
std::string format(void) const
Definition: Options.cpp:359
bool adjoin(void) const
Definition: Options.cpp:71
std::string textEncoding(void) const
Definition: Options.cpp:723
void transformScale(const double sx_, const double sy_)
Definition: Options.cpp:847
const MagickCore::Image * fillPattern(void) const
Definition: Options.cpp:266
Color strokeColor(void) const
Definition: Options.cpp:571
bool quiet(void) const
Definition: Options.cpp:504
class MagickPPExport Geometry
Definition: Geometry.h:19
const double * strokeDashArray(void) const
Definition: Options.cpp:599
size_t subImage(void) const
Definition: Options.cpp:679
Color matteColor(void) const
Definition: Options.cpp:81
Color fillColor(void) const
Definition: Options.cpp:246
size_t quantizeTreeDepth(void) const
Definition: Options.cpp:494
ColorspaceType colorspaceType(void) const
Definition: Options.cpp:138
size_t quantizeColors(void) const
Definition: Options.cpp:452
FillRule fillRule(void) const
Definition: Options.cpp:276
LineCap strokeLineCap(void) const
Definition: Options.cpp:619
MagickPPExport void throwExceptionExplicit(const MagickCore::ExceptionType severity_, const char *reason_, const char *description_=(char *) NULL)
Definition: Exception.cpp:807
std::string magick(void) const
Definition: Options.cpp:403
double textInterlineSpacing(void) const
Definition: Options.cpp:749
bool strokeAntiAlias(void) const
Definition: Options.cpp:558
CompressionType compressType(void) const
Definition: Options.cpp:148
ImageType type(void) const
Definition: Options.cpp:926
FILE * file(void) const
Definition: Options.cpp:219
#define ThrowPPException(quiet)
Definition: Include.h:1533
Color textUnderColor(void) const
Definition: Options.cpp:782
std::string x11Display(void) const
Definition: Options.cpp:950
double textInterwordSpacing(void) const
Definition: Options.cpp:760
GravityType textGravity() const
Definition: Options.cpp:738
std::string samplingFactor(void) const
Definition: Options.cpp:528
DitherMethod quantizeDitherMethod(void) const
Definition: Options.cpp:484
std::string backgroundTexture(void) const
Definition: Options.cpp:104
bool verbose(void) const
Definition: Options.cpp:936
const MagickCore::Image * strokePattern(void) const
Definition: Options.cpp:658
LineJoin strokeLineJoin(void) const
Definition: Options.cpp:629
void transformOrigin(const double tx_, const double ty_)
Definition: Options.cpp:787
void transformSkewY(const double skewy_)
Definition: Options.cpp:896
void transformSkewX(const double skewx_)
Definition: Options.cpp:871
bool monochrome(void) const
Definition: Options.cpp:416
MagickCore::DrawInfo * drawInfo(void)
Definition: Options.cpp:958
Geometry size(void) const
Definition: Options.cpp:544
MagickPPExport void CloneString(char **destination_, const std::string &source_)
Definition: Functions.cpp:23
class MagickPPExport Point
Definition: Geometry.h:198
class MagickPPExport Image
Definition: Drawable.h:720
InterlaceType interlaceType(void) const
Definition: Options.cpp:380
double strokeWidth(void) const
Definition: Options.cpp:669
#define GetPPException
Definition: Include.h:1514
StyleType fontStyle(void) const
Definition: Options.cpp:343
void isValid(bool isValid_)
Definition: Geometry.cpp:367
size_t depth(void) const
Definition: Options.cpp:199
double fontPointsize(void) const
Definition: Options.cpp:331
Color boxColor(void) const
Definition: Options.cpp:128
bool debug(void) const
Definition: Options.cpp:171
ColorspaceType quantizeColorSpace(void) const
Definition: Options.cpp:462
bool textAntiAlias(void) const
Definition: Options.cpp:700
ResolutionType resolutionUnits(void) const
Definition: Options.cpp:514