Magick++ 7.1.0

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