Coverage Report

Created: 2026-04-01 07:49

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