Coverage Report

Created: 2025-08-11 08:01

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