blob: 5bae6c6d7231302bc4820513ea5c7d034541a919 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001// This may look like C code, but it is really -*- C++ -*-
2//
3// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4//
5// Implementation of Options
6//
7// A wrapper around DrawInfo, ImageInfo, and QuantizeInfo
8//
9
10#define MAGICKCORE_IMPLEMENTATION 1
11#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12
13#include "Magick++/Include.h"
14#include <string>
15#include <string.h>
16#include <stdlib.h>
17#include <math.h>
18#include "Magick++/Options.h"
19#include "Magick++/Functions.h"
20#include "Magick++/Exception.h"
21
22#define MagickPI 3.14159265358979323846264338327950288419716939937510
23#define DegreesToRadians(x) (MagickPI*(x)/180.0)
24
25// Constructor
26Magick::Options::Options( void )
27 : _imageInfo(static_cast<ImageInfo*>(AcquireMagickMemory(sizeof(ImageInfo)))),
28 _quantizeInfo(static_cast<QuantizeInfo*>(AcquireMagickMemory(sizeof(QuantizeInfo)))),
29 _drawInfo(static_cast<DrawInfo*>(AcquireMagickMemory( sizeof(DrawInfo))))
30{
31 // Initialize image info with defaults
32 GetImageInfo( _imageInfo );
33
34 // Initialize quantization info
35 GetQuantizeInfo( _quantizeInfo );
36
37 // Initialize drawing info
38 GetDrawInfo( _imageInfo, _drawInfo );
39}
40
41// Copy constructor
42Magick::Options::Options( const Magick::Options& options_ )
43 : _imageInfo(CloneImageInfo( options_._imageInfo )),
44 _quantizeInfo(CloneQuantizeInfo(options_._quantizeInfo)),
45 _drawInfo(CloneDrawInfo(_imageInfo, options_._drawInfo))
46{
47}
48
49// Construct using raw structures
50Magick::Options::Options( const MagickCore::ImageInfo* imageInfo_,
51 const MagickCore::QuantizeInfo* quantizeInfo_,
52 const MagickCore::DrawInfo* drawInfo_ )
53: _imageInfo(0),
54 _quantizeInfo(0),
55 _drawInfo(0)
56{
57 _imageInfo = CloneImageInfo(imageInfo_);
58 _quantizeInfo = CloneQuantizeInfo(quantizeInfo_);
59 _drawInfo = CloneDrawInfo(imageInfo_,drawInfo_);
60}
61
62// Destructor
63Magick::Options::~Options()
64{
65 // Destroy image info
66 _imageInfo =DestroyImageInfo( _imageInfo );
67 _imageInfo=0;
68
69 // Destroy quantization info
70 _quantizeInfo =DestroyQuantizeInfo( _quantizeInfo );
71 _quantizeInfo=0;
72
73 // Destroy drawing info
74 _drawInfo =DestroyDrawInfo( _drawInfo );
75 _drawInfo=0;
76}
77
78/*
79 * Methods for setting image attributes
80 *
81 */
82
83// Anti-alias Postscript and TrueType fonts (default true)
84void Magick::Options::antiAlias( bool flag_ )
85{
86 _drawInfo->text_antialias = static_cast<MagickBooleanType>
87 (flag_ ? MagickTrue : MagickFalse);
88}
89bool Magick::Options::antiAlias( void ) const
90{
91 return static_cast<bool>(_drawInfo->text_antialias);
92}
93
94void Magick::Options::adjoin ( bool flag_ )
95{
96 _imageInfo->adjoin = static_cast<MagickBooleanType>
97 (flag_ ? MagickTrue : MagickFalse);
98}
99bool Magick::Options::adjoin ( void ) const
100{
101 return static_cast<bool>(_imageInfo->adjoin);
102}
103
104void Magick::Options::backgroundColor ( const Magick::Color &color_ )
105{
106 _imageInfo->background_color = color_;
107}
108Magick::Color Magick::Options::backgroundColor ( void ) const
109{
110 return Magick::Color( _imageInfo->background_color );
111}
112
113void Magick::Options::backgroundTexture ( const std::string &backgroundTexture_ )
114{
115 if ( backgroundTexture_.length() == 0 )
116 _imageInfo->texture=(char *) RelinquishMagickMemory(_imageInfo->texture);
117 else
118 Magick::CloneString( &_imageInfo->texture, backgroundTexture_ );
119}
120std::string Magick::Options::backgroundTexture ( void ) const
121{
122 if ( _imageInfo->texture )
123 return std::string( _imageInfo->texture );
124 else
125 return std::string();
126}
127
128void Magick::Options::borderColor ( const Color &color_ )
129{
130 _imageInfo->border_color = color_;
131 _drawInfo->border_color = color_;
132}
133Magick::Color Magick::Options::borderColor ( void ) const
134{
135 return Magick::Color( _imageInfo->border_color );
136}
137
138// Text bounding-box base color
139void Magick::Options::boxColor ( const Magick::Color &boxColor_ )
140{
141 _drawInfo->undercolor = boxColor_;
142}
143Magick::Color Magick::Options::boxColor ( void ) const
144{
145 return Magick::Color( _drawInfo->undercolor );
146}
147
148void Magick::Options::colorspaceType ( Magick::ColorspaceType colorspace_ )
149{
150 _imageInfo->colorspace = colorspace_;
151}
152Magick::ColorspaceType Magick::Options::colorspaceType ( void ) const
153{
154 return static_cast<Magick::ColorspaceType>(_imageInfo->colorspace);
155}
156
157void Magick::Options::compressType ( CompressionType compressType_ )
158{
159 _imageInfo->compression = compressType_;
160}
161Magick::CompressionType Magick::Options::compressType ( void ) const
162{
163 return static_cast<Magick::CompressionType>(_imageInfo->compression);
164}
165
166void Magick::Options::colorFuzz ( double fuzz_ )
167{
168 _imageInfo->fuzz = fuzz_;
169}
170double Magick::Options::colorFuzz ( void ) const
171{
172 return _imageInfo->fuzz;
173}
174
175// Enable printing of debug messages from ImageMagick
176void Magick::Options::debug ( bool flag_ )
177{
178 if(flag_)
179 {
180 SetLogEventMask("All");
181 }
182 else
183 {
184 SetLogEventMask("None");
185 }
186}
187bool Magick::Options::debug ( void ) const
188{
189 if( IsEventLogging() )
190 {
191 return true;
192 }
193 return false;
194}
195
196void Magick::Options::density ( const Magick::Geometry &density_ )
197{
198 if ( !density_.isValid() )
199 _imageInfo->density=(char *) RelinquishMagickMemory(_imageInfo->density);
200 else
201 Magick::CloneString( &_imageInfo->density, density_ );
202}
203Magick::Geometry Magick::Options::density ( void ) const
204{
205 if ( _imageInfo->density )
206 return Geometry( _imageInfo->density );
207
208 return Geometry();
209}
210
211void Magick::Options::depth ( unsigned int depth_ )
212{
213 _imageInfo->depth = depth_;
214}
215unsigned int Magick::Options::depth ( void ) const
216{
217 return _imageInfo->depth;
218}
219
220// Endianness (little like Intel or big like SPARC) for image
221// formats which support endian-specific options.
222void Magick::Options::endian ( Magick::EndianType endian_ )
223{
224 _imageInfo->endian = endian_;
225}
226Magick::EndianType Magick::Options::endian ( void ) const
227{
228 return _imageInfo->endian;
229}
230
231void Magick::Options::fileName ( const std::string &fileName_ )
232{
233 fileName_.copy( _imageInfo->filename, MaxTextExtent-1 );
234 _imageInfo->filename[ fileName_.length() ] = 0;
235}
236std::string Magick::Options::fileName ( void ) const
237{
238 return std::string( _imageInfo->filename );
239}
240
241// Color to use when drawing inside an object
242void Magick::Options::fillColor ( const Magick::Color &fillColor_ )
243{
244 _drawInfo->fill = fillColor_;
245 if (fillColor_ == Magick::Color())
246 fillPattern((const MagickCore::Image*) NULL);
247}
248Magick::Color Magick::Options::fillColor ( void ) const
249{
250 return _drawInfo->fill;
251}
252// Pattern image to use when filling objects
253void Magick::Options::fillPattern ( const MagickCore::Image *fillPattern_ )
254{
255 if ( _drawInfo->fill_pattern )
256 {
257 DestroyImageList( _drawInfo->fill_pattern );
258 _drawInfo->fill_pattern = 0;
259 }
260 if ( fillPattern_ )
261 {
262 ExceptionInfo exceptionInfo;
263 GetExceptionInfo( &exceptionInfo );
264 _drawInfo->fill_pattern =
265 CloneImage( const_cast<MagickCore::Image*>(fillPattern_),
266 0,
267 0,
268 static_cast<MagickBooleanType>(MagickTrue),
269 &exceptionInfo );
270 throwException( exceptionInfo );
271 (void) DestroyExceptionInfo( &exceptionInfo );
272 }
273}
274const MagickCore::Image* Magick::Options::fillPattern ( void ) const
275{
276 return _drawInfo->fill_pattern;
277}
278
279// Rule to use when filling drawn objects
280void Magick::Options::fillRule ( const Magick::FillRule &fillRule_ )
281{
282 _drawInfo->fill_rule = fillRule_;
283}
284Magick::FillRule Magick::Options::fillRule ( void ) const
285{
286 return _drawInfo->fill_rule;
287}
288
289void Magick::Options::font ( const std::string &font_ )
290{
291 if ( font_.length() == 0 )
292 {
293 _imageInfo->font=(char *) RelinquishMagickMemory(_imageInfo->font);
294 _drawInfo->font=(char *) RelinquishMagickMemory(_drawInfo->font);
295 }
296 else
297 {
298 Magick::CloneString( &_imageInfo->font, font_ );
299 Magick::CloneString( &_drawInfo->font, font_ );
300 }
301}
302std::string Magick::Options::font ( void ) const
303{
304 if ( _imageInfo->font )
305 return std::string( _imageInfo->font );
306
307 return std::string();
308}
309
310void Magick::Options::fontPointsize ( double pointSize_ )
311{
312 _imageInfo->pointsize = pointSize_;
313 _drawInfo->pointsize = pointSize_;
314}
315double Magick::Options::fontPointsize ( void ) const
316{
317 return _imageInfo->pointsize;
318}
319
320std::string Magick::Options::format ( void ) const
321{
322 ExceptionInfo exception;
323
324 const MagickInfo * magick_info = 0;
325 GetExceptionInfo(&exception);
326 if ( *_imageInfo->magick != '\0' )
327 magick_info = GetMagickInfo( _imageInfo->magick , &exception);
328 throwException( exception );
329 (void) DestroyExceptionInfo( &exception );
330
331 if (( magick_info != 0 ) &&
332 ( *magick_info->description != '\0' ))
333 return std::string( magick_info->description );
334
335 return std::string();
336}
337
338void Magick::Options::interlaceType ( Magick::InterlaceType interlace_ )
339{
340 _imageInfo->interlace = interlace_;
341}
342Magick::InterlaceType Magick::Options::interlaceType ( void ) const
343{
344 return static_cast<Magick::InterlaceType>(_imageInfo->interlace);
345}
346
347void Magick::Options::magick ( const std::string &magick_ )
348{
349 ExceptionInfo exception;
350
351 FormatMagickString( _imageInfo->filename, MaxTextExtent, "%.1024s:", magick_.c_str() );
352 GetExceptionInfo(&exception);
353 SetImageInfo( _imageInfo, MagickTrue, &exception);
354 if ( *_imageInfo->magick == '\0' )
355 throwExceptionExplicit( OptionWarning,
356 "Unrecognized image format",
357 magick_.c_str() );
358 (void) DestroyExceptionInfo( &exception );
359}
360std::string Magick::Options::magick ( void ) const
361{
362 if ( _imageInfo->magick && *_imageInfo->magick )
363 return std::string( _imageInfo->magick );
364
365 return std::string();
366}
367
368void Magick::Options::matteColor ( const Magick::Color &matteColor_ )
369{
370 _imageInfo->matte_color = matteColor_;
371}
372Magick::Color Magick::Options::matteColor ( void ) const
373{
374 return Magick::Color( _imageInfo->matte_color );
375}
376
377void Magick::Options::monochrome ( bool monochromeFlag_ )
378{
379 _imageInfo->monochrome = (MagickBooleanType) monochromeFlag_;
380}
381bool Magick::Options::monochrome ( void ) const
382{
383 return static_cast<bool>(_imageInfo->monochrome);
384}
385
386void Magick::Options::page ( const Magick::Geometry &pageSize_ )
387{
388 if ( !pageSize_.isValid() )
389 _imageInfo->page=(char *) RelinquishMagickMemory(_imageInfo->page);
390 else
391 Magick::CloneString( &_imageInfo->page, pageSize_ );
392}
393Magick::Geometry Magick::Options::page ( void ) const
394{
395 if ( _imageInfo->page )
396 return Geometry( _imageInfo->page );
397
398 return Geometry();
399}
400
401void Magick::Options::quality ( unsigned int quality_ )
402{
403 _imageInfo->quality = quality_;
404}
405unsigned int Magick::Options::quality ( void ) const
406{
407 return _imageInfo->quality;
408}
409
410void Magick::Options::quantizeColors ( unsigned int colors_ )
411{
412 _quantizeInfo->number_colors = colors_;
413}
414unsigned int Magick::Options::quantizeColors ( void ) const
415{
416 return _quantizeInfo->number_colors;
417}
418
419void Magick::Options::quantizeColorSpace ( Magick::ColorspaceType colorSpace_ )
420{
421 _quantizeInfo->colorspace = colorSpace_;
422}
423Magick::ColorspaceType Magick::Options::quantizeColorSpace ( void ) const
424{
425 return static_cast<Magick::ColorspaceType>(_quantizeInfo->colorspace);
426}
427
428void Magick::Options::quantizeDither ( bool ditherFlag_ )
429{
430 _imageInfo->dither = (MagickBooleanType) ditherFlag_;
431 _quantizeInfo->dither = (MagickBooleanType) ditherFlag_;
432}
433bool Magick::Options::quantizeDither ( void ) const
434{
435 return static_cast<bool>(_imageInfo->dither);
436}
437
438void Magick::Options::quantizeTreeDepth ( unsigned int treeDepth_ )
439{
440 _quantizeInfo->tree_depth = treeDepth_;
441}
442unsigned int Magick::Options::quantizeTreeDepth ( void ) const
443{
444 return _quantizeInfo->tree_depth;
445}
446
447void Magick::Options::resolutionUnits ( Magick::ResolutionType resolutionUnits_ )
448{
449 _imageInfo->units = resolutionUnits_;
450}
451Magick::ResolutionType Magick::Options::resolutionUnits ( void ) const
452{
453 return static_cast<Magick::ResolutionType>(_imageInfo->units);
454}
455
456void Magick::Options::samplingFactor ( const std::string &samplingFactor_ )
457{
458 if ( samplingFactor_.length() == 0 )
459 _imageInfo->sampling_factor=(char *) RelinquishMagickMemory(_imageInfo->sampling_factor);
460 else
461 Magick::CloneString( &_imageInfo->sampling_factor, samplingFactor_ );
462}
463std::string Magick::Options::samplingFactor ( void ) const
464{
465 if ( _imageInfo->sampling_factor )
466 return std::string( _imageInfo->sampling_factor );
467
468 return std::string();
469}
470
471void Magick::Options::size ( const Geometry &geometry_ )
472{
473 _imageInfo->size=(char *) RelinquishMagickMemory(_imageInfo->size);
474
475 if ( geometry_.isValid() )
476 Magick::CloneString( &_imageInfo->size, geometry_ );
477}
478Magick::Geometry Magick::Options::size ( void ) const
479{
480 if ( _imageInfo->size )
481 return Geometry( _imageInfo->size );
482
483 return Geometry();
484}
485
486void Magick::Options::strokeAntiAlias( bool flag_ )
487{
488 flag_ ? _drawInfo->stroke_antialias=MagickTrue : _drawInfo->stroke_antialias=MagickFalse;
489}
490bool Magick::Options::strokeAntiAlias( void ) const
491{
492 return (_drawInfo->stroke_antialias != 0 ? true : false);
493}
494
495// Color to use when drawing object outlines
496void Magick::Options::strokeColor ( const Magick::Color &strokeColor_ )
497{
498 _drawInfo->stroke = strokeColor_;
499}
500Magick::Color Magick::Options::strokeColor ( void ) const
501{
502 return _drawInfo->stroke;
503}
504
505void Magick::Options::strokeDashArray ( const double* strokeDashArray_ )
506{
507 _drawInfo->dash_pattern=(double *)
508 RelinquishMagickMemory(_drawInfo->dash_pattern);
509
510 if(strokeDashArray_)
511 {
512 // Count elements in dash array
513 unsigned int x;
514 for (x=0; strokeDashArray_[x]; x++) ;
515 // Allocate elements
516 _drawInfo->dash_pattern =
517 static_cast<double*>(AcquireMagickMemory((x+1)*sizeof(double)));
518 // Copy elements
519 memcpy(_drawInfo->dash_pattern,strokeDashArray_,
520 (x+1)*sizeof(double));
521 }
522}
523const double* Magick::Options::strokeDashArray ( void ) const
524{
525 return _drawInfo->dash_pattern;
526}
527
528void Magick::Options::strokeDashOffset ( double strokeDashOffset_ )
529{
530 _drawInfo->dash_offset = strokeDashOffset_;
531}
532double Magick::Options::strokeDashOffset ( void ) const
533{
534 return _drawInfo->dash_offset;
535}
536
537// Specify the shape to be used at the end of open subpaths when they
538// are stroked. Values of LineCap are ButtCap, RoundCap, and
539// SquareCap.
540void Magick::Options::strokeLineCap ( Magick::LineCap lineCap_ )
541{
542 _drawInfo->linecap = lineCap_;
543}
544Magick::LineCap Magick::Options::strokeLineCap ( void ) const
545{
546 return _drawInfo->linecap;
547}
548
549// Specify the shape to be used at the corners of paths (or other
550// vector shapes) when they are stroked.
551void Magick::Options::strokeLineJoin ( Magick::LineJoin lineJoin_ )
552{
553 _drawInfo->linejoin = lineJoin_;
554}
555Magick::LineJoin Magick::Options::strokeLineJoin ( void ) const
556{
557 return _drawInfo->linejoin;
558}
559
560// miterLimit for drawing lines, circles, ellipses, etc.
561void Magick::Options::strokeMiterLimit ( unsigned int miterLimit_ )
562{
563 _drawInfo->miterlimit = miterLimit_;
564}
565unsigned int Magick::Options::strokeMiterLimit ( void ) const
566{
567 return _drawInfo->miterlimit;
568}
569
570// Pattern image to use for stroked outlines
571void Magick::Options::strokePattern ( const MagickCore::Image *strokePattern_ )
572{
573 if ( _drawInfo->stroke_pattern )
574 {
575 DestroyImageList( _drawInfo->stroke_pattern );
576 _drawInfo->stroke_pattern = 0;
577 }
578
579 if ( strokePattern_ )
580 {
581 ExceptionInfo exceptionInfo;
582 GetExceptionInfo( &exceptionInfo );
583 _drawInfo->stroke_pattern =
584 CloneImage( const_cast<MagickCore::Image*>(strokePattern_),
585 0,
586 0,
587 MagickTrue,
588 &exceptionInfo );
589 throwException( exceptionInfo );
590 (void) DestroyExceptionInfo( &exceptionInfo );
591 }
592}
593const MagickCore::Image* Magick::Options::strokePattern ( void ) const
594{
595 return _drawInfo->stroke_pattern;
596}
597
598// Stroke width for drawing lines, circles, ellipses, etc.
599void Magick::Options::strokeWidth ( double strokeWidth_ )
600{
601 _drawInfo->stroke_width = strokeWidth_;
602}
603double Magick::Options::strokeWidth ( void ) const
604{
605 return _drawInfo->stroke_width;
606}
607
608void Magick::Options::subImage ( unsigned int subImage_ )
609{
610 _imageInfo->scene = subImage_;
611}
612unsigned int Magick::Options::subImage ( void ) const
613{
614 return _imageInfo->scene;
615}
616
617void Magick::Options::subRange ( unsigned int subRange_ )
618{
619 _imageInfo->number_scenes = subRange_;
620}
621unsigned int Magick::Options::subRange ( void ) const
622{
623 return _imageInfo->number_scenes;
624}
625
626// Annotation text encoding (e.g. "UTF-16")
627void Magick::Options::textEncoding ( const std::string &encoding_ )
628{
629 CloneString(&_drawInfo->encoding, encoding_.c_str());
630}
631std::string Magick::Options::textEncoding ( void ) const
632{
633 if ( _drawInfo->encoding && *_drawInfo->encoding )
634 return std::string( _drawInfo->encoding );
635
636 return std::string();
637}
638
639void Magick::Options::tileName ( const std::string &tileName_ )
640{
641 if ( tileName_.length() == 0 )
642 _imageInfo->tile=(char *) RelinquishMagickMemory(_imageInfo->tile);
643 else
644 Magick::CloneString( &_imageInfo->tile, tileName_ );
645}
646std::string Magick::Options::tileName ( void ) const
647{
648 if ( _imageInfo->tile )
649 return std::string( _imageInfo->tile );
650 return std::string();
651}
652
653// Image representation type
654void Magick::Options::type ( const Magick::ImageType type_ )
655{
656 _imageInfo->type = type_;
657}
658Magick::ImageType Magick::Options::type ( void ) const
659{
660 return _imageInfo->type;
661}
662
663// Origin of coordinate system to use when annotating with text or drawing
664void Magick::Options::transformOrigin ( double tx_, double ty_ )
665{
666 AffineMatrix current = _drawInfo->affine;
667 AffineMatrix affine;
668 affine.sx=1.0;
669 affine.rx=0.0;
670 affine.ry=0.0;
671 affine.sy=1.0;
672 affine.tx=0.0;
673 affine.ty=0.0;
674
675 affine.tx = tx_;
676 affine.ty = ty_;
677
678 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
679 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
680 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
681 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
682 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
683 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
684}
685
686// Reset transformation parameters to default
687void Magick::Options::transformReset ( void )
688{
689 _drawInfo->affine.sx=1.0;
690 _drawInfo->affine.rx=0.0;
691 _drawInfo->affine.ry=0.0;
692 _drawInfo->affine.sy=1.0;
693 _drawInfo->affine.tx=0.0;
694 _drawInfo->affine.ty=0.0;
695}
696
697// Rotation to use when annotating with text or drawing
698void Magick::Options::transformRotation ( double angle_ )
699{
700 AffineMatrix current = _drawInfo->affine;
701 AffineMatrix affine;
702 affine.sx=1.0;
703 affine.rx=0.0;
704 affine.ry=0.0;
705 affine.sy=1.0;
706 affine.tx=0.0;
707 affine.ty=0.0;
708
709 affine.sx=cos(DegreesToRadians(fmod(angle_,360.0)));
710 affine.rx=(-sin(DegreesToRadians(fmod(angle_,360.0))));
711 affine.ry=sin(DegreesToRadians(fmod(angle_,360.0)));
712 affine.sy=cos(DegreesToRadians(fmod(angle_,360.0)));
713
714 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
715 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
716 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
717 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
718 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
719 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
720}
721
722// Scale to use when annotating with text or drawing
723void Magick::Options::transformScale ( double sx_, double sy_ )
724{
725 AffineMatrix current = _drawInfo->affine;
726 AffineMatrix affine;
727 affine.sx=1.0;
728 affine.rx=0.0;
729 affine.ry=0.0;
730 affine.sy=1.0;
731 affine.tx=0.0;
732 affine.ty=0.0;
733
734 affine.sx = sx_;
735 affine.sy = sy_;
736
737 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
738 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
739 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
740 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
741 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
742 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
743}
744
745// Skew to use in X axis when annotating with text or drawing
746void Magick::Options::transformSkewX ( double skewx_ )
747{
748 AffineMatrix current = _drawInfo->affine;
749 AffineMatrix affine;
750 affine.sx=1.0;
751 affine.rx=0.0;
752 affine.ry=0.0;
753 affine.sy=1.0;
754 affine.tx=0.0;
755 affine.ty=0.0;
756
757 affine.sx=1.0;
758 affine.ry=tan(DegreesToRadians(fmod(skewx_,360.0)));
759 affine.sy=1.0;
760
761 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
762 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
763 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
764 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
765 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
766 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
767}
768
769// Skew to use in Y axis when annotating with text or drawing
770void Magick::Options::transformSkewY ( double skewy_ )
771{
772 AffineMatrix current = _drawInfo->affine;
773 AffineMatrix affine;
774 affine.sx=1.0;
775 affine.rx=0.0;
776 affine.ry=0.0;
777 affine.sy=1.0;
778 affine.tx=0.0;
779 affine.ty=0.0;
780
781 affine.sx=1.0;
782 affine.rx=tan(DegreesToRadians(fmod(skewy_,360.0)));
783 affine.sy=1.0;
784
785 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
786 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
787 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
788 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
789 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
790 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
791}
792
793void Magick::Options::verbose ( bool verboseFlag_ )
794{
795 _imageInfo->verbose = (MagickBooleanType) verboseFlag_;
796}
797bool Magick::Options::verbose ( void ) const
798{
799 return static_cast<bool>(_imageInfo->verbose);
800}
801
802void Magick::Options::virtualPixelMethod ( VirtualPixelMethod virtual_pixel_method_ )
803{
804 _imageInfo->virtual_pixel_method = virtual_pixel_method_;
805}
806Magick::VirtualPixelMethod Magick::Options::virtualPixelMethod ( void ) const
807{
808 return static_cast<Magick::VirtualPixelMethod>(_imageInfo->virtual_pixel_method);
809}
810
811void Magick::Options::view ( const std::string &view_ )
812{
813 if ( view_.length() == 0 )
814 _imageInfo->view=(char *) RelinquishMagickMemory(_imageInfo->view);
815 else
816 Magick::CloneString( &_imageInfo->view, view_ );
817}
818std::string Magick::Options::view ( void ) const
819{
820 if ( _imageInfo->view )
821 return std::string( _imageInfo->view );
822
823 return std::string();
824}
825
826void Magick::Options::x11Display ( const std::string &display_ )
827{
828 if ( display_.length() == 0 )
829 _imageInfo->server_name=(char *) RelinquishMagickMemory(_imageInfo->server_name);
830 else
831 Magick::CloneString( &_imageInfo->server_name, display_ );
832}
833std::string Magick::Options::x11Display ( void ) const
834{
835 if ( _imageInfo->server_name )
836 return std::string( _imageInfo->server_name );
837
838 return std::string();
839}
840
841//
842// Internal implementation methods. Please do not use.
843//
844
845MagickCore::DrawInfo * Magick::Options::drawInfo( void )
846{
847 return _drawInfo;
848}
849
850MagickCore::ImageInfo * Magick::Options::imageInfo( void )
851{
852 return _imageInfo;
853}
854
855MagickCore::QuantizeInfo * Magick::Options::quantizeInfo( void )
856{
857 return _quantizeInfo;
858}