Coverage Report

Created: 2026-09-13 07:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/imagemagick/Magick++/lib/Image.cpp
Line
Count
Source
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 @ 1999 ImageMagick Studio LLC, a non-profit organization
6
// dedicated to making software imaging solutions freely available.
7
//
8
// Implementation of Image
9
//
10
11
#define MAGICKCORE_IMPLEMENTATION  1
12
#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
13
14
#include "Magick++/Include.h"
15
#include "Magick++/Image.h"
16
#include "Magick++/Functions.h"
17
#include "Magick++/Pixels.h"
18
#include "Magick++/Options.h"
19
#include "Magick++/ImageRef.h"
20
21
using namespace std;
22
23
0
#define MagickPI     3.1415926535897932384626433832795028841971693993751058209749445923078164062
24
0
#define DegreesToRadians(x)  (MagickPI*(x)/180.0)
25
1.02M
#define ThrowImageException ThrowPPException(quiet())
26
27
MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
28
MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
29
MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
30
31
MagickPPExport int Magick::operator == (const Magick::Image &left_,
32
  const Magick::Image &right_)
33
0
{
34
  // If image pixels and signature are the same, then the image is identical
35
0
  return((left_.rows() == right_.rows()) &&
36
0
    (left_.columns() == right_.columns()) &&
37
0
    (left_.signature() == right_.signature()));
38
0
}
39
40
MagickPPExport int Magick::operator != (const Magick::Image &left_,
41
  const Magick::Image &right_)
42
0
{
43
0
  return(!(left_ == right_));
44
0
}
45
46
MagickPPExport int Magick::operator > (const Magick::Image &left_,
47
  const Magick::Image &right_)
48
0
{
49
0
  return(!(left_ < right_) && (left_ != right_));
50
0
}
51
52
MagickPPExport int Magick::operator < (const Magick::Image &left_,
53
  const Magick::Image &right_)
54
0
{
55
  // If image pixels are less, then image is smaller
56
0
  return((left_.rows() * left_.columns()) <
57
0
    (right_.rows() * right_.columns()));
58
0
}
59
60
MagickPPExport int Magick::operator >= (const Magick::Image &left_,
61
  const Magick::Image &right_)
62
0
{
63
0
  return((left_ > right_) || (left_ == right_));
64
0
}
65
66
MagickPPExport int Magick::operator <= (const Magick::Image &left_,
67
  const Magick::Image &right_)
68
0
{
69
0
  return((left_ < right_) || ( left_ == right_));
70
0
}
71
72
Magick::Image::Image(void)
73
597k
  : _imgRef(new ImageRef)
74
597k
{
75
597k
}
76
77
Magick::Image::Image(const Blob &blob_)
78
0
  : _imgRef(new ImageRef)
79
0
{
80
0
  try
81
0
  {
82
    // Initialize, Allocate and Read images
83
0
    quiet(true);
84
0
    read(blob_);
85
0
    quiet(false);
86
0
  }
87
0
  catch (const Error&)
88
0
  {
89
    // Release resources
90
0
    delete _imgRef;
91
0
    throw;
92
0
  }
93
0
}
94
95
Magick::Image::Image(const Blob &blob_,const Geometry &size_)
96
0
  : _imgRef(new ImageRef)
97
0
{
98
0
  try
99
0
  {
100
    // Read from Blob
101
0
    quiet(true);
102
0
    read(blob_, size_);
103
0
    quiet(false);
104
0
  }
105
0
  catch(const Error&)
106
0
  {
107
    // Release resources
108
0
    delete _imgRef;
109
0
    throw;
110
0
  }
111
0
}
112
113
Magick::Image::Image(const Blob &blob_,const Geometry &size_,
114
  const size_t depth_)
115
0
  : _imgRef(new ImageRef)
116
0
{
117
0
  try
118
0
  {
119
    // Read from Blob
120
0
    quiet(true);
121
0
    read(blob_,size_,depth_);
122
0
    quiet(false);
123
0
  }
124
0
  catch(const Error&)
125
0
  {
126
    // Release resources
127
0
    delete _imgRef;
128
0
    throw;
129
0
  }
130
0
}
131
132
Magick::Image::Image(const Blob &blob_,const Geometry &size_,
133
  const size_t depth_,const std::string &magick_)
134
0
  : _imgRef(new ImageRef)
135
0
{
136
0
  try
137
0
  {
138
    // Read from Blob
139
0
    quiet(true);
140
0
    read(blob_,size_,depth_,magick_);
141
0
    quiet(false);
142
0
  }
143
0
  catch(const Error&)
144
0
  {
145
    // Release resources
146
0
    delete _imgRef;
147
0
    throw;
148
0
  }
149
0
}
150
151
Magick::Image::Image(const Blob &blob_,const Geometry &size_,
152
  const std::string &magick_)
153
0
  : _imgRef(new ImageRef)
154
0
{
155
0
  try
156
0
  {
157
    // Read from Blob
158
0
    quiet(true);
159
0
    read(blob_,size_,magick_);
160
0
    quiet(false);
161
0
  }
162
0
  catch(const Error&)
163
0
  {
164
    // Release resources
165
0
    delete _imgRef;
166
0
    throw;
167
0
  }
168
0
}
169
170
Magick::Image::Image(const Geometry &size_,const Color &color_)
171
4.02k
  : _imgRef(new ImageRef)
172
4.02k
{
173
  // xc: prefix specifies an X11 color string
174
4.02k
  std::string imageSpec("xc:");
175
4.02k
  imageSpec+=color_;
176
177
4.02k
  try
178
4.02k
  {
179
4.02k
    quiet(true);
180
    // Set image size
181
4.02k
    size(size_);
182
183
    // Initialize, Allocate and Read images
184
4.02k
    read(imageSpec);
185
4.02k
    quiet(false);
186
4.02k
  }
187
4.02k
  catch(const Error&)
188
4.02k
  {
189
    // Release resources
190
0
    delete _imgRef;
191
0
    throw;
192
0
  }
193
4.02k
}
194
195
Magick::Image::Image(const Image &image_)
196
0
  : _imgRef(image_._imgRef)
197
0
{
198
0
  _imgRef->increase();
199
0
}
200
201
Magick::Image::Image(const Image &image_,const Geometry &geometry_)
202
0
  : _imgRef(new ImageRef)
203
0
{
204
0
  const RectangleInfo
205
0
    geometry=geometry_;
206
207
0
  OffsetInfo
208
0
    offset;
209
210
0
  MagickCore::Image
211
0
    *image;
212
213
0
  GetPPException;
214
0
  image=CloneImage(image_.constImage(),geometry_.width(),geometry_.height(),
215
0
    MagickTrue,exceptionInfo);
216
0
  replaceImage(image);
217
0
  _imgRef->options(new Options(*image_.constOptions()));
218
0
  offset.x=0;
219
0
  offset.y=0;
220
0
  (void) CopyImagePixels(image,image_.constImage(),&geometry,&offset,
221
0
    exceptionInfo);
222
0
  ThrowImageException;
223
0
}
224
225
Magick::Image::Image(const size_t width_,const size_t height_,
226
  const std::string &map_,const StorageType type_,const void *pixels_)
227
0
  : _imgRef(new ImageRef)
228
0
{
229
0
  try
230
0
  {
231
0
    quiet(true);
232
0
    read(width_,height_,map_.c_str(),type_,pixels_);
233
0
    quiet(false);
234
0
  }
235
0
  catch(const Error&)
236
0
  {
237
    // Release resources
238
0
    delete _imgRef;
239
0
    throw;
240
0
  }
241
0
}
242
243
Magick::Image::Image(const std::string &imageSpec_)
244
0
  : _imgRef(new ImageRef)
245
0
{
246
0
  try
247
0
  {
248
    // Initialize, Allocate and Read images
249
0
    quiet(true);
250
0
    read(imageSpec_);
251
0
    quiet(false);
252
0
  }
253
0
  catch(const Error&)
254
0
  {
255
    // Release resources
256
0
    delete _imgRef;
257
0
    throw;
258
0
  }
259
0
}
260
261
Magick::Image::~Image()
262
601k
{
263
601k
  try
264
601k
  {
265
601k
    if (_imgRef->decrease() == 0)
266
601k
      delete _imgRef;
267
601k
  }
268
601k
  catch(Magick::Exception&)
269
601k
  {
270
0
  }
271
272
601k
  _imgRef=(Magick::ImageRef *) NULL;
273
601k
}
274
275
Magick::Image& Magick::Image::operator=(const Magick::Image &image_)
276
0
{
277
0
  if (this != &image_)
278
0
    {
279
0
      image_._imgRef->increase();
280
0
      if (_imgRef->decrease() == 0)
281
0
        delete _imgRef;
282
283
      // Use new image reference
284
0
      _imgRef=image_._imgRef;
285
0
    }
286
0
  return(*this);
287
0
}
288
289
void Magick::Image::adjoin(const bool flag_)
290
0
{
291
0
  modifyImage();
292
0
  options()->adjoin(flag_);
293
0
}
294
295
bool Magick::Image::adjoin(void) const
296
0
{
297
0
  return(constOptions()->adjoin());
298
0
}
299
300
void Magick::Image::alpha(const bool alphaFlag_)
301
0
{
302
0
  modifyImage();
303
304
  // If matte channel is requested, but image doesn't already have a
305
  // matte channel, then create an opaque matte channel.  Likewise, if
306
  // the image already has a matte channel but a matte channel is not
307
  // desired, then set the matte channel to opaque.
308
0
  GetPPException;
309
0
  if (bool(alphaFlag_) != bool(constImage()->alpha_trait))
310
0
    SetImageAlpha(image(),OpaqueAlpha,exceptionInfo);
311
0
  ThrowImageException;
312
313
0
  image()->alpha_trait=alphaFlag_ ? BlendPixelTrait : UndefinedPixelTrait;
314
0
}
315
316
bool Magick::Image::alpha(void) const
317
0
{
318
0
  if (constImage()->alpha_trait == BlendPixelTrait)
319
0
    return(true);
320
0
  else
321
0
    return(false);
322
0
}
323
324
void Magick::Image::matteColor(const Color &matteColor_)
325
0
{
326
0
  modifyImage();
327
328
0
  if (matteColor_.isValid())
329
0
    {
330
0
      image()->matte_color=matteColor_;
331
0
      options()->matteColor(matteColor_);
332
0
    }
333
0
  else
334
0
    {
335
      // Set to default matte color
336
0
      Color tmpColor("#BDBDBD");
337
0
      image()->matte_color=tmpColor;
338
0
      options()->matteColor(tmpColor);
339
0
    }
340
0
}
341
342
Magick::Color Magick::Image::matteColor(void) const
343
0
{
344
0
  return(Color(constImage()->matte_color));
345
0
}
346
347
void Magick::Image::animationDelay(const size_t delay_)
348
0
{
349
0
  modifyImage();
350
0
  image()->delay=delay_;
351
0
}
352
353
size_t Magick::Image::animationDelay(void) const
354
0
{
355
0
  return(constImage()->delay);
356
0
}
357
358
void Magick::Image::animationIterations(const size_t iterations_)
359
0
{
360
0
  modifyImage();
361
0
  image()->iterations=iterations_;
362
0
}
363
364
size_t Magick::Image::animationIterations(void) const
365
0
{
366
0
  return(constImage()->iterations);
367
0
}
368
369
void Magick::Image::backgroundColor(const Color &backgroundColor_)
370
0
{
371
0
  modifyImage();
372
373
0
  if (backgroundColor_.isValid())
374
0
    image()->background_color=backgroundColor_;
375
0
  else
376
0
    image()->background_color=Color();
377
378
0
  options()->backgroundColor(backgroundColor_);
379
0
}
380
381
Magick::Color Magick::Image::backgroundColor(void) const
382
0
{
383
0
  return(constOptions()->backgroundColor());
384
0
}
385
386
void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
387
0
{
388
0
  modifyImage();
389
0
  options()->backgroundTexture(backgroundTexture_);
390
0
}
391
392
std::string Magick::Image::backgroundTexture(void) const
393
0
{
394
0
  return(constOptions()->backgroundTexture());
395
0
}
396
397
size_t Magick::Image::baseColumns(void) const
398
0
{
399
0
  return(constImage()->magick_columns);
400
0
}
401
402
std::string Magick::Image::baseFilename(void) const
403
0
{
404
0
  return(std::string(constImage()->magick_filename));
405
0
}
406
407
size_t Magick::Image::baseRows(void) const
408
0
{
409
0
  return(constImage()->magick_rows);
410
0
}
411
412
void Magick::Image::blackPointCompensation(const bool flag_)
413
0
{
414
0
  image()->black_point_compensation=(MagickBooleanType) flag_;
415
0
}
416
417
bool Magick::Image::blackPointCompensation(void) const
418
0
{
419
0
  return(static_cast<bool>(constImage()->black_point_compensation));
420
0
}
421
422
void Magick::Image::borderColor(const Color &borderColor_)
423
0
{
424
0
  modifyImage();
425
426
0
  if (borderColor_.isValid())
427
0
    image()->border_color=borderColor_;
428
0
  else
429
0
    image()->border_color=Color();
430
431
0
  options()->borderColor(borderColor_);
432
0
}
433
434
Magick::Color Magick::Image::borderColor(void) const
435
0
{
436
0
  return(constOptions()->borderColor());
437
0
}
438
439
Magick::Geometry Magick::Image::boundingBox(void) const
440
0
{
441
0
  RectangleInfo
442
0
    bbox;
443
444
0
  GetPPException;
445
0
  bbox=GetImageBoundingBox(constImage(),exceptionInfo);
446
0
  ThrowImageException;
447
0
  return(Geometry(bbox));
448
0
}
449
450
void Magick::Image::boxColor(const Color &boxColor_)
451
0
{
452
0
  modifyImage();
453
0
  options()->boxColor(boxColor_);
454
0
}
455
456
Magick::Color Magick::Image::boxColor(void) const
457
0
{
458
0
  return(constOptions()->boxColor());
459
0
}
460
461
void Magick::Image::channelDepth(const ChannelType channel_,
462
  const size_t depth_)
463
0
{
464
0
  modifyImage();
465
0
  GetPPException;
466
0
  GetAndSetPPChannelMask(channel_);
467
0
  SetImageDepth(image(),depth_,exceptionInfo);
468
0
  RestorePPChannelMask;
469
0
  ThrowImageException;
470
0
}
471
472
size_t Magick::Image::channelDepth(const ChannelType channel_)
473
0
{
474
0
  size_t
475
0
    channel_depth;
476
477
0
  GetPPException;
478
0
  GetAndSetPPChannelMask(channel_);
479
0
  channel_depth=GetImageDepth(constImage(),exceptionInfo);
480
0
  RestorePPChannelMask;
481
0
  ThrowImageException;
482
0
  return(channel_depth);
483
0
}
484
485
size_t Magick::Image::channels() const
486
0
{
487
0
  return(constImage()->number_channels);
488
0
}
489
490
void Magick::Image::classType(const ClassType class_)
491
0
{
492
0
  if (classType() == PseudoClass && class_ == DirectClass)
493
0
    {
494
      // Use SyncImage to synchronize the DirectClass pixels with the
495
      // color map and then set to DirectClass type.
496
0
      modifyImage();
497
0
      GetPPException;
498
0
      SyncImage(image(),exceptionInfo);
499
0
      ThrowImageException;
500
0
      image()->colormap=(PixelInfo *)RelinquishMagickMemory(image()->colormap);
501
0
      image()->storage_class=static_cast<MagickCore::ClassType>(DirectClass);
502
0
      return;
503
0
    }
504
505
0
  if (classType() == DirectClass && class_ == PseudoClass)
506
0
    {
507
      // Quantize to create PseudoClass color map
508
0
      modifyImage();
509
0
      quantizeColors(MaxColormapSize);
510
0
      quantize();
511
0
      image()->storage_class=static_cast<MagickCore::ClassType>(PseudoClass);
512
0
    }
513
0
}
514
515
Magick::ClassType Magick::Image::classType(void) const
516
0
{
517
0
  return static_cast<Magick::ClassType>(constImage()->storage_class);
518
0
}
519
520
void Magick::Image::colorFuzz(const double fuzz_)
521
0
{
522
0
  modifyImage();
523
0
  image()->fuzz=fuzz_;
524
0
  options()->colorFuzz(fuzz_);
525
0
}
526
527
double Magick::Image::colorFuzz(void) const
528
0
{
529
0
  return(constOptions()->colorFuzz());
530
0
}
531
532
void Magick::Image::colorMapSize(const size_t entries_)
533
0
{
534
0
  if (entries_ >MaxColormapSize)
535
0
    throwExceptionExplicit(MagickCore::OptionError,
536
0
      "Colormap entries must not exceed MaxColormapSize");
537
538
0
  modifyImage();
539
0
  GetPPException;
540
0
  (void) AcquireImageColormap(image(),entries_,exceptionInfo);
541
0
  ThrowImageException;
542
0
}
543
544
size_t Magick::Image::colorMapSize(void) const
545
0
{
546
0
  if (!constImage()->colormap)
547
0
    throwExceptionExplicit(MagickCore::OptionError,
548
0
      "Image does not contain a colormap");
549
550
0
  return(constImage()->colors);
551
0
}
552
553
void Magick::Image::colorSpace(const ColorspaceType colorSpace_)
554
0
{
555
0
  if (image()->colorspace == colorSpace_)
556
0
    return;
557
558
0
  modifyImage();
559
0
  GetPPException;
560
0
  TransformImageColorspace(image(),colorSpace_,exceptionInfo);
561
0
  ThrowImageException;
562
0
}
563
564
Magick::ColorspaceType Magick::Image::colorSpace(void) const
565
0
{
566
0
  return (constImage()->colorspace);
567
0
}
568
569
void Magick::Image::colorSpaceType(const ColorspaceType colorSpace_)
570
0
{
571
0
  modifyImage();
572
0
  GetPPException;
573
0
  SetImageColorspace(image(),colorSpace_,exceptionInfo);
574
0
  ThrowImageException;
575
0
  options()->colorspaceType(colorSpace_);
576
0
}
577
578
Magick::ColorspaceType Magick::Image::colorSpaceType(void) const
579
0
{
580
0
  return(constOptions()->colorspaceType());
581
0
}
582
583
size_t Magick::Image::columns(void) const
584
0
{
585
0
  return(constImage()->columns);
586
0
}
587
588
void Magick::Image::comment(const std::string &comment_)
589
0
{
590
0
  modifyImage();
591
0
  GetPPException;
592
0
  SetImageProperty(image(),"Comment",NULL,exceptionInfo);
593
0
  if (comment_.length() > 0)
594
0
    SetImageProperty(image(),"Comment",comment_.c_str(),exceptionInfo);
595
0
  ThrowImageException;
596
0
}
597
598
std::string Magick::Image::comment(void) const
599
0
{
600
0
  const char
601
0
    *value;
602
603
0
  GetPPException;
604
0
  value=GetImageProperty(constImage(),"Comment",exceptionInfo);
605
0
  ThrowImageException;
606
607
0
  if (value)
608
0
    return(std::string(value));
609
610
0
  return(std::string()); // Intentionally no exception
611
0
}
612
613
void Magick::Image::compose(const CompositeOperator compose_)
614
0
{
615
0
  image()->compose=compose_;
616
0
}
617
618
Magick::CompositeOperator Magick::Image::compose(void) const
619
0
{
620
0
  return(constImage()->compose);
621
0
}
622
623
void Magick::Image::compressType(const CompressionType compressType_)
624
0
{
625
0
  modifyImage();
626
0
  image()->compression=compressType_;
627
0
  options()->compressType(compressType_);
628
0
}
629
630
Magick::CompressionType Magick::Image::compressType(void) const
631
0
{
632
0
  return(constImage()->compression);
633
0
}
634
635
void Magick::Image::debug(const bool flag_)
636
0
{
637
0
  modifyImage();
638
0
  options()->debug(flag_);
639
0
}
640
641
bool Magick::Image::debug(void) const
642
0
{
643
0
  return(constOptions()->debug());
644
0
}
645
646
void Magick::Image::density(const Point &density_)
647
0
{
648
0
  modifyImage();
649
0
  options()->density(density_);
650
0
  if (density_.isValid())
651
0
    {
652
0
      image()->resolution.x=density_.x();
653
0
      if (density_.y() != 0.0)
654
0
        image()->resolution.y=density_.y();
655
0
      else
656
0
        image()->resolution.y=density_.x();
657
0
    }
658
0
  else
659
0
    {
660
      // Reset to default
661
0
      image()->resolution.x=0.0;
662
0
      image()->resolution.y=0.0;
663
0
    }
664
0
}
665
666
Magick::Point Magick::Image::density(void) const
667
0
{
668
0
  if (isValid())
669
0
    {
670
0
      double
671
0
        x_resolution=72,
672
0
        y_resolution=72;
673
674
0
      if (constImage()->resolution.x > 0.0)
675
0
        x_resolution=constImage()->resolution.x;
676
677
0
      if (constImage()->resolution.y > 0.0)
678
0
        y_resolution=constImage()->resolution.y;
679
680
0
      return(Point(x_resolution, y_resolution));
681
0
    }
682
683
0
  return(constOptions()->density());
684
0
}
685
686
void Magick::Image::depth(const size_t depth_)
687
0
{
688
0
  modifyImage();
689
0
  image()->depth=depth_;
690
0
  options()->depth(depth_);
691
0
}
692
693
size_t Magick::Image::depth(void) const
694
0
{
695
0
  return(constImage()->depth);
696
0
}
697
698
std::string Magick::Image::directory(void) const
699
0
{
700
0
  if (constImage()->directory)
701
0
    return(std::string(constImage()->directory));
702
703
0
  if (!quiet())
704
0
    throwExceptionExplicit(MagickCore::CorruptImageWarning,
705
0
      "Image does not contain a directory");
706
707
0
  return(std::string());
708
0
}
709
710
void Magick::Image::endian(const Magick::EndianType endian_)
711
0
{
712
0
  modifyImage();
713
0
  options()->endian(endian_);
714
0
  image()->endian=endian_;
715
0
}
716
717
Magick::EndianType Magick::Image::endian(void) const
718
0
{
719
0
  return(constImage()->endian);
720
0
}
721
722
void Magick::Image::exifProfile(const Magick::Blob &exifProfile_)
723
0
{
724
0
  modifyImage();
725
726
0
  if (exifProfile_.data() != 0)
727
0
    {
728
0
      StringInfo
729
0
        *exif_profile;
730
731
0
      exif_profile=AcquireStringInfo(exifProfile_.length());
732
0
      SetStringInfoDatum(exif_profile,(unsigned char *) exifProfile_.data());
733
0
      GetPPException;
734
0
      (void) SetImageProfile(image(),"exif",exif_profile,exceptionInfo);
735
0
      exif_profile=DestroyStringInfo(exif_profile);
736
0
      ThrowImageException;
737
0
    }
738
0
}
739
740
Magick::Blob Magick::Image::exifProfile(void) const
741
0
{
742
0
  const StringInfo 
743
0
    *exif_profile;
744
745
0
  exif_profile=GetImageProfile(constImage(),"exif");
746
0
  if (exif_profile == (StringInfo *) NULL)
747
0
    return(Blob());
748
0
  return(Blob(GetStringInfoDatum(exif_profile),
749
0
    GetStringInfoLength(exif_profile)));
750
0
} 
751
752
void Magick::Image::fileName(const std::string &fileName_)
753
526k
{
754
526k
  ssize_t
755
526k
    max_length;
756
757
526k
  modifyImage();
758
759
526k
  max_length=sizeof(image()->filename)-1;
760
526k
  fileName_.copy(image()->filename,(size_t) max_length);
761
526k
  if ((ssize_t) fileName_.length() > max_length)
762
0
    image()->filename[max_length]=0;
763
526k
  else
764
526k
    image()->filename[fileName_.length()]=0;
765
766
526k
  options()->fileName(fileName_);
767
526k
}
768
769
std::string Magick::Image::fileName(void) const
770
0
{
771
0
  return(constOptions()->fileName());
772
0
}
773
774
MagickCore::MagickSizeType Magick::Image::fileSize(void) const
775
0
{
776
0
  return(GetBlobSize(constImage()));
777
0
}
778
779
void Magick::Image::fillColor(const Magick::Color &fillColor_)
780
0
{
781
0
  modifyImage();
782
0
  options()->fillColor(fillColor_);
783
0
}
784
785
Magick::Color Magick::Image::fillColor(void) const
786
0
{
787
0
  return(constOptions()->fillColor());
788
0
}
789
790
void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
791
0
{
792
0
  modifyImage();
793
0
  options()->fillRule(fillRule_);
794
0
}
795
796
Magick::FillRule Magick::Image::fillRule(void) const
797
0
{
798
0
  return constOptions()->fillRule();
799
0
}
800
801
void Magick::Image::fillPattern(const Image &fillPattern_)
802
0
{
803
0
  modifyImage();
804
0
  if (fillPattern_.isValid())
805
0
    options()->fillPattern(fillPattern_.constImage());
806
0
  else
807
0
    options()->fillPattern(static_cast<MagickCore::Image*>(NULL));
808
0
}
809
810
Magick::Image Magick::Image::fillPattern(void) const
811
0
{
812
  // FIXME: This is inordinately inefficient
813
0
  const MagickCore::Image
814
0
    *tmpTexture;
815
816
0
  Image
817
0
    texture;
818
819
0
  tmpTexture=constOptions()->fillPattern();
820
821
0
  if (tmpTexture)
822
0
    {
823
0
      MagickCore::Image
824
0
        *image;
825
826
0
      GetPPException;
827
0
      image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
828
0
      texture.replaceImage(image);
829
0
      ThrowImageException;
830
0
    }
831
0
  return(texture);
832
0
}
833
834
void Magick::Image::filterType(const Magick::FilterType filterType_)
835
0
{
836
0
  modifyImage();
837
0
  image()->filter=filterType_;
838
0
}
839
840
Magick::FilterType Magick::Image::filterType(void) const
841
0
{
842
0
  return(constImage()->filter);
843
0
}
844
845
void Magick::Image::font(const std::string &font_)
846
0
{
847
0
  modifyImage();
848
0
  options()->font(font_);
849
0
}
850
851
std::string Magick::Image::font(void) const
852
0
{
853
0
  return(constOptions()->font());
854
0
}
855
856
void Magick::Image::fontFamily(const std::string &family_)
857
0
{
858
0
  modifyImage();
859
0
  options()->fontFamily(family_);
860
0
}
861
862
std::string Magick::Image::fontFamily(void) const
863
0
{
864
0
  return(constOptions()->fontFamily());
865
0
}
866
867
void Magick::Image::fontPointsize(const double pointSize_)
868
0
{
869
0
  modifyImage();
870
0
  options()->fontPointsize(pointSize_);
871
0
}
872
873
double Magick::Image::fontPointsize(void) const
874
0
{
875
0
  return(constOptions()->fontPointsize());
876
0
}
877
878
void Magick::Image::fontStyle(const StyleType pointSize_)
879
0
{
880
0
  modifyImage();
881
0
  options()->fontStyle(pointSize_);
882
0
}
883
884
Magick::StyleType Magick::Image::fontStyle(void) const
885
0
{
886
0
  return(constOptions()->fontStyle());
887
0
}
888
889
void Magick::Image::fontWeight(const size_t weight_)
890
0
{
891
0
  modifyImage();
892
0
  options()->fontWeight(weight_);
893
0
}
894
895
size_t Magick::Image::fontWeight(void) const
896
0
{
897
0
  return(constOptions()->fontWeight());
898
0
}
899
900
std::string Magick::Image::format(void) const
901
0
{
902
0
  const MagickInfo 
903
0
   *magick_info;
904
905
0
  GetPPException;
906
0
  magick_info=GetMagickInfo(constImage()->magick,exceptionInfo);
907
0
  ThrowImageException;
908
909
0
  if ((magick_info != 0) && (*magick_info->description != '\0'))
910
0
    return(std::string(magick_info->description));
911
912
0
  if (!quiet())
913
0
    throwExceptionExplicit(MagickCore::CorruptImageWarning,
914
0
      "Unrecognized image magick type");
915
916
0
  return(std::string());
917
0
}
918
919
std::string Magick::Image::formatExpression(const std::string expression)
920
0
{
921
0
  char
922
0
    *text;
923
924
0
  std::string
925
0
    text_string;
926
927
0
  GetPPException;
928
0
  modifyImage();
929
0
  text=InterpretImageProperties(imageInfo(),image(),expression.c_str(),
930
0
    exceptionInfo);
931
0
  if (text != (char *) NULL)
932
0
    {
933
0
      text_string=std::string(text);
934
0
      text=DestroyString(text);
935
0
    }
936
0
  ThrowImageException;
937
0
  return(text_string);
938
0
}
939
940
double Magick::Image::gamma(void) const
941
0
{
942
0
  return(constImage()->gamma);
943
0
}
944
945
Magick::Geometry Magick::Image::geometry(void) const
946
0
{
947
0
  if (constImage()->geometry)
948
0
    return Geometry(constImage()->geometry);
949
950
0
  if (!quiet())
951
0
    throwExceptionExplicit(MagickCore::OptionWarning,
952
0
      "Image does not contain a geometry");
953
954
0
  return(Geometry());
955
0
}
956
957
void Magick::Image::gifDisposeMethod(
958
  const MagickCore::DisposeType disposeMethod_)
959
0
{
960
0
  modifyImage();
961
0
  image()->dispose=disposeMethod_;
962
0
}
963
964
MagickCore::DisposeType Magick::Image::gifDisposeMethod(void) const
965
0
{
966
0
  return(constImage()->dispose);
967
0
}
968
969
bool Magick::Image::hasChannel(const PixelChannel channel) const
970
0
{
971
0
  if (GetPixelChannelTraits(constImage(),channel) == UndefinedPixelTrait)
972
0
    return(false);
973
974
0
  if (channel == GreenPixelChannel || channel == BluePixelChannel)
975
0
    return (GetPixelChannelOffset(constImage(),channel) == (ssize_t)channel);
976
977
0
  return(true);
978
0
}
979
980
void Magick::Image::highlightColor(const Color color_)
981
0
{
982
0
  std::string
983
0
    value;
984
985
0
  value=color_;
986
0
  artifact("compare:highlight-color",value);
987
0
}
988
989
void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
990
0
{
991
0
  profile("icc",colorProfile_);
992
0
}
993
994
Magick::Blob Magick::Image::iccColorProfile(void) const
995
0
{
996
0
  const StringInfo
997
0
    *color_profile;
998
999
0
  color_profile=GetImageProfile(constImage(),"icc");
1000
0
  if (color_profile == (StringInfo *) NULL)
1001
0
    return(Blob());
1002
0
  return(Blob(GetStringInfoDatum(color_profile),GetStringInfoLength(
1003
0
    color_profile)));
1004
0
}
1005
1006
void Magick::Image::interlaceType(const Magick::InterlaceType interlace_)
1007
0
{
1008
0
  modifyImage();
1009
0
  image()->interlace=interlace_;
1010
0
  options()->interlaceType(interlace_);
1011
0
}
1012
1013
Magick::InterlaceType Magick::Image::interlaceType(void) const
1014
0
{
1015
0
  return(constImage()->interlace);
1016
0
}
1017
1018
void Magick::Image::interpolate(const PixelInterpolateMethod interpolate_)
1019
0
{
1020
0
  modifyImage();
1021
0
  image()->interpolate=interpolate_;
1022
0
}
1023
1024
Magick::PixelInterpolateMethod Magick::Image::interpolate(void) const
1025
0
{
1026
0
  return constImage()->interpolate;
1027
0
}
1028
1029
void Magick::Image::iptcProfile(const Magick::Blob &iptcProfile_)
1030
0
{
1031
0
  modifyImage();
1032
0
  if (iptcProfile_.data() != 0)
1033
0
    {
1034
0
      StringInfo
1035
0
        *iptc_profile;
1036
1037
0
      iptc_profile=AcquireStringInfo(iptcProfile_.length());
1038
0
      SetStringInfoDatum(iptc_profile,(unsigned char *) iptcProfile_.data());
1039
0
      GetPPException;
1040
0
      (void) SetImageProfile(image(),"iptc",iptc_profile,exceptionInfo);
1041
0
      iptc_profile=DestroyStringInfo(iptc_profile);
1042
0
      ThrowImageException;
1043
0
    }
1044
0
}
1045
1046
Magick::Blob Magick::Image::iptcProfile(void) const
1047
0
{
1048
0
  const StringInfo
1049
0
    *iptc_profile;
1050
1051
0
  iptc_profile=GetImageProfile(constImage(),"iptc");
1052
0
  if (iptc_profile == (StringInfo *) NULL)
1053
0
    return(Blob());
1054
0
  return(Blob(GetStringInfoDatum(iptc_profile),GetStringInfoLength(
1055
0
    iptc_profile)));
1056
0
}
1057
1058
bool Magick::Image::isOpaque(void) const
1059
0
{
1060
0
  MagickBooleanType
1061
0
    result;
1062
1063
0
  GetPPException;
1064
0
  result=IsImageOpaque(constImage(),exceptionInfo);
1065
0
  ThrowImageException;
1066
0
  return(result != MagickFalse ? true : false);
1067
0
}
1068
1069
void Magick::Image::isValid(const bool isValid_)
1070
0
{
1071
0
  if (!isValid_)
1072
0
    {
1073
0
      delete _imgRef;
1074
0
      _imgRef=new ImageRef;
1075
0
    }
1076
0
  else if (!isValid())
1077
0
    {
1078
      // Construct with single-pixel black image to make
1079
      // image valid. This is an obvious hack.
1080
0
      size(Geometry(1,1));
1081
0
      read("xc:black");
1082
0
    }
1083
0
}
1084
1085
bool Magick::Image::isValid(void) const
1086
0
{
1087
0
  return rows() && columns();
1088
0
}
1089
1090
void Magick::Image::label(const std::string &label_)
1091
0
{
1092
0
  modifyImage();
1093
0
  GetPPException;
1094
0
  (void) SetImageProperty(image(),"Label",NULL,exceptionInfo);
1095
0
  if (label_.length() > 0)
1096
0
    (void) SetImageProperty(image(),"Label",label_.c_str(),exceptionInfo);
1097
0
  ThrowImageException;
1098
0
}
1099
1100
std::string Magick::Image::label(void) const
1101
0
{
1102
0
  const char
1103
0
    *value;
1104
1105
0
  GetPPException;
1106
0
  value=GetImageProperty(constImage(),"Label",exceptionInfo);
1107
0
  ThrowImageException;
1108
1109
0
  if (value)
1110
0
    return(std::string(value));
1111
1112
0
  return(std::string());
1113
0
}
1114
1115
void Magick::Image::lowlightColor(const Color color_)
1116
0
{
1117
0
  std::string
1118
0
    value;
1119
1120
0
  value=color_;
1121
0
  artifact("compare:lowlight-color",value);
1122
0
}
1123
1124
void Magick::Image::magick(const std::string &magick_)
1125
588k
{
1126
588k
  size_t
1127
588k
    length;
1128
1129
588k
  modifyImage();
1130
1131
588k
  length=sizeof(image()->magick)-1;
1132
588k
  if (magick_.length() < length)
1133
588k
    length=magick_.length();
1134
1135
588k
  if (!magick_.empty())
1136
588k
    magick_.copy(image()->magick,length);
1137
588k
  image()->magick[length]=0;
1138
1139
588k
  options()->magick(magick_);
1140
588k
}
1141
1142
std::string Magick::Image::magick(void) const
1143
0
{
1144
0
  if (*(constImage()->magick) != '\0')
1145
0
    return(std::string(constImage()->magick));
1146
1147
0
  return(constOptions()->magick());
1148
0
}
1149
1150
void Magick::Image::masklightColor(const Color color_)
1151
0
{
1152
0
  std::string
1153
0
    value;
1154
1155
0
  value=color_;
1156
0
  artifact("compare:masklight-color",value);
1157
0
}
1158
1159
double Magick::Image::meanErrorPerPixel(void) const
1160
0
{
1161
0
  return(constImage()->error.mean_error_per_pixel);
1162
0
}
1163
1164
void Magick::Image::modulusDepth(const size_t depth_)
1165
0
{
1166
0
  modifyImage();
1167
0
  GetPPException;
1168
0
  SetImageDepth(image(),depth_,exceptionInfo);
1169
0
  ThrowImageException;
1170
0
  options()->depth(depth_);
1171
0
}
1172
1173
size_t Magick::Image::modulusDepth(void) const
1174
0
{
1175
0
  size_t 
1176
0
    depth;
1177
1178
0
  GetPPException;
1179
0
  depth=GetImageDepth(constImage(),exceptionInfo);
1180
0
  ThrowImageException;
1181
0
  return(depth);
1182
0
}
1183
1184
void Magick::Image::monochrome(const bool monochromeFlag_)
1185
0
{
1186
0
  modifyImage();
1187
0
  options()->monochrome(monochromeFlag_);
1188
0
}
1189
1190
bool Magick::Image::monochrome(void) const
1191
0
{
1192
0
  return(constOptions()->monochrome());
1193
0
}
1194
1195
Magick::Geometry Magick::Image::montageGeometry(void) const
1196
0
{
1197
0
  if (constImage()->montage)
1198
0
    return Magick::Geometry(constImage()->montage);
1199
1200
0
  if (!quiet())
1201
0
    throwExceptionExplicit(MagickCore::CorruptImageWarning,
1202
0
    "Image does not contain a montage");
1203
1204
0
  return(Magick::Geometry());
1205
0
}
1206
1207
double Magick::Image::normalizedMaxError(void) const
1208
0
{
1209
0
  return(constImage()->error.normalized_maximum_error);
1210
0
}
1211
1212
double Magick::Image::normalizedMeanError(void) const
1213
0
{
1214
0
  return(constImage()->error.normalized_mean_error);
1215
0
}
1216
1217
void Magick::Image::orientation(const Magick::OrientationType orientation_)
1218
0
{
1219
0
  modifyImage();
1220
0
  image()->orientation=orientation_;
1221
0
}
1222
1223
Magick::OrientationType Magick::Image::orientation(void) const
1224
0
{
1225
0
  return(constImage()->orientation);
1226
0
}
1227
1228
void Magick::Image::page(const Magick::Geometry &pageSize_)
1229
0
{
1230
0
  modifyImage();
1231
0
  options()->page(pageSize_);
1232
0
  image()->page=pageSize_;
1233
0
}
1234
1235
Magick::Geometry Magick::Image::page(void) const
1236
0
{
1237
0
  return(Geometry(constImage()->page.width,constImage()->page.height,
1238
0
    constImage()->page.x,constImage()->page.y));
1239
0
}
1240
1241
void Magick::Image::quality(const size_t quality_)
1242
0
{
1243
0
  modifyImage();
1244
0
  image()->quality=quality_;
1245
0
  options()->quality(quality_);
1246
0
}
1247
1248
size_t Magick::Image::quality(void) const
1249
0
{
1250
0
  return(constImage()->quality);
1251
0
}
1252
1253
void Magick::Image::quantizeColors(const size_t colors_)
1254
0
{
1255
0
  modifyImage();
1256
0
  options()->quantizeColors(colors_);
1257
0
}
1258
1259
size_t Magick::Image::quantizeColors(void) const
1260
0
{
1261
0
  return(constOptions()->quantizeColors());
1262
0
}
1263
1264
void Magick::Image::quantizeColorSpace(
1265
  const Magick::ColorspaceType colorSpace_)
1266
0
{
1267
0
  modifyImage();
1268
0
  options()->quantizeColorSpace(colorSpace_);
1269
0
}
1270
1271
Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1272
0
{
1273
0
  return(constOptions()->quantizeColorSpace());
1274
0
}
1275
1276
void Magick::Image::quantizeDither(const bool ditherFlag_)
1277
0
{
1278
0
  modifyImage();
1279
0
  options()->quantizeDither(ditherFlag_);
1280
0
}
1281
1282
bool Magick::Image::quantizeDither(void) const
1283
0
{
1284
0
  return(constOptions()->quantizeDither());
1285
0
}
1286
1287
void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1288
0
{
1289
0
  modifyImage();
1290
0
  options()->quantizeDitherMethod(ditherMethod_);
1291
0
}
1292
1293
MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1294
0
{
1295
0
  return(constOptions()->quantizeDitherMethod());
1296
0
}
1297
1298
void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1299
0
{
1300
0
  modifyImage();
1301
0
  options()->quantizeTreeDepth(treeDepth_);
1302
0
}
1303
1304
size_t Magick::Image::quantizeTreeDepth() const
1305
0
{
1306
0
  return(constOptions()->quantizeTreeDepth());
1307
0
}
1308
1309
void Magick::Image::quiet(const bool quiet_)
1310
8.04k
{
1311
8.04k
  modifyImage();
1312
8.04k
  options()->quiet(quiet_);
1313
8.04k
}
1314
1315
bool Magick::Image::quiet(void) const
1316
1.03M
{
1317
1.03M
  return(constOptions()->quiet());
1318
1.03M
}
1319
1320
void Magick::Image::renderingIntent(
1321
  const Magick::RenderingIntent renderingIntent_)
1322
0
{
1323
0
  modifyImage();
1324
0
  image()->rendering_intent=renderingIntent_;
1325
0
}
1326
1327
Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1328
0
{
1329
0
  return(static_cast<Magick::RenderingIntent>(constImage()->rendering_intent));
1330
0
}
1331
1332
void Magick::Image::resolutionUnits(
1333
  const Magick::ResolutionType resolutionUnits_)
1334
0
{
1335
0
  modifyImage();
1336
0
  image()->units=resolutionUnits_;
1337
0
  options()->resolutionUnits(resolutionUnits_);
1338
0
}
1339
1340
Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1341
0
{
1342
0
  return(static_cast<Magick::ResolutionType>(constImage()->units));
1343
0
}
1344
1345
size_t Magick::Image::rows(void) const
1346
0
{
1347
0
  return(constImage()->rows);
1348
0
}
1349
1350
void Magick::Image::samplingFactor(const std::string &samplingFactor_)
1351
0
{
1352
0
  modifyImage();
1353
0
  options()->samplingFactor(samplingFactor_);
1354
0
}
1355
1356
std::string Magick::Image::samplingFactor(void) const
1357
0
{
1358
0
  return(constOptions()->samplingFactor());
1359
0
}
1360
1361
void Magick::Image::scene(const size_t scene_)
1362
0
{
1363
0
  modifyImage();
1364
0
  image()->scene=scene_;
1365
0
}
1366
1367
size_t Magick::Image::scene(void) const
1368
0
{
1369
0
  return(constImage()->scene);
1370
0
}
1371
1372
void Magick::Image::size(const Geometry &geometry_)
1373
4.02k
{
1374
4.02k
  modifyImage();
1375
4.02k
  options()->size(geometry_);
1376
4.02k
  image()->rows=geometry_.height();
1377
4.02k
  image()->columns=geometry_.width();
1378
4.02k
}
1379
1380
Magick::Geometry Magick::Image::size(void) const
1381
0
{
1382
0
  return(Magick::Geometry(constImage()->columns,constImage()->rows));
1383
0
}
1384
1385
void Magick::Image::strokeAntiAlias(const bool flag_)
1386
0
{
1387
0
  modifyImage();
1388
0
  options()->strokeAntiAlias(flag_);
1389
0
}
1390
1391
bool Magick::Image::strokeAntiAlias(void) const
1392
0
{
1393
0
  return(constOptions()->strokeAntiAlias());
1394
0
}
1395
1396
void Magick::Image::strokeColor(const Magick::Color &strokeColor_)
1397
0
{
1398
0
  std::string
1399
0
    value;
1400
1401
0
  modifyImage();
1402
0
  options()->strokeColor(strokeColor_);
1403
0
  value=strokeColor_;
1404
0
  artifact("stroke",value);
1405
0
}
1406
1407
Magick::Color Magick::Image::strokeColor(void) const
1408
0
{
1409
0
  return(constOptions()->strokeColor());
1410
0
}
1411
1412
void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1413
0
{
1414
0
  modifyImage();
1415
0
  options()->strokeDashArray(strokeDashArray_);
1416
0
}
1417
1418
const double* Magick::Image::strokeDashArray(void) const
1419
0
{
1420
0
  return(constOptions()->strokeDashArray());
1421
0
}
1422
1423
void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1424
0
{
1425
0
  modifyImage();
1426
0
  options()->strokeDashOffset(strokeDashOffset_);
1427
0
}
1428
1429
double Magick::Image::strokeDashOffset(void) const
1430
0
{
1431
0
  return(constOptions()->strokeDashOffset());
1432
0
}
1433
1434
void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1435
0
{
1436
0
  modifyImage();
1437
0
  options()->strokeLineCap(lineCap_);
1438
0
}
1439
1440
Magick::LineCap Magick::Image::strokeLineCap(void) const
1441
0
{
1442
0
  return(constOptions()->strokeLineCap());
1443
0
}
1444
1445
void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1446
0
{
1447
0
  modifyImage();
1448
0
  options()->strokeLineJoin(lineJoin_);
1449
0
}
1450
1451
Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1452
0
{
1453
0
  return(constOptions()->strokeLineJoin());
1454
0
}
1455
1456
void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1457
0
{
1458
0
  modifyImage();
1459
0
  options()->strokeMiterLimit(strokeMiterLimit_);
1460
0
}
1461
1462
size_t Magick::Image::strokeMiterLimit(void) const
1463
0
{
1464
0
  return(constOptions()->strokeMiterLimit());
1465
0
}
1466
1467
void Magick::Image::strokePattern(const Image &strokePattern_)
1468
0
{
1469
0
  modifyImage();
1470
0
  if(strokePattern_.isValid())
1471
0
    options()->strokePattern(strokePattern_.constImage());
1472
0
  else
1473
0
    options()->strokePattern(static_cast<MagickCore::Image*>(NULL));
1474
0
}
1475
1476
Magick::Image Magick::Image::strokePattern(void) const
1477
0
{
1478
  // FIXME: This is inordinately inefficient
1479
0
  const MagickCore::Image 
1480
0
    *tmpTexture;
1481
1482
0
  Image
1483
0
    texture;
1484
1485
0
  tmpTexture=constOptions()->strokePattern();
1486
1487
0
  if (tmpTexture)
1488
0
    {
1489
0
      MagickCore::Image
1490
0
        *image;
1491
1492
0
      GetPPException;
1493
0
      image=CloneImage(tmpTexture,0,0,MagickTrue,exceptionInfo);
1494
0
      texture.replaceImage(image);
1495
0
      ThrowImageException;
1496
0
    }
1497
0
  return(texture);
1498
0
}
1499
1500
void Magick::Image::strokeWidth(const double strokeWidth_)
1501
0
{
1502
0
  char
1503
0
    value[MagickPathExtent];
1504
1505
0
  modifyImage();
1506
0
  options()->strokeWidth(strokeWidth_);
1507
0
  FormatLocaleString(value,MagickPathExtent,"%.17g",strokeWidth_);
1508
0
  (void) SetImageArtifact(image(),"strokewidth",value);
1509
0
}
1510
1511
double Magick::Image::strokeWidth(void) const
1512
0
{
1513
0
  return(constOptions()->strokeWidth());
1514
0
}
1515
1516
void Magick::Image::subImage(const size_t subImage_)
1517
0
{
1518
0
  modifyImage();
1519
0
  options()->subImage(subImage_);
1520
0
}
1521
1522
size_t Magick::Image::subImage(void) const
1523
0
{
1524
0
  return(constOptions()->subImage());
1525
0
}
1526
1527
void Magick::Image::subRange(const size_t subRange_)
1528
0
{
1529
0
  modifyImage();
1530
0
  options()->subRange(subRange_);
1531
0
}
1532
1533
size_t Magick::Image::subRange(void) const
1534
0
{
1535
0
  return(constOptions()->subRange());
1536
0
}
1537
1538
void Magick::Image::textAntiAlias(const bool flag_)
1539
0
{
1540
0
  modifyImage();
1541
0
  options()->textAntiAlias(flag_);
1542
0
}
1543
1544
bool Magick::Image::textAntiAlias(void) const
1545
0
{
1546
0
  return(constOptions()->textAntiAlias());
1547
0
}
1548
1549
void Magick::Image::textDirection(DirectionType direction_)
1550
0
{
1551
0
  modifyImage();
1552
0
  options()->textDirection(direction_);
1553
0
}
1554
1555
Magick::DirectionType Magick::Image::textDirection(void) const
1556
0
{
1557
0
  return(constOptions()->textDirection());
1558
0
}
1559
1560
void Magick::Image::textEncoding(const std::string &encoding_)
1561
0
{
1562
0
  modifyImage();
1563
0
  options()->textEncoding(encoding_);
1564
0
}
1565
1566
std::string Magick::Image::textEncoding(void) const
1567
0
{
1568
0
  return(constOptions()->textEncoding());
1569
0
}
1570
1571
void Magick::Image::textGravity(GravityType gravity_)
1572
0
{
1573
0
  modifyImage();
1574
0
  options()->textGravity(gravity_);
1575
0
}
1576
1577
Magick::GravityType Magick::Image::textGravity(void) const
1578
0
{
1579
0
  return(constOptions()->textGravity());
1580
0
}
1581
1582
void Magick::Image::textInterlineSpacing(double spacing_)
1583
0
{
1584
0
  modifyImage();
1585
0
  options()->textInterlineSpacing(spacing_);
1586
0
}
1587
1588
double Magick::Image::textInterlineSpacing(void) const
1589
0
{
1590
0
  return(constOptions()->textInterlineSpacing());
1591
0
}
1592
1593
void Magick::Image::textInterwordSpacing(double spacing_)
1594
0
{
1595
0
  modifyImage();
1596
0
  options()->textInterwordSpacing(spacing_);
1597
0
}
1598
1599
double Magick::Image::textInterwordSpacing(void) const
1600
0
{
1601
0
  return(constOptions()->textInterwordSpacing());
1602
0
}
1603
1604
void Magick::Image::textKerning(double kerning_)
1605
0
{
1606
0
  modifyImage();
1607
0
  options()->textKerning(kerning_);
1608
0
}
1609
1610
double Magick::Image::textKerning(void) const
1611
0
{
1612
0
  return(constOptions()->textKerning());
1613
0
}
1614
1615
void Magick::Image::textUnderColor(const Color &underColor_)
1616
0
{
1617
0
  modifyImage();
1618
0
  options()->textUnderColor(underColor_);
1619
0
}
1620
1621
Magick::Color Magick::Image::textUnderColor(void) const
1622
0
{
1623
0
  return(constOptions()->textUnderColor());
1624
0
}
1625
1626
size_t Magick::Image::totalColors(void) const
1627
0
{
1628
0
  size_t
1629
0
    colors;
1630
1631
0
  GetPPException;
1632
0
  colors=GetNumberColors(constImage(),(FILE *) NULL,exceptionInfo);
1633
0
  ThrowImageException;
1634
0
  return colors;
1635
0
}
1636
1637
void Magick::Image::transformRotation(const double angle_)
1638
0
{
1639
0
  modifyImage();
1640
0
  options()->transformRotation(angle_);
1641
0
}
1642
1643
void Magick::Image::transformSkewX(const double skewx_)
1644
0
{
1645
0
  modifyImage();
1646
0
  options()->transformSkewX(skewx_);
1647
0
}
1648
1649
void Magick::Image::transformSkewY(const double skewy_)
1650
0
{
1651
0
  modifyImage();
1652
0
  options()->transformSkewY(skewy_);
1653
0
}
1654
1655
Magick::ImageType Magick::Image::type(void) const
1656
0
{
1657
0
  if (constOptions()->type() != UndefinedType)
1658
0
    return(constOptions()->type());
1659
0
  return(GetImageType(constImage()));
1660
0
}
1661
1662
void Magick::Image::type(const Magick::ImageType type_)
1663
0
{
1664
0
  modifyImage();
1665
0
  options()->type(type_);
1666
0
  GetPPException;
1667
0
  SetImageType(image(),type_,exceptionInfo);
1668
0
  ThrowImageException;
1669
0
}
1670
1671
void Magick::Image::verbose(const bool verboseFlag_)
1672
0
{
1673
0
  modifyImage();
1674
0
  options()->verbose(verboseFlag_);
1675
0
}
1676
1677
bool Magick::Image::verbose(void) const
1678
0
{
1679
0
  return(constOptions()->verbose());
1680
0
}
1681
1682
void Magick::Image::virtualPixelMethod(
1683
  const VirtualPixelMethod virtualPixelMethod_)
1684
0
{
1685
0
  modifyImage();
1686
0
  GetPPException;
1687
0
  SetImageVirtualPixelMethod(image(),virtualPixelMethod_,exceptionInfo);
1688
0
  ThrowImageException;
1689
0
}
1690
1691
Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1692
0
{
1693
0
  return(GetImageVirtualPixelMethod(constImage()));
1694
0
}
1695
1696
void Magick::Image::x11Display(const std::string &display_)
1697
0
{
1698
0
  modifyImage();
1699
0
  options()->x11Display(display_);
1700
0
}
1701
1702
std::string Magick::Image::x11Display(void) const
1703
0
{
1704
0
  return(constOptions()->x11Display());
1705
0
}
1706
1707
double Magick::Image::xResolution(void) const
1708
0
{
1709
0
  return(constImage()->resolution.x);
1710
0
}
1711
1712
double Magick::Image::yResolution(void) const
1713
0
{
1714
0
  return(constImage()->resolution.y);
1715
0
}
1716
1717
void Magick::Image::adaptiveBlur(const double radius_,const double sigma_)
1718
0
{
1719
0
  MagickCore::Image
1720
0
    *newImage;
1721
1722
0
  GetPPException;
1723
0
  newImage=AdaptiveBlurImage(constImage(),radius_,sigma_,exceptionInfo);
1724
0
  replaceImage(newImage);
1725
0
  ThrowImageException;
1726
0
}
1727
1728
void Magick::Image::adaptiveResize(const Geometry &geometry_)
1729
0
{
1730
0
  MagickCore::Image
1731
0
    *newImage;
1732
1733
0
  size_t
1734
0
    height=rows(),
1735
0
    width=columns();
1736
1737
0
  ssize_t
1738
0
    x=0,
1739
0
    y=0;
1740
1741
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
1742
0
    &height);
1743
1744
0
  GetPPException;
1745
0
  newImage=AdaptiveResizeImage(constImage(),width,height,exceptionInfo);
1746
0
  replaceImage(newImage);
1747
0
  ThrowImageException;
1748
0
}
1749
1750
void Magick::Image::adaptiveSharpen(const double radius_,const double sigma_)
1751
0
{
1752
0
  MagickCore::Image
1753
0
    *newImage;
1754
1755
0
  GetPPException;
1756
0
  newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1757
0
  replaceImage(newImage);
1758
0
  ThrowImageException;
1759
0
}
1760
1761
void Magick::Image::adaptiveSharpenChannel(const ChannelType channel_,
1762
  const double radius_,const double sigma_ )
1763
0
{
1764
0
  MagickCore::Image
1765
0
    *newImage;
1766
1767
0
  GetPPException;
1768
0
  GetAndSetPPChannelMask(channel_);
1769
0
  newImage=AdaptiveSharpenImage(constImage(),radius_,sigma_,exceptionInfo);
1770
0
  RestorePPChannelMask;
1771
0
  replaceImage(newImage);
1772
0
  ThrowImageException;
1773
0
}
1774
1775
void Magick::Image::adaptiveThreshold(const size_t width_,const size_t height_,
1776
   const double bias_)
1777
0
{
1778
1779
0
  MagickCore::Image
1780
0
    *newImage;
1781
1782
0
  GetPPException;
1783
0
  newImage=AdaptiveThresholdImage(constImage(),width_,height_,bias_,
1784
0
    exceptionInfo);
1785
0
  replaceImage(newImage);
1786
0
  ThrowImageException;
1787
0
}
1788
1789
void Magick::Image::addNoise(const NoiseType noiseType_,const double attenuate_)
1790
0
{
1791
0
  MagickCore::Image
1792
0
    *newImage;
1793
1794
0
  GetPPException;
1795
0
  newImage=AddNoiseImage(constImage(),noiseType_,attenuate_,exceptionInfo);
1796
0
  replaceImage(newImage);
1797
0
  ThrowImageException;
1798
0
}
1799
1800
void Magick::Image::addNoiseChannel(const ChannelType channel_,
1801
  const NoiseType noiseType_,const double attenuate_)
1802
0
{
1803
0
  MagickCore::Image
1804
0
    *newImage;
1805
1806
0
  GetPPException;
1807
0
  GetAndSetPPChannelMask(channel_);
1808
0
  newImage=AddNoiseImage(constImage(),noiseType_,attenuate_,exceptionInfo);
1809
0
  RestorePPChannelMask;
1810
0
  replaceImage(newImage);
1811
0
  ThrowImageException;
1812
0
}
1813
1814
void Magick::Image::affineTransform(const DrawableAffine &affine_)
1815
0
{
1816
0
  AffineMatrix
1817
0
    _affine;
1818
1819
0
  MagickCore::Image
1820
0
    *newImage;
1821
1822
0
  _affine.sx=affine_.sx();
1823
0
  _affine.sy=affine_.sy();
1824
0
  _affine.rx=affine_.rx();
1825
0
  _affine.ry=affine_.ry();
1826
0
  _affine.tx=affine_.tx();
1827
0
  _affine.ty=affine_.ty();
1828
1829
0
  GetPPException;
1830
0
  newImage=AffineTransformImage(constImage(),&_affine,exceptionInfo);
1831
0
  replaceImage(newImage);
1832
0
  ThrowImageException;
1833
0
}
1834
1835
void Magick::Image::alpha(const unsigned int alpha_)
1836
0
{
1837
0
  modifyImage();
1838
0
  GetPPException;
1839
0
  SetImageAlpha(image(),(Quantum) alpha_,exceptionInfo);
1840
0
  ThrowImageException;
1841
0
}
1842
1843
void Magick::Image::alphaChannel(AlphaChannelOption alphaOption_)
1844
0
{
1845
0
  modifyImage();
1846
0
  GetPPException;
1847
0
  SetImageAlphaChannel(image(),alphaOption_,exceptionInfo);
1848
0
  ThrowImageException;
1849
0
}
1850
1851
void Magick::Image::annotate(const std::string &text_,
1852
  const Geometry &location_)
1853
0
{
1854
0
  annotate(text_,location_,NorthWestGravity,0.0);
1855
0
}
1856
1857
void Magick::Image::annotate(const std::string &text_,
1858
  const Geometry &boundingArea_,const GravityType gravity_)
1859
0
{
1860
0
  annotate(text_,boundingArea_,gravity_,0.0);
1861
0
}
1862
1863
void Magick::Image::annotate(const std::string &text_,
1864
  const Geometry &boundingArea_,const GravityType gravity_,
1865
  const double degrees_)
1866
0
{
1867
0
  AffineMatrix
1868
0
    oaffine;
1869
1870
0
  char
1871
0
    boundingArea[MagickPathExtent];
1872
1873
0
  DrawInfo
1874
0
    *drawInfo;
1875
1876
0
  modifyImage();
1877
1878
0
  drawInfo=options()->drawInfo();
1879
0
  drawInfo->text=DestroyString(drawInfo->text);
1880
0
  drawInfo->text=const_cast<char *>(text_.c_str());
1881
0
  drawInfo->geometry=DestroyString(drawInfo->geometry);
1882
1883
0
  if (boundingArea_.isValid())
1884
0
    {
1885
0
      if (boundingArea_.width() == 0 || boundingArea_.height() == 0)
1886
0
        {
1887
0
          FormatLocaleString(boundingArea,MagickPathExtent,"%+.20g%+.20g",
1888
0
            (double) boundingArea_.xOff(),(double) boundingArea_.yOff());
1889
0
        }
1890
0
      else
1891
0
        {
1892
0
          (void) CopyMagickString(boundingArea,
1893
0
            std::string(boundingArea_).c_str(), MagickPathExtent);
1894
0
        }
1895
0
      drawInfo->geometry=boundingArea;
1896
0
    }
1897
1898
0
  drawInfo->gravity=gravity_;
1899
1900
0
  oaffine=drawInfo->affine;
1901
0
  if (degrees_ != 0.0)
1902
0
    {
1903
0
       AffineMatrix
1904
0
         affine,
1905
0
         current;
1906
1907
0
       affine.sx=1.0;
1908
0
       affine.rx=0.0;
1909
0
       affine.ry=0.0;
1910
0
       affine.sy=1.0;
1911
0
       affine.tx=0.0;
1912
0
       affine.ty=0.0;
1913
1914
0
       current=drawInfo->affine;
1915
0
       affine.sx=cos(DegreesToRadians(fmod(degrees_,360.0)));
1916
0
       affine.rx=sin(DegreesToRadians(fmod(degrees_,360.0)));
1917
0
       affine.ry=(-sin(DegreesToRadians(fmod(degrees_,360.0))));
1918
0
       affine.sy=cos(DegreesToRadians(fmod(degrees_,360.0)));
1919
1920
0
       drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
1921
0
       drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
1922
0
       drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
1923
0
       drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
1924
0
       drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty
1925
0
         +current.tx;
1926
0
    }
1927
1928
0
  GetPPException;
1929
0
  AnnotateImage(image(),drawInfo,exceptionInfo);
1930
1931
  // Restore original values
1932
0
  drawInfo->affine=oaffine;
1933
0
  drawInfo->text=(char *) NULL;
1934
0
  drawInfo->geometry=(char *) NULL;
1935
1936
0
  ThrowImageException;
1937
0
}
1938
1939
void Magick::Image::annotate(const std::string &text_,
1940
  const GravityType gravity_)
1941
0
{
1942
0
  DrawInfo
1943
0
    *drawInfo;
1944
1945
0
  modifyImage();
1946
1947
0
  drawInfo=options()->drawInfo();
1948
0
  drawInfo->text=DestroyString(drawInfo->text);
1949
0
  drawInfo->text=const_cast<char *>(text_.c_str());
1950
0
  drawInfo->gravity=gravity_;
1951
1952
0
  GetPPException;
1953
0
  AnnotateImage(image(),drawInfo,exceptionInfo);
1954
1955
0
  drawInfo->gravity=NorthWestGravity;
1956
0
  drawInfo->text=(char *) NULL;
1957
1958
0
  ThrowImageException;
1959
0
}
1960
1961
void Magick::Image::artifact(const std::string &name_,const std::string &value_)
1962
0
{
1963
0
  modifyImage();
1964
0
  (void) SetImageArtifact(image(),name_.c_str(),value_.c_str());
1965
0
}
1966
1967
std::string Magick::Image::artifact(const std::string &name_) const
1968
0
{
1969
0
  const char
1970
0
    *value;
1971
1972
0
  value=GetImageArtifact(constImage(),name_.c_str());
1973
0
  if (value)
1974
0
    return(std::string(value));
1975
0
  return(std::string());
1976
0
}
1977
1978
void Magick::Image::attribute(const std::string name_,const char *value_)
1979
0
{
1980
0
  modifyImage();
1981
0
  GetPPException;
1982
0
  SetImageProperty(image(),name_.c_str(),value_,exceptionInfo);
1983
0
  ThrowImageException;
1984
0
}
1985
1986
void Magick::Image::attribute(const std::string name_,const std::string value_)
1987
0
{
1988
0
  modifyImage();
1989
0
  GetPPException;
1990
0
  SetImageProperty(image(),name_.c_str(),value_.c_str(),exceptionInfo);
1991
0
  ThrowImageException;
1992
0
}
1993
1994
std::string Magick::Image::attribute(const std::string name_) const
1995
0
{
1996
0
  const char
1997
0
    *value;
1998
1999
0
  GetPPException;
2000
0
  value=GetImageProperty(constImage(),name_.c_str(),exceptionInfo);
2001
0
  ThrowImageException;
2002
2003
0
  if (value)
2004
0
    return(std::string(value));
2005
2006
0
  return(std::string()); // Intentionally no exception
2007
0
}
2008
2009
void Magick::Image::autoGamma(void)
2010
0
{
2011
0
  modifyImage();
2012
0
  GetPPException;
2013
0
  (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2014
0
  (void) AutoGammaImage(image(),exceptionInfo);
2015
0
  ThrowImageException;
2016
0
}
2017
2018
void Magick::Image::autoGammaChannel(const ChannelType channel_)
2019
0
{
2020
0
  modifyImage();
2021
0
  GetPPException;
2022
0
  GetAndSetPPChannelMask(channel_);
2023
0
  (void) SyncImageSettings(imageInfo(),image(),exceptionInfo);
2024
0
  (void) AutoGammaImage(image(),exceptionInfo);
2025
0
  RestorePPChannelMask;
2026
0
  ThrowImageException;
2027
0
}
2028
2029
void Magick::Image::autoLevel(void)
2030
0
{
2031
0
  modifyImage();
2032
0
  GetPPException;
2033
0
  (void) AutoLevelImage(image(),exceptionInfo);
2034
0
  ThrowImageException;
2035
0
}
2036
2037
void Magick::Image::autoLevelChannel(const ChannelType channel_)
2038
0
{
2039
0
  modifyImage();
2040
0
  GetPPException;
2041
0
  GetAndSetPPChannelMask(channel_);
2042
0
  (void) AutoLevelImage(image(),exceptionInfo);
2043
0
  RestorePPChannelMask;
2044
0
  ThrowImageException;
2045
0
}
2046
2047
void Magick::Image::autoOrient(void)
2048
0
{
2049
0
  MagickCore::Image
2050
0
    *newImage;
2051
2052
0
  if (image()->orientation == UndefinedOrientation ||
2053
0
      image()->orientation == TopLeftOrientation)
2054
0
    return;
2055
2056
0
  GetPPException;
2057
0
  newImage=AutoOrientImage(constImage(),image()->orientation,exceptionInfo);
2058
0
  replaceImage(newImage);
2059
0
  ThrowImageException;
2060
0
}
2061
2062
void Magick::Image::autoThreshold(const AutoThresholdMethod method_)
2063
0
{
2064
0
  modifyImage();
2065
0
  GetPPException;
2066
0
  AutoThresholdImage(image(),method_, exceptionInfo);
2067
0
  ThrowImageException;
2068
0
}
2069
2070
void Magick::Image::blackThreshold(const std::string &threshold_)
2071
0
{
2072
0
  modifyImage();
2073
0
  GetPPException;
2074
0
  BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2075
0
  ThrowImageException;
2076
0
}
2077
2078
void Magick::Image::blackThresholdChannel(const ChannelType channel_,
2079
  const std::string &threshold_)
2080
0
{
2081
0
  modifyImage();
2082
0
  GetPPException;
2083
0
  GetAndSetPPChannelMask(channel_);
2084
0
  BlackThresholdImage(image(),threshold_.c_str(),exceptionInfo);
2085
0
  RestorePPChannelMask;
2086
0
  ThrowImageException;
2087
0
}
2088
2089
void Magick::Image::blueShift(const double factor_)
2090
0
{
2091
0
  MagickCore::Image
2092
0
    *newImage;
2093
2094
0
  GetPPException;
2095
0
  newImage=BlueShiftImage(constImage(),factor_,exceptionInfo);
2096
0
  replaceImage(newImage);
2097
0
  ThrowImageException;
2098
0
}
2099
2100
void Magick::Image::blur(const double radius_,const double sigma_)
2101
0
{
2102
0
  MagickCore::Image
2103
0
    *newImage;
2104
2105
0
  GetPPException;
2106
0
  newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2107
0
  replaceImage(newImage);
2108
0
  ThrowImageException;
2109
0
}
2110
2111
void Magick::Image::blurChannel(const ChannelType channel_,
2112
  const double radius_,const double sigma_)
2113
0
{
2114
0
  MagickCore::Image
2115
0
    *newImage;
2116
2117
0
  GetPPException;
2118
0
  GetAndSetPPChannelMask(channel_);
2119
0
  newImage=BlurImage(constImage(),radius_,sigma_,exceptionInfo);
2120
0
  RestorePPChannelMask;
2121
0
  replaceImage(newImage);
2122
0
  ThrowImageException;
2123
0
}
2124
2125
void Magick::Image::border(const Geometry &geometry_)
2126
0
{
2127
0
  MagickCore::Image
2128
0
    *newImage;
2129
2130
0
  RectangleInfo
2131
0
    borderInfo=geometry_;
2132
2133
0
  GetPPException;
2134
0
  newImage=BorderImage(constImage(),&borderInfo,image()->compose,
2135
0
    exceptionInfo);
2136
0
  replaceImage(newImage);
2137
0
  ThrowImageException;
2138
0
}
2139
2140
void Magick::Image::brightnessContrast(const double brightness_,
2141
  const double contrast_)
2142
0
{
2143
0
  modifyImage();
2144
0
  GetPPException;
2145
0
  BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2146
0
  ThrowImageException;
2147
0
}
2148
2149
void Magick::Image::brightnessContrastChannel(const ChannelType channel_,
2150
  const double brightness_,const double contrast_)
2151
0
{
2152
0
  modifyImage();
2153
0
  GetPPException;
2154
0
  GetAndSetPPChannelMask(channel_);
2155
0
  BrightnessContrastImage(image(),brightness_,contrast_,exceptionInfo);
2156
0
  RestorePPChannelMask;
2157
0
  ThrowImageException;
2158
0
}
2159
2160
void Magick::Image::cannyEdge(const double radius_,const double sigma_,
2161
  const double lowerPercent_,const double upperPercent_)
2162
0
{
2163
0
  MagickCore::Image
2164
0
    *newImage;
2165
2166
0
  modifyImage();
2167
0
  GetPPException;
2168
0
  newImage=CannyEdgeImage(constImage(),radius_,sigma_,lowerPercent_,
2169
0
    upperPercent_,exceptionInfo);
2170
0
  replaceImage(newImage);
2171
0
  ThrowImageException;
2172
0
}
2173
2174
void Magick::Image::cdl(const std::string &cdl_)
2175
0
{
2176
0
  modifyImage();
2177
0
  GetPPException;
2178
0
  (void) ColorDecisionListImage(image(),cdl_.c_str(),exceptionInfo);
2179
0
  ThrowImageException;
2180
0
}
2181
2182
void Magick::Image::channel(const ChannelType channel_)
2183
0
{
2184
0
  MagickCore::Image
2185
0
    *newImage;
2186
2187
0
  GetPPException;
2188
0
  newImage=SeparateImage(constImage(),channel_,exceptionInfo);
2189
0
  replaceImage(newImage);
2190
0
  ThrowImageException;
2191
0
}
2192
2193
void Magick::Image::charcoal(const double radius_,const double sigma_)
2194
0
{
2195
0
  MagickCore::Image
2196
0
    *newImage;
2197
2198
0
  GetPPException;
2199
0
  newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2200
0
  replaceImage(newImage);
2201
0
  ThrowImageException;
2202
0
}
2203
2204
void Magick::Image::charcoalChannel(const ChannelType channel_,
2205
  const double radius_,const double sigma_)
2206
0
{
2207
0
  MagickCore::Image
2208
0
    *newImage;
2209
2210
0
  GetPPException;
2211
0
  GetAndSetPPChannelMask(channel_);
2212
0
  newImage=CharcoalImage(image(),radius_,sigma_,exceptionInfo);
2213
0
  RestorePPChannelMask;
2214
0
  replaceImage(newImage);
2215
0
  ThrowImageException;
2216
0
}
2217
2218
void Magick::Image::chop(const Geometry &geometry_)
2219
0
{
2220
0
  MagickCore::Image
2221
0
    *newImage;
2222
2223
0
  RectangleInfo
2224
0
    chopInfo=geometry_;
2225
2226
0
  GetPPException;
2227
0
  newImage=ChopImage(image(),&chopInfo,exceptionInfo);
2228
0
  replaceImage(newImage);
2229
0
  ThrowImageException;
2230
0
}
2231
2232
void Magick::Image::chromaBluePrimary(const double x_,const double y_,
2233
  const double z_)
2234
0
{
2235
0
  modifyImage();
2236
0
  image()->chromaticity.blue_primary.x=x_;
2237
0
  image()->chromaticity.blue_primary.y=y_;
2238
0
  image()->chromaticity.blue_primary.z=z_;
2239
0
}
2240
2241
void Magick::Image::chromaBluePrimary(double *x_,double *y_,double *z_) const
2242
0
{
2243
0
  *x_=constImage()->chromaticity.blue_primary.x;
2244
0
  *y_=constImage()->chromaticity.blue_primary.y;
2245
0
  *z_=constImage()->chromaticity.blue_primary.z;
2246
0
}
2247
2248
void Magick::Image::chromaGreenPrimary(const double x_,const double y_,
2249
  const double z_)
2250
0
{
2251
0
  modifyImage();
2252
0
  image()->chromaticity.green_primary.x=x_;
2253
0
  image()->chromaticity.green_primary.y=y_;
2254
0
  image()->chromaticity.green_primary.z=z_;
2255
0
}
2256
2257
void Magick::Image::chromaGreenPrimary(double *x_,double *y_,double *z_) const
2258
0
{
2259
0
  *x_=constImage()->chromaticity.green_primary.x;
2260
0
  *y_=constImage()->chromaticity.green_primary.y;
2261
0
  *z_=constImage()->chromaticity.green_primary.z;
2262
0
}
2263
2264
void Magick::Image::chromaRedPrimary(const double x_,const double y_,
2265
  const double z_)
2266
0
{
2267
0
  modifyImage();
2268
0
  image()->chromaticity.red_primary.x=x_;
2269
0
  image()->chromaticity.red_primary.y=y_;
2270
0
  image()->chromaticity.red_primary.z=z_;
2271
0
}
2272
2273
void Magick::Image::chromaRedPrimary(double *x_,double *y_,double *z_) const
2274
0
{
2275
0
  *x_=constImage()->chromaticity.red_primary.x;
2276
0
  *y_=constImage()->chromaticity.red_primary.y;
2277
0
  *z_=constImage()->chromaticity.red_primary.z;
2278
0
}
2279
2280
void Magick::Image::chromaWhitePoint(const double x_,const double y_,
2281
  const double z_)
2282
0
{
2283
0
  modifyImage();
2284
0
  image()->chromaticity.white_point.x=x_;
2285
0
  image()->chromaticity.white_point.y=y_;
2286
0
  image()->chromaticity.white_point.z=z_;
2287
0
}
2288
2289
void Magick::Image::chromaWhitePoint(double *x_,double *y_,double *z_) const
2290
0
{
2291
0
  *x_=constImage()->chromaticity.white_point.x;
2292
0
  *y_=constImage()->chromaticity.white_point.y;
2293
0
  *z_=constImage()->chromaticity.white_point.z;
2294
0
}
2295
2296
void Magick::Image::clamp(void)
2297
0
{
2298
0
  modifyImage();
2299
0
  GetPPException;
2300
0
  ClampImage(image(),exceptionInfo);
2301
0
  ThrowImageException;
2302
0
}
2303
2304
void Magick::Image::clampChannel(const ChannelType channel_)
2305
0
{
2306
0
  modifyImage();
2307
0
  GetPPException;
2308
0
  GetAndSetPPChannelMask(channel_);
2309
0
  ClampImage(image(),exceptionInfo);
2310
0
  RestorePPChannelMask;
2311
0
  ThrowImageException;
2312
0
}
2313
2314
void Magick::Image::clip(void)
2315
0
{
2316
0
  modifyImage();
2317
0
  GetPPException;
2318
0
  ClipImage(image(),exceptionInfo);
2319
0
  ThrowImageException;
2320
0
}
2321
2322
void Magick::Image::clipPath(const std::string pathname_,const bool inside_)
2323
0
{
2324
0
  modifyImage();
2325
0
  GetPPException;
2326
0
  ClipImagePath(image(),pathname_.c_str(),(MagickBooleanType) inside_,
2327
0
    exceptionInfo);
2328
0
  ThrowImageException;
2329
0
}
2330
2331
void Magick::Image::clut(const Image &clutImage_,
2332
  const PixelInterpolateMethod method)
2333
0
{
2334
0
  modifyImage();
2335
0
  GetPPException;
2336
0
  ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2337
0
  ThrowImageException;
2338
0
}
2339
2340
void Magick::Image::clutChannel(const ChannelType channel_,
2341
  const Image &clutImage_,const PixelInterpolateMethod method)
2342
0
{
2343
0
  modifyImage();
2344
0
  GetPPException;
2345
0
  GetAndSetPPChannelMask(channel_);
2346
0
  ClutImage(image(),clutImage_.constImage(),method,exceptionInfo);
2347
0
  RestorePPChannelMask;
2348
0
  ThrowImageException;
2349
0
}
2350
2351
void Magick::Image::colorize(const unsigned int alpha_,const Color &penColor_)
2352
0
{
2353
0
  colorize(alpha_,alpha_,alpha_,penColor_);
2354
0
}
2355
2356
void Magick::Image::colorize(const unsigned int alphaRed_,
2357
  const unsigned int alphaGreen_,const unsigned int alphaBlue_,
2358
  const Color &penColor_)
2359
0
{
2360
0
  char
2361
0
    blend[MagickPathExtent];
2362
2363
0
  MagickCore::Image
2364
0
    *newImage;
2365
2366
0
  PixelInfo
2367
0
    target;
2368
2369
0
  if (!penColor_.isValid())
2370
0
    throwExceptionExplicit(MagickCore::OptionError,
2371
0
      "Pen color argument is invalid");
2372
2373
0
  FormatLocaleString(blend,MagickPathExtent,"%u/%u/%u",alphaRed_,alphaGreen_,
2374
0
    alphaBlue_);
2375
2376
0
  target=static_cast<PixelInfo>(penColor_);
2377
0
  GetPPException;
2378
0
  newImage=ColorizeImage(image(),blend,&target,exceptionInfo);
2379
0
  replaceImage(newImage);
2380
0
  ThrowImageException;
2381
0
}
2382
2383
void Magick::Image::colorMap(const size_t index_,const Color &color_)
2384
0
{
2385
0
  MagickCore::Image
2386
0
    *imageptr;
2387
2388
0
  imageptr=image();
2389
2390
0
  if (index_ > (MaxColormapSize-1))
2391
0
    throwExceptionExplicit(MagickCore::OptionError,
2392
0
      "Colormap index must be less than MaxColormapSize");
2393
2394
0
  if (!color_.isValid())
2395
0
    throwExceptionExplicit(MagickCore::OptionError,
2396
0
      "Color argument is invalid");
2397
2398
0
  modifyImage();
2399
2400
  // Ensure that colormap size is large enough
2401
0
  if (colorMapSize() < (index_+1))
2402
0
    colorMapSize(index_+1);
2403
2404
  // Set color at index in colormap
2405
0
  (imageptr->colormap)[index_]=color_;
2406
0
}
2407
2408
Magick::Color Magick::Image::colorMap(const size_t index_) const
2409
0
{
2410
0
  if (!constImage()->colormap)
2411
0
    {
2412
0
      throwExceptionExplicit(MagickCore::OptionError,
2413
0
        "Image does not contain a colormap");
2414
0
      return(Color());
2415
0
    }
2416
2417
0
  if (index_ > constImage()->colors-1)
2418
0
    throwExceptionExplicit(MagickCore::OptionError,"Index out of range");
2419
2420
0
  return(Magick::Color((constImage()->colormap)[index_]));
2421
0
}
2422
2423
void Magick::Image::colorMatrix(const size_t order_,
2424
  const double *color_matrix_)
2425
0
{
2426
0
  KernelInfo
2427
0
    *kernel_info;
2428
2429
0
  GetPPException;
2430
0
  kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2431
0
  if (kernel_info != (KernelInfo *) NULL)
2432
0
    {
2433
0
      kernel_info->width=order_;
2434
0
      kernel_info->height=order_;
2435
0
      kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2436
0
        order_*sizeof(*kernel_info->values));
2437
0
      if (kernel_info->values != (MagickRealType *) NULL)
2438
0
        {
2439
0
          MagickCore::Image
2440
0
            *newImage;
2441
2442
0
          for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2443
0
            kernel_info->values[i]=color_matrix_[i];
2444
0
          newImage=ColorMatrixImage(image(),kernel_info,exceptionInfo);
2445
0
          replaceImage(newImage);
2446
0
        }
2447
0
      kernel_info=DestroyKernelInfo(kernel_info);
2448
0
    }
2449
0
  ThrowImageException;
2450
0
}
2451
2452
bool Magick::Image::compare(const Image &reference_) const
2453
0
{
2454
0
  bool
2455
0
    status;
2456
2457
0
  Image
2458
0
    ref=reference_;
2459
2460
0
  GetPPException;
2461
0
  status=static_cast<bool>(IsImagesEqual(constImage(),ref.constImage(),
2462
0
    exceptionInfo));
2463
0
  ThrowImageException;
2464
0
  return(status);
2465
0
}
2466
2467
double Magick::Image::compare(const Image &reference_,const MetricType metric_)
2468
0
{
2469
0
  double
2470
0
    distortion=0.0;
2471
2472
0
  GetPPException;
2473
0
  GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2474
0
    exceptionInfo);
2475
0
  ThrowImageException;
2476
0
  return(distortion);
2477
0
}
2478
2479
double Magick::Image::compareChannel(const ChannelType channel_,
2480
  const Image &reference_,const MetricType metric_)
2481
0
{
2482
0
  double
2483
0
    distortion=0.0;
2484
2485
0
  GetPPException;
2486
0
  GetAndSetPPChannelMask(channel_);
2487
0
  GetImageDistortion(image(),reference_.constImage(),metric_,&distortion,
2488
0
    exceptionInfo);
2489
0
  RestorePPChannelMask;
2490
0
  ThrowImageException;
2491
0
  return(distortion);
2492
0
}
2493
2494
Magick::Image Magick::Image::compare(const Image &reference_,
2495
  const MetricType metric_,double *distortion)
2496
0
{
2497
0
  MagickCore::Image
2498
0
    *newImage;
2499
2500
0
  GetPPException;
2501
0
  newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2502
0
    exceptionInfo);
2503
0
  ThrowImageException;
2504
0
  if (newImage == (MagickCore::Image *) NULL)
2505
0
    return(Magick::Image());
2506
0
  else
2507
0
    return(Magick::Image(newImage));
2508
0
}
2509
2510
Magick::Image Magick::Image::compareChannel(const ChannelType channel_,
2511
  const Image &reference_,const MetricType metric_,double *distortion)
2512
0
{
2513
0
  MagickCore::Image
2514
0
    *newImage;
2515
2516
0
  GetPPException;
2517
0
  GetAndSetPPChannelMask(channel_);
2518
0
  newImage=CompareImages(image(),reference_.constImage(),metric_,distortion,
2519
0
    exceptionInfo);
2520
0
  RestorePPChannelMask;
2521
0
  ThrowImageException;
2522
0
  if (newImage == (MagickCore::Image *) NULL)
2523
0
    return(Magick::Image());
2524
0
  else
2525
0
    return(Magick::Image(newImage));
2526
0
}
2527
2528
void Magick::Image::composite(const Image &compositeImage_,
2529
  const Geometry &offset_,const CompositeOperator compose_)
2530
0
{
2531
0
  size_t
2532
0
    height=rows(),
2533
0
    width=columns();
2534
2535
0
  ssize_t
2536
0
    x=offset_.xOff(),
2537
0
    y=offset_.yOff();
2538
2539
0
  ParseMetaGeometry(static_cast<std::string>(offset_).c_str(),&x,&y,&width,
2540
0
    &height);
2541
2542
0
  modifyImage();
2543
0
  GetPPException;
2544
0
  CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2545
0
    x,y,exceptionInfo);
2546
0
  ThrowImageException;
2547
0
}
2548
2549
void Magick::Image::composite(const Image &compositeImage_,
2550
  const GravityType gravity_,const CompositeOperator compose_)
2551
0
{
2552
0
  RectangleInfo
2553
0
    geometry;
2554
2555
0
  modifyImage();
2556
0
  SetGeometry(compositeImage_.constImage(),&geometry);
2557
0
  GravityAdjustGeometry(columns(),rows(),gravity_,&geometry);
2558
2559
0
  GetPPException;
2560
0
  CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2561
0
    geometry.x,geometry.y,exceptionInfo);
2562
0
  ThrowImageException;
2563
0
}
2564
2565
void Magick::Image::composite(const Image &compositeImage_,
2566
  const ssize_t xOffset_,const ssize_t yOffset_,
2567
  const CompositeOperator compose_)
2568
0
{
2569
  // Image supplied as compositeImage is composited with current image and
2570
  // results in updating current image.
2571
0
  modifyImage();
2572
0
  GetPPException;
2573
0
  CompositeImage(image(),compositeImage_.constImage(),compose_,MagickTrue,
2574
0
    xOffset_,yOffset_,exceptionInfo);
2575
0
  ThrowImageException;
2576
0
}
2577
2578
void Magick::Image::connectedComponents(const size_t connectivity_)
2579
0
{
2580
0
  MagickCore::Image
2581
0
    *newImage;
2582
2583
0
  GetPPException;
2584
0
  newImage=ConnectedComponentsImage(constImage(),connectivity_,
2585
0
    (CCObjectInfo **) NULL,exceptionInfo);
2586
0
  replaceImage(newImage);
2587
0
  ThrowImageException;
2588
0
}
2589
2590
void Magick::Image::contrast(const bool sharpen_)
2591
0
{
2592
0
  modifyImage();
2593
0
  GetPPException;
2594
0
  ContrastImage(image(),(MagickBooleanType) sharpen_,exceptionInfo);
2595
0
  ThrowImageException;
2596
0
}
2597
2598
void Magick::Image::contrastStretch(const double blackPoint_,
2599
  const double whitePoint_)
2600
0
{
2601
0
  modifyImage();
2602
0
  GetPPException;
2603
0
  ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2604
0
  ThrowImageException;
2605
0
}
2606
2607
void Magick::Image::contrastStretchChannel(const ChannelType channel_,
2608
  const double blackPoint_,const double whitePoint_)
2609
0
{
2610
0
  modifyImage();
2611
0
  GetPPException;
2612
0
  GetAndSetPPChannelMask(channel_);
2613
0
  ContrastStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
2614
0
  RestorePPChannelMask;
2615
0
  ThrowImageException;
2616
0
}
2617
2618
void Magick::Image::convolve(const size_t order_,const double *kernel_)
2619
0
{
2620
0
  KernelInfo
2621
0
    *kernel_info;
2622
2623
0
  GetPPException;
2624
0
  kernel_info=AcquireKernelInfo((const char *) NULL,exceptionInfo);
2625
0
  kernel_info->width=order_;
2626
0
  kernel_info->height=order_;
2627
0
  kernel_info->x=(ssize_t) (order_-1)/2;
2628
0
  kernel_info->y=(ssize_t) (order_-1)/2;
2629
0
  kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order_,
2630
0
    order_*sizeof(*kernel_info->values));
2631
0
  if (kernel_info->values != (MagickRealType *) NULL)
2632
0
    {
2633
0
      MagickCore::Image
2634
0
        *newImage;
2635
2636
0
      for (ssize_t i=0; i < (ssize_t) (order_*order_); i++)
2637
0
        kernel_info->values[i]=kernel_[i];
2638
0
      newImage=ConvolveImage(image(),kernel_info,exceptionInfo);
2639
0
      replaceImage(newImage);
2640
0
    }
2641
0
  kernel_info=DestroyKernelInfo(kernel_info);
2642
0
  ThrowImageException;
2643
0
}
2644
2645
void Magick::Image::copyPixels(const Image &source_,const Geometry &geometry_,
2646
  const Offset &offset_)
2647
0
{
2648
0
  const OffsetInfo
2649
0
    offset=offset_;
2650
2651
0
  const RectangleInfo
2652
0
    geometry=geometry_;
2653
2654
0
  GetPPException;
2655
0
  (void) CopyImagePixels(image(),source_.constImage(),&geometry,&offset,
2656
0
    exceptionInfo);
2657
0
  ThrowImageException;
2658
0
}
2659
2660
void Magick::Image::crop(const Geometry &geometry_)
2661
0
{
2662
0
  MagickCore::Image
2663
0
    *newImage;
2664
2665
0
  RectangleInfo
2666
0
    cropInfo=geometry_;
2667
2668
0
  GetPPException;
2669
0
  newImage=CropImage(constImage(),&cropInfo,exceptionInfo);
2670
0
  replaceImage(newImage);
2671
0
  ThrowImageException;
2672
0
}
2673
2674
void Magick::Image::cycleColormap(const ssize_t amount_)
2675
0
{
2676
0
  modifyImage();
2677
0
  GetPPException;
2678
0
  CycleColormapImage(image(),amount_,exceptionInfo);
2679
0
  ThrowImageException;
2680
0
}
2681
2682
void Magick::Image::decipher(const std::string &passphrase_)
2683
0
{
2684
0
  modifyImage();
2685
0
  GetPPException;
2686
0
  DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2687
0
  ThrowImageException;
2688
0
}
2689
2690
void Magick::Image::defineSet(const std::string &magick_,
2691
  const std::string &key_,bool flag_)
2692
0
{
2693
0
  std::string
2694
0
    definition;
2695
2696
0
  modifyImage();
2697
0
  definition=magick_ + ":" + key_;
2698
0
  if (flag_)
2699
0
    (void) SetImageOption(imageInfo(),definition.c_str(),"");
2700
0
  else
2701
0
    DeleteImageOption(imageInfo(),definition.c_str());
2702
0
}
2703
2704
bool Magick::Image::defineSet(const std::string &magick_,
2705
  const std::string &key_ ) const
2706
0
{
2707
0
  const char
2708
0
    *option;
2709
2710
0
  std::string
2711
0
    key;
2712
2713
0
  key=magick_ + ":" + key_;
2714
0
  option=GetImageOption(constImageInfo(),key.c_str());
2715
0
  if (option)
2716
0
    return(true);
2717
0
  return(false);
2718
0
}
2719
2720
void Magick::Image::defineValue(const std::string &magick_,
2721
  const std::string &key_,const std::string &value_)
2722
0
{
2723
0
  std::string
2724
0
    format,
2725
0
    option;
2726
2727
0
  modifyImage();
2728
0
  format=magick_ + ":" + key_;
2729
0
  option=value_;
2730
0
  (void) SetImageOption(imageInfo(),format.c_str(),option.c_str());
2731
0
}
2732
2733
std::string Magick::Image::defineValue(const std::string &magick_,
2734
  const std::string &key_) const
2735
0
{
2736
0
  const char
2737
0
    *option;
2738
2739
0
  std::string
2740
0
    definition;
2741
2742
0
  definition=magick_ + ":" + key_;
2743
0
  option=GetImageOption(constImageInfo(),definition.c_str());
2744
0
  if (option)
2745
0
    return(std::string(option));
2746
0
  return(std::string());
2747
0
}
2748
2749
void Magick::Image::deskew(const double threshold_)
2750
0
{
2751
0
  MagickCore::Image
2752
0
    *newImage;
2753
2754
0
  GetPPException;
2755
0
  newImage=DeskewImage(constImage(),threshold_,exceptionInfo);
2756
0
  replaceImage(newImage);
2757
0
  ThrowImageException;
2758
0
}
2759
2760
void Magick::Image::despeckle(void)
2761
0
{
2762
0
  MagickCore::Image
2763
0
    *newImage;
2764
2765
0
  GetPPException;
2766
0
  newImage=DespeckleImage(constImage(),exceptionInfo);
2767
0
  replaceImage(newImage);
2768
0
  ThrowImageException;
2769
0
}
2770
2771
void Magick::Image::display(void)
2772
0
{
2773
0
  GetPPException;
2774
0
  DisplayImages(imageInfo(),image(),exceptionInfo);
2775
0
  ThrowImageException;
2776
0
}
2777
2778
void Magick::Image::distort(const DistortMethod method_,
2779
  const size_t numberArguments_,const double *arguments_,const bool bestfit_)
2780
0
{
2781
0
  MagickCore::Image
2782
0
    *newImage;
2783
2784
0
  GetPPException;
2785
0
  newImage=DistortImage(constImage(), method_,numberArguments_,arguments_,
2786
0
    bestfit_ == true ? MagickTrue : MagickFalse,exceptionInfo);
2787
0
  replaceImage(newImage);
2788
0
  ThrowImageException;
2789
0
}
2790
2791
void Magick::Image::draw(const Magick::Drawable &drawable_)
2792
0
{
2793
0
  DrawingWand
2794
0
    *wand;
2795
2796
0
  modifyImage();
2797
2798
0
  wand=AcquireDrawingWand(options()->drawInfo(),image());
2799
2800
0
  if(wand)
2801
0
    {
2802
0
      drawable_.operator()(wand);
2803
2804
0
      DrawRender(wand);
2805
2806
0
      ClonePPDrawException(wand);
2807
0
      wand=DestroyDrawingWand(wand);
2808
0
      ThrowPPDrawException(quiet());
2809
0
    }
2810
0
}
2811
2812
void Magick::Image::draw(const std::vector<Magick::Drawable> &drawable_)
2813
0
{
2814
0
  DrawingWand
2815
0
    *wand;
2816
2817
0
  modifyImage();
2818
2819
0
  wand= AcquireDrawingWand(options()->drawInfo(),image());
2820
2821
0
  if(wand)
2822
0
    {
2823
0
      for (std::vector<Magick::Drawable>::const_iterator p = drawable_.begin();
2824
0
           p != drawable_.end(); p++ )
2825
0
        {
2826
0
          p->operator()(wand);
2827
0
          if (DrawGetExceptionType(wand) != MagickCore::UndefinedException)
2828
0
            break;
2829
0
        }
2830
2831
0
      if (DrawGetExceptionType(wand) == MagickCore::UndefinedException)
2832
0
        DrawRender(wand);
2833
2834
0
      ClonePPDrawException(wand);
2835
0
      wand=DestroyDrawingWand(wand);
2836
0
      ThrowPPDrawException(quiet());
2837
0
    }
2838
0
}
2839
2840
void Magick::Image::edge(const double radius_)
2841
0
{
2842
0
  MagickCore::Image
2843
0
    *newImage;
2844
2845
0
  GetPPException;
2846
0
  newImage=EdgeImage(constImage(),radius_,exceptionInfo);
2847
0
  replaceImage(newImage);
2848
0
  ThrowImageException;
2849
0
}
2850
2851
void Magick::Image::emboss(const double radius_,const double sigma_)
2852
0
{
2853
0
  MagickCore::Image
2854
0
    *newImage;
2855
2856
0
  GetPPException;
2857
0
  newImage=EmbossImage(constImage(),radius_,sigma_,exceptionInfo);
2858
0
  replaceImage(newImage);
2859
0
  ThrowImageException;
2860
0
}
2861
2862
void Magick::Image::encipher(const std::string &passphrase_)
2863
0
{
2864
0
  modifyImage();
2865
0
  GetPPException;
2866
0
  EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2867
0
  ThrowImageException;
2868
0
}
2869
2870
void Magick::Image::enhance(void)
2871
0
{
2872
0
  MagickCore::Image
2873
0
    *newImage;
2874
2875
0
  GetPPException;
2876
0
  newImage=EnhanceImage(constImage(),exceptionInfo);
2877
0
  replaceImage(newImage);
2878
0
  ThrowImageException;
2879
0
}
2880
2881
void Magick::Image::equalize(void)
2882
0
{
2883
0
  modifyImage();
2884
0
  GetPPException;
2885
0
  EqualizeImage(image(),exceptionInfo);
2886
0
  ThrowImageException;
2887
0
}
2888
2889
void Magick::Image::erase(void)
2890
0
{
2891
0
  modifyImage();
2892
0
  GetPPException;
2893
0
  (void) SetImageBackgroundColor(image(),exceptionInfo);
2894
0
  ThrowImageException;
2895
0
}
2896
2897
void Magick::Image::evaluate(const ChannelType channel_,
2898
  const MagickEvaluateOperator operator_,double rvalue_)
2899
0
{
2900
0
  GetPPException;
2901
0
  GetAndSetPPChannelMask(channel_);
2902
0
  EvaluateImage(image(),operator_,rvalue_,exceptionInfo);
2903
0
  RestorePPChannelMask;
2904
0
  ThrowImageException;
2905
0
}
2906
2907
void Magick::Image::evaluate(const ChannelType channel_,
2908
  const MagickFunction function_,const size_t number_parameters_,
2909
  const double *parameters_)
2910
0
{
2911
0
  GetPPException;
2912
0
  GetAndSetPPChannelMask(channel_);
2913
0
  FunctionImage(image(),function_,number_parameters_,parameters_,
2914
0
    exceptionInfo);
2915
0
  RestorePPChannelMask;
2916
0
  ThrowImageException;
2917
0
}
2918
2919
void Magick::Image::evaluate(const ChannelType channel_,const ssize_t x_,
2920
  const ssize_t y_,const size_t columns_,const size_t rows_,
2921
  const MagickEvaluateOperator operator_,const double rvalue_)
2922
0
{
2923
0
  RectangleInfo
2924
0
    geometry;
2925
2926
0
  MagickCore::Image
2927
0
    *cropImage;
2928
2929
0
  geometry.width = columns_;
2930
0
  geometry.height = rows_;
2931
0
  geometry.x = x_;
2932
0
  geometry.y = y_;
2933
2934
0
  GetPPException;
2935
0
  cropImage=CropImage(image(),&geometry,exceptionInfo);
2936
0
  GetAndSetPPChannelMask(channel_);
2937
0
  EvaluateImage(cropImage,operator_,rvalue_,exceptionInfo);
2938
0
  RestorePPChannelMask;
2939
0
  (void) CompositeImage(image(),cropImage,image()->alpha_trait == 
2940
0
    BlendPixelTrait ? OverCompositeOp : CopyCompositeOp,MagickFalse,
2941
0
    geometry.x,geometry.y,exceptionInfo );
2942
0
  cropImage=DestroyImageList(cropImage);
2943
0
  ThrowImageException;
2944
0
}
2945
2946
void Magick::Image::extent(const Geometry &geometry_ )
2947
0
{
2948
0
  MagickCore::Image
2949
0
    *newImage;
2950
2951
0
  RectangleInfo
2952
0
    extentInfo=geometry_;
2953
2954
0
  modifyImage();
2955
0
  extentInfo.x=geometry_.xOff();
2956
0
  extentInfo.y=geometry_.yOff();
2957
0
  GetPPException;
2958
0
  newImage=ExtentImage(image(),&extentInfo,exceptionInfo);
2959
0
  replaceImage(newImage);
2960
0
  ThrowImageException;
2961
0
}
2962
2963
void Magick::Image::extent(const Geometry &geometry_,
2964
  const Color &backgroundColor_)
2965
0
{
2966
0
  backgroundColor(backgroundColor_);
2967
0
  extent(geometry_);
2968
0
}
2969
2970
void Magick::Image::extent(const Geometry &geometry_,
2971
  const Color &backgroundColor_,const GravityType gravity_)
2972
0
{
2973
0
  backgroundColor(backgroundColor_);
2974
0
  extent(geometry_,gravity_);
2975
0
}
2976
2977
void Magick::Image::extent(const Geometry &geometry_,
2978
  const GravityType gravity_)
2979
0
{
2980
0
  RectangleInfo
2981
0
    geometry;
2982
2983
0
  SetGeometry(image(),&geometry);
2984
0
  geometry.width=geometry_.width();
2985
0
  geometry.height=geometry_.height();
2986
0
  GravityAdjustGeometry(image()->columns,image()->rows,gravity_,&geometry);
2987
0
  extent(geometry);
2988
0
}
2989
2990
void Magick::Image::flip(void)
2991
0
{
2992
0
  MagickCore::Image
2993
0
    *newImage;
2994
2995
0
  GetPPException;
2996
0
  newImage=FlipImage(constImage(),exceptionInfo);
2997
0
  replaceImage(newImage);
2998
0
  ThrowImageException;
2999
0
}
3000
3001
void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
3002
  const unsigned int alpha_,const bool invert_)
3003
0
{
3004
0
  PixelInfo
3005
0
    target;
3006
3007
0
  modifyImage();
3008
3009
0
  target=static_cast<PixelInfo>(pixelColor(x_,y_));
3010
0
  target.alpha=alpha_;
3011
0
  GetPPException;
3012
0
  GetAndSetPPChannelMask(AlphaChannel);
3013
0
  FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
3014
0
    (MagickBooleanType)invert_,exceptionInfo);
3015
0
  RestorePPChannelMask;
3016
0
  ThrowImageException;
3017
0
}
3018
3019
void Magick::Image::floodFillAlpha(const ssize_t x_,const ssize_t y_,
3020
  const unsigned int alpha_,const Color &target_,const bool invert_)
3021
0
{
3022
0
  PixelInfo
3023
0
    target;
3024
3025
0
  modifyImage();
3026
3027
0
  target=static_cast<PixelInfo>(target_);
3028
0
  target.alpha=alpha_;
3029
0
  GetPPException;
3030
0
  GetAndSetPPChannelMask(AlphaChannel);
3031
0
  FloodfillPaintImage(image(),options()->drawInfo(),&target,x_,y_,
3032
0
    (MagickBooleanType)invert_,exceptionInfo);
3033
0
  RestorePPChannelMask;
3034
0
  ThrowImageException;
3035
0
}
3036
3037
void Magick::Image::floodFillColor(const Geometry &point_,
3038
  const Magick::Color &fillColor_,const bool invert_)
3039
0
{
3040
0
  floodFillColor(point_.xOff(),point_.yOff(),fillColor_,invert_);
3041
0
}
3042
3043
void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
3044
  const Magick::Color &fillColor_,const bool invert_)
3045
0
{
3046
0
  PixelInfo
3047
0
    pixel;
3048
3049
0
  modifyImage();
3050
3051
0
  pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
3052
0
  floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
3053
0
}
3054
3055
void Magick::Image::floodFillColor(const Geometry &point_,
3056
  const Magick::Color &fillColor_,const Magick::Color &borderColor_,
3057
  const bool invert_)
3058
0
{
3059
0
  floodFillColor(point_.xOff(),point_.yOff(),fillColor_,borderColor_,invert_);
3060
0
}
3061
3062
void Magick::Image::floodFillColor(const ssize_t x_,const ssize_t y_,
3063
  const Magick::Color &fillColor_,const Magick::Color &borderColor_,
3064
  const bool invert_)
3065
0
{
3066
0
  PixelInfo
3067
0
    pixel;
3068
3069
0
  modifyImage();
3070
3071
0
  pixel=static_cast<PixelInfo>(borderColor_);
3072
0
  floodFill(x_,y_,(Magick::Image *)NULL,fillColor_,&pixel,invert_);
3073
0
}
3074
3075
void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3076
  const Magick::Image &texture_,const bool invert_)
3077
0
{
3078
0
  floodFillTexture(point_.xOff(),point_.yOff(),texture_,invert_);
3079
0
}
3080
3081
void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3082
  const Magick::Image &texture_,const bool invert_)
3083
0
{
3084
0
  PixelInfo
3085
0
    pixel;
3086
3087
0
  modifyImage();
3088
3089
0
  pixel=static_cast<PixelInfo>(pixelColor(x_,y_));
3090
0
  floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3091
0
}
3092
3093
void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3094
  const Magick::Image &texture_,const Magick::Color &borderColor_,
3095
  const bool invert_)
3096
0
{
3097
0
  floodFillTexture(point_.xOff(),point_.yOff(),texture_,borderColor_,invert_);
3098
0
}
3099
3100
void Magick::Image::floodFillTexture(const ssize_t x_,const ssize_t y_,
3101
  const Magick::Image &texture_,const Magick::Color &borderColor_,
3102
  const bool invert_)
3103
0
{
3104
0
  PixelInfo
3105
0
    pixel;
3106
3107
0
  modifyImage();
3108
3109
0
  pixel=static_cast<PixelInfo>(borderColor_);
3110
0
  floodFill(x_,y_,&texture_,Magick::Color(),&pixel,invert_);
3111
0
}
3112
3113
void Magick::Image::flop(void)
3114
0
{
3115
0
  MagickCore::Image
3116
0
    *newImage;
3117
3118
0
  GetPPException;
3119
0
  newImage=FlopImage(constImage(),exceptionInfo);
3120
0
  replaceImage(newImage);
3121
0
  ThrowImageException;
3122
0
}
3123
3124
void Magick::Image::fontTypeMetrics(const std::string &text_,
3125
  TypeMetric *metrics)
3126
0
{
3127
0
  DrawInfo
3128
0
    *drawInfo;
3129
3130
0
  drawInfo=options()->drawInfo();
3131
0
  drawInfo->text=DestroyString(drawInfo->text);
3132
0
  drawInfo->text=const_cast<char *>(text_.c_str());
3133
0
  GetPPException;
3134
0
  GetTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),exceptionInfo);
3135
0
  drawInfo->text=(char *) NULL;
3136
0
  ThrowImageException;
3137
0
}
3138
3139
void Magick::Image::fontTypeMetricsMultiline(const std::string &text_,
3140
  TypeMetric *metrics)
3141
0
{
3142
0
  DrawInfo
3143
0
    *drawInfo;
3144
3145
0
  drawInfo=options()->drawInfo();
3146
0
  drawInfo->text=DestroyString(drawInfo->text);
3147
0
  drawInfo->text=const_cast<char *>(text_.c_str());
3148
0
  GetPPException;
3149
0
  (void) GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric),
3150
0
    exceptionInfo);
3151
0
  drawInfo->text=(char *) NULL;
3152
0
  ThrowImageException;
3153
0
}
3154
3155
void Magick::Image::frame(const Geometry &geometry_)
3156
0
{
3157
0
  FrameInfo
3158
0
    info;
3159
  
3160
0
  MagickCore::Image
3161
0
    *newImage;
3162
3163
0
  info.x=static_cast<ssize_t>(geometry_.width());
3164
0
  info.y=static_cast<ssize_t>(geometry_.height());
3165
0
  info.width=columns() + (static_cast<size_t>(info.x) << 1);
3166
0
  info.height=rows() + (static_cast<size_t>(info.y) << 1);
3167
0
  info.outer_bevel=geometry_.xOff();
3168
0
  info.inner_bevel=geometry_.yOff();
3169
3170
0
  GetPPException;
3171
0
  newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3172
0
  replaceImage(newImage);
3173
0
  ThrowImageException;
3174
0
}
3175
3176
void Magick::Image::frame(const size_t width_,const size_t height_,
3177
  const ssize_t innerBevel_,const ssize_t outerBevel_)
3178
0
{
3179
0
  FrameInfo
3180
0
    info;
3181
3182
0
  MagickCore::Image
3183
0
    *newImage;
3184
3185
0
  info.x=static_cast<ssize_t>(width_);
3186
0
  info.y=static_cast<ssize_t>(height_);
3187
0
  info.width=columns() + (static_cast<size_t>(info.x) << 1);
3188
0
  info.height=rows() + (static_cast<size_t>(info.y) << 1);
3189
0
  info.outer_bevel=static_cast<ssize_t>(outerBevel_);
3190
0
  info.inner_bevel=static_cast<ssize_t>(innerBevel_);
3191
3192
0
  GetPPException;
3193
0
  newImage=FrameImage(constImage(),&info,image()->compose,exceptionInfo);
3194
0
  replaceImage(newImage);
3195
0
  ThrowImageException;
3196
0
}
3197
3198
void Magick::Image::fx(const std::string expression_)
3199
0
{
3200
0
  MagickCore::Image
3201
0
    *newImage;
3202
3203
0
  GetPPException;
3204
0
  newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3205
0
  replaceImage(newImage);
3206
0
  ThrowImageException;
3207
0
}
3208
3209
void Magick::Image::fx(const std::string expression_,
3210
  const Magick::ChannelType channel_)
3211
0
{
3212
0
  MagickCore::Image
3213
0
    *newImage;
3214
3215
0
  GetPPException;
3216
0
  GetAndSetPPChannelMask(channel_);
3217
0
  newImage=FxImage(constImage(),expression_.c_str(),exceptionInfo);
3218
0
  RestorePPChannelMask;
3219
0
  replaceImage(newImage);
3220
0
  ThrowImageException;
3221
0
}
3222
3223
void Magick::Image::gamma(const double gamma_)
3224
0
{
3225
0
  modifyImage();
3226
0
  GetPPException;
3227
0
  GammaImage(image(),gamma_,exceptionInfo);
3228
0
  ThrowImageException;
3229
0
}
3230
3231
void Magick::Image::gamma(const double gammaRed_,const double gammaGreen_,
3232
  const double gammaBlue_)
3233
0
{
3234
0
  modifyImage();
3235
0
  GetPPException;
3236
0
  GetAndSetPPChannelMask(RedChannel);
3237
0
  (void) GammaImage(image(),gammaRed_,exceptionInfo);
3238
0
  SetPPChannelMask(GreenChannel);
3239
0
  (void) GammaImage(image(),gammaGreen_,exceptionInfo);
3240
0
  SetPPChannelMask(BlueChannel);
3241
0
  (void) GammaImage(image(),gammaBlue_,exceptionInfo);
3242
0
  RestorePPChannelMask;
3243
0
  ThrowImageException;
3244
0
}
3245
3246
void Magick::Image::gaussianBlur(const double radius_,const double sigma_)
3247
0
{
3248
0
  MagickCore::Image
3249
0
    *newImage;
3250
3251
0
  GetPPException;
3252
0
  newImage=GaussianBlurImage(constImage(),radius_,sigma_,exceptionInfo);
3253
0
  replaceImage(newImage);
3254
0
  ThrowImageException;
3255
0
}
3256
3257
void Magick::Image::gaussianBlurChannel(const ChannelType channel_,
3258
  const double radius_,const double sigma_)
3259
0
{
3260
0
  MagickCore::Image
3261
0
    *newImage;
3262
3263
0
  GetPPException;
3264
0
  GetAndSetPPChannelMask(channel_);
3265
0
  newImage=GaussianBlurImage(constImage(),radius_,sigma_,exceptionInfo);
3266
0
  RestorePPChannelMask;
3267
0
  replaceImage(newImage);
3268
0
  ThrowImageException;
3269
0
}
3270
3271
const Magick::Quantum *Magick::Image::getConstPixels(const ssize_t x_,
3272
  const ssize_t y_,const size_t columns_,const size_t rows_) const
3273
0
{
3274
0
  const Quantum
3275
0
    *p;
3276
3277
0
  GetPPException;
3278
0
  p=GetVirtualPixels(constImage(),x_, y_,columns_, rows_,exceptionInfo);
3279
0
  ThrowImageException;
3280
0
  return(p);
3281
0
}
3282
3283
const void *Magick::Image::getConstMetacontent(void) const
3284
0
{
3285
0
  const void
3286
0
    *result;
3287
3288
0
  result=GetVirtualMetacontent(constImage());
3289
3290
0
  if(!result)
3291
0
    throwExceptionExplicit(MagickCore::OptionError,
3292
0
      "Unable to retrieve meta content.");
3293
3294
0
  return(result);
3295
0
}
3296
3297
void *Magick::Image::getMetacontent(void )
3298
0
{
3299
0
  void
3300
0
    *result;
3301
3302
0
  result=GetAuthenticMetacontent(image());
3303
3304
0
  if(!result)
3305
0
    throwExceptionExplicit(MagickCore::OptionError,
3306
0
      "Unable to retrieve meta content.");
3307
3308
0
  return(result);
3309
0
}
3310
3311
Magick::Quantum *Magick::Image::getPixels(const ssize_t x_,const ssize_t y_,
3312
  const size_t columns_,const size_t rows_)
3313
0
{
3314
0
  Quantum
3315
0
    *result;
3316
3317
0
  modifyImage();
3318
0
  GetPPException;
3319
0
  result=GetAuthenticPixels(image(),x_, y_,columns_,rows_,exceptionInfo);
3320
0
  ThrowImageException;
3321
3322
0
  return(result);
3323
0
}
3324
3325
void Magick::Image::grayscale(const PixelIntensityMethod method_)
3326
0
{
3327
0
  modifyImage();
3328
0
  GetPPException;
3329
0
  (void) GrayscaleImage(image(),method_,exceptionInfo);
3330
0
  ThrowImageException;
3331
0
}
3332
3333
void  Magick::Image::haldClut(const Image &clutImage_)
3334
0
{
3335
0
  modifyImage();
3336
0
  GetPPException;
3337
0
  (void) HaldClutImage(image(),clutImage_.constImage(),exceptionInfo);
3338
0
  ThrowImageException;
3339
0
}
3340
3341
void Magick::Image::houghLine(const size_t width_,const size_t height_,
3342
  const size_t threshold_)
3343
0
{
3344
0
  MagickCore::Image
3345
0
    *newImage;
3346
3347
0
  GetPPException;
3348
0
  newImage=HoughLineImage(constImage(),width_,height_,threshold_,
3349
0
    exceptionInfo);
3350
0
  replaceImage(newImage);
3351
0
  ThrowImageException;
3352
0
}
3353
3354
Magick::ImageType Magick::Image::identifyType(void) const
3355
0
{
3356
0
  ImageType
3357
0
    image_type;
3358
3359
0
  GetPPException;
3360
0
  image_type=IdentifyImageType(constImage(),exceptionInfo);
3361
0
  ThrowImageException;
3362
0
  return(image_type);
3363
0
}
3364
3365
void Magick::Image::implode(const double factor_)
3366
0
{
3367
0
  MagickCore::Image
3368
0
    *newImage;
3369
3370
0
  GetPPException;
3371
0
  newImage=ImplodeImage(constImage(),factor_,image()->interpolate,
3372
0
    exceptionInfo);
3373
0
  replaceImage(newImage);
3374
0
  ThrowImageException;
3375
0
}
3376
3377
void Magick::Image::inverseFourierTransform(const Image &phase_)
3378
0
{
3379
0
  inverseFourierTransform(phase_,true);
3380
0
}
3381
3382
void Magick::Image::inverseFourierTransform(const Image &phase_,
3383
  const bool magnitude_)
3384
0
{
3385
0
  MagickCore::Image
3386
0
    *newImage;
3387
3388
0
  GetPPException;
3389
0
  newImage=InverseFourierTransformImage(constImage(),phase_.constImage(),
3390
0
    magnitude_ == true ? MagickTrue : MagickFalse,exceptionInfo);
3391
0
  replaceImage(newImage);
3392
0
  ThrowImageException;
3393
0
}
3394
3395
void Magick::Image::kuwahara(const double radius_,const double sigma_)
3396
0
{
3397
0
  MagickCore::Image
3398
0
    *newImage;
3399
3400
0
  GetPPException;
3401
0
  newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3402
0
  replaceImage(newImage);
3403
0
  ThrowImageException;
3404
0
}
3405
3406
void Magick::Image::kuwaharaChannel(const ChannelType channel_,
3407
  const double radius_,const double sigma_)
3408
0
{
3409
0
  MagickCore::Image
3410
0
    *newImage;
3411
3412
0
  GetPPException;
3413
0
  GetAndSetPPChannelMask(channel_);
3414
0
  newImage=KuwaharaImage(constImage(),radius_,sigma_,exceptionInfo);
3415
0
  replaceImage(newImage);
3416
0
  RestorePPChannelMask;
3417
0
  ThrowImageException;
3418
0
}
3419
3420
void Magick::Image::level(const double blackPoint_,const double whitePoint_,
3421
  const double gamma_)
3422
0
{
3423
0
  modifyImage();
3424
0
  GetPPException;
3425
0
  (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3426
0
  ThrowImageException;
3427
0
}
3428
3429
void Magick::Image::levelChannel(const ChannelType channel_,
3430
  const double blackPoint_,const double whitePoint_,const double gamma_)
3431
0
{
3432
0
  modifyImage();
3433
0
  GetPPException;
3434
0
  GetAndSetPPChannelMask(channel_);
3435
0
  (void) LevelImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3436
0
  RestorePPChannelMask;
3437
0
  ThrowImageException;
3438
0
}
3439
3440
void Magick::Image::levelColors(const Color &blackColor_,
3441
  const Color &whiteColor_,const bool invert_)
3442
0
{
3443
0
  PixelInfo
3444
0
    black,
3445
0
    white;
3446
3447
0
  modifyImage();
3448
3449
0
  black=static_cast<PixelInfo>(blackColor_);
3450
0
  white=static_cast<PixelInfo>(whiteColor_);
3451
0
  GetPPException;
3452
0
  (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3453
0
    MagickTrue : MagickFalse,exceptionInfo);
3454
0
  ThrowImageException;
3455
0
}
3456
3457
void Magick::Image::levelColorsChannel(const ChannelType channel_,
3458
  const Color &blackColor_,const Color &whiteColor_,const bool invert_)
3459
0
{
3460
0
  PixelInfo
3461
0
    black,
3462
0
    white;
3463
3464
0
  modifyImage();
3465
3466
0
  black=static_cast<PixelInfo>(blackColor_);
3467
0
  white=static_cast<PixelInfo>(whiteColor_);
3468
0
  GetPPException;
3469
0
  GetAndSetPPChannelMask(channel_);
3470
0
  (void) LevelImageColors(image(),&black,&white,invert_ == true ?
3471
0
    MagickTrue : MagickFalse,exceptionInfo);
3472
0
  RestorePPChannelMask;
3473
0
  ThrowImageException;
3474
0
}
3475
3476
void Magick::Image::levelize(const double blackPoint_,const double whitePoint_,
3477
  const double gamma_)
3478
0
{
3479
0
  modifyImage();
3480
0
  GetPPException;
3481
0
  (void) LevelizeImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3482
0
  ThrowImageException;
3483
0
}
3484
3485
void Magick::Image::levelizeChannel(const ChannelType channel_,
3486
  const double blackPoint_,const double whitePoint_,const double gamma_)
3487
0
{
3488
0
  modifyImage();
3489
0
  GetPPException;
3490
0
  GetAndSetPPChannelMask(channel_);
3491
0
  (void) LevelizeImage(image(),blackPoint_,whitePoint_,gamma_,exceptionInfo);
3492
0
  RestorePPChannelMask;
3493
0
  ThrowImageException;
3494
0
}
3495
3496
void Magick::Image::linearStretch(const double blackPoint_,
3497
  const double whitePoint_)
3498
0
{
3499
0
  modifyImage();
3500
0
  GetPPException;
3501
0
  LinearStretchImage(image(),blackPoint_,whitePoint_,exceptionInfo);
3502
0
  ThrowImageException;
3503
0
}
3504
3505
void Magick::Image::liquidRescale(const Geometry &geometry_)
3506
0
{
3507
0
  MagickCore::Image
3508
0
    *newImage;
3509
3510
0
  size_t
3511
0
    height=rows(),
3512
0
    width=columns();
3513
3514
0
  ssize_t
3515
0
    x=0,
3516
0
    y=0;
3517
3518
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
3519
0
    &height);
3520
3521
0
  GetPPException;
3522
0
  newImage=LiquidRescaleImage(image(),width,height,(double) x,(double) y,exceptionInfo);
3523
0
  replaceImage(newImage);
3524
0
  ThrowImageException;
3525
0
}
3526
3527
void Magick::Image::localContrast(const double radius_,const double strength_)
3528
0
{
3529
0
  MagickCore::Image
3530
0
    *newImage;
3531
3532
0
  GetPPException;
3533
0
  newImage=LocalContrastImage(constImage(),radius_,strength_,exceptionInfo);
3534
0
  replaceImage(newImage);
3535
0
  ThrowImageException;
3536
0
}
3537
3538
void Magick::Image::localContrastChannel(const ChannelType channel_,
3539
  const double radius_,const double strength_)
3540
0
{
3541
0
  MagickCore::Image
3542
0
    *newImage;
3543
3544
0
  GetPPException;
3545
0
  GetAndSetPPChannelMask(channel_);
3546
0
  newImage=LocalContrastImage(constImage(),radius_,strength_,exceptionInfo);
3547
0
  RestorePPChannelMask;
3548
0
  replaceImage(newImage);
3549
0
  ThrowImageException;
3550
0
}
3551
3552
void Magick::Image::magnify(void)
3553
0
{
3554
0
  MagickCore::Image
3555
0
    *newImage;
3556
3557
0
  GetPPException;
3558
0
  newImage=MagnifyImage(constImage(),exceptionInfo);
3559
0
  replaceImage(newImage);
3560
0
  ThrowImageException;
3561
0
}
3562
3563
void Magick::Image::map(const Image &mapImage_,const bool dither_)
3564
0
{
3565
0
  map(mapImage_, dither_ ? RiemersmaDitherMethod : NoDitherMethod);
3566
0
}
3567
3568
void Magick::Image::map(const Image &mapImage_,const DitherMethod ditherMethod_)
3569
0
{
3570
0
  modifyImage();
3571
0
  GetPPException;
3572
0
  options()->quantizeDither(ditherMethod_);
3573
0
  RemapImage(options()->quantizeInfo(),image(),mapImage_.constImage(),
3574
0
    exceptionInfo);
3575
0
  ThrowImageException;
3576
0
}
3577
3578
void Magick::Image::meanShift(const size_t width_,const size_t height_,
3579
  const double color_distance_)
3580
0
{
3581
0
  MagickCore::Image
3582
0
    *newImage;
3583
3584
0
  GetPPException;
3585
0
  newImage=MeanShiftImage(constImage(),width_,height_,color_distance_,
3586
0
    exceptionInfo);
3587
0
  replaceImage(newImage);
3588
0
  ThrowImageException;
3589
0
}
3590
3591
void Magick::Image::medianFilter(const double radius_)
3592
0
{
3593
0
  MagickCore::Image
3594
0
    *newImage;
3595
3596
0
  GetPPException;
3597
0
  newImage=StatisticImage(image(),MedianStatistic,(size_t) radius_,
3598
0
    (size_t) radius_,exceptionInfo);
3599
0
  replaceImage(newImage);
3600
0
  ThrowImageException;
3601
0
}
3602
3603
void Magick::Image::minify(void)
3604
0
{
3605
0
  MagickCore::Image
3606
0
    *newImage;
3607
3608
0
  GetPPException;
3609
0
  newImage=MinifyImage(constImage(),exceptionInfo);
3610
0
  replaceImage(newImage);
3611
0
  ThrowImageException;
3612
0
}
3613
3614
void Magick::Image::modulate(const double brightness_,const double saturation_,
3615
  const double hue_)
3616
0
{
3617
0
  char
3618
0
    modulate[MagickPathExtent + 1];
3619
3620
0
  FormatLocaleString(modulate,MagickPathExtent,"%3.6f,%3.6f,%3.6f",brightness_,
3621
0
    saturation_,hue_);
3622
3623
0
  modifyImage();
3624
0
  GetPPException;
3625
0
  ModulateImage(image(),modulate,exceptionInfo);
3626
0
  ThrowImageException;
3627
0
}
3628
3629
Magick::ImageMoments Magick::Image::moments(void) const
3630
0
{
3631
0
  return(ImageMoments(*this));
3632
0
}
3633
3634
void Magick::Image::morphology(const MorphologyMethod method_,
3635
  const std::string kernel_,const ssize_t iterations_)
3636
0
{
3637
0
  KernelInfo
3638
0
    *kernel;
3639
3640
0
  MagickCore::Image
3641
0
    *newImage;
3642
3643
0
  GetPPException;
3644
0
  kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3645
0
  if (kernel == (KernelInfo *) NULL)
3646
0
    throwExceptionExplicit(MagickCore::OptionError,"Unable to parse kernel.");
3647
0
  newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3648
0
    exceptionInfo);
3649
0
  replaceImage(newImage);
3650
0
  kernel=DestroyKernelInfo(kernel);
3651
0
  ThrowImageException;
3652
0
}
3653
3654
void Magick::Image::morphology(const MorphologyMethod method_,
3655
  const KernelInfoType kernel_,const std::string arguments_,
3656
  const ssize_t iterations_)
3657
0
{
3658
0
  const char
3659
0
    *option;
3660
3661
0
  std::string
3662
0
    kernel;
3663
3664
0
  option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3665
0
  if (option == (const char *)NULL)
3666
0
    {
3667
0
      throwExceptionExplicit(MagickCore::OptionError,
3668
0
        "Unable to determine kernel type.");
3669
0
      return;
3670
0
    }
3671
0
  kernel=std::string(option);
3672
0
  if (!arguments_.empty())
3673
0
    kernel+=":"+arguments_;
3674
3675
0
  morphology(method_,kernel,iterations_);
3676
0
}
3677
3678
void Magick::Image::morphologyChannel(const ChannelType channel_,
3679
  const MorphologyMethod method_,const std::string kernel_,
3680
  const ssize_t iterations_)
3681
0
{
3682
0
  KernelInfo
3683
0
    *kernel;
3684
3685
0
  MagickCore::Image
3686
0
    *newImage;
3687
3688
3689
0
  GetPPException;
3690
0
  kernel=AcquireKernelInfo(kernel_.c_str(),exceptionInfo);
3691
0
  if (kernel == (KernelInfo *)NULL)
3692
0
    {
3693
0
      throwExceptionExplicit(MagickCore::OptionError,
3694
0
        "Unable to parse kernel.");
3695
0
      return;
3696
0
    }
3697
0
  GetAndSetPPChannelMask(channel_);
3698
0
  newImage=MorphologyImage(constImage(),method_,iterations_,kernel,
3699
0
    exceptionInfo);
3700
0
  RestorePPChannelMask;
3701
0
  replaceImage(newImage);
3702
0
  kernel=DestroyKernelInfo(kernel);
3703
0
  ThrowImageException;
3704
0
}
3705
3706
void Magick::Image::morphologyChannel(const ChannelType channel_,
3707
  const MorphologyMethod method_,const KernelInfoType kernel_,
3708
  const std::string arguments_,const ssize_t iterations_)
3709
0
{
3710
0
  const char
3711
0
    *option;
3712
3713
0
  std::string
3714
0
    kernel;
3715
3716
0
  option=CommandOptionToMnemonic(MagickKernelOptions,kernel_);
3717
0
  if (option == (const char *)NULL)
3718
0
    {
3719
0
      throwExceptionExplicit(MagickCore::OptionError,
3720
0
        "Unable to determine kernel type.");
3721
0
      return;
3722
0
    }
3723
3724
0
  kernel=std::string(option);
3725
0
  if (!arguments_.empty())
3726
0
    kernel+=":"+arguments_;
3727
3728
0
  morphologyChannel(channel_,method_,kernel,iterations_);
3729
0
}
3730
3731
void Magick::Image::motionBlur(const double radius_,const double sigma_,
3732
  const double angle_)
3733
0
{
3734
0
  MagickCore::Image
3735
0
    *newImage;
3736
3737
0
  GetPPException;
3738
0
  newImage=MotionBlurImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
3739
0
  replaceImage(newImage);
3740
0
  ThrowImageException;
3741
0
}
3742
3743
void Magick::Image::negate(const bool grayscale_)
3744
0
{
3745
0
  modifyImage();
3746
0
  GetPPException;
3747
0
  NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3748
0
  ThrowImageException;
3749
0
}
3750
3751
void Magick::Image::negateChannel(const ChannelType channel_,
3752
  const bool grayscale_)
3753
0
{
3754
0
  modifyImage();
3755
0
  GetPPException;
3756
0
  GetAndSetPPChannelMask(channel_);
3757
0
  NegateImage(image(),(MagickBooleanType) grayscale_,exceptionInfo);
3758
0
  RestorePPChannelMask;
3759
0
  ThrowImageException;
3760
0
}
3761
3762
void Magick::Image::normalize(void)
3763
0
{
3764
0
  modifyImage();
3765
0
  GetPPException;
3766
0
  NormalizeImage(image(),exceptionInfo);
3767
0
  ThrowImageException;
3768
0
}
3769
3770
void Magick::Image::oilPaint(const double radius_,const double sigma_)
3771
0
{
3772
0
  MagickCore::Image
3773
0
    *newImage;
3774
3775
0
  GetPPException;
3776
0
  newImage=OilPaintImage(constImage(),radius_,sigma_,exceptionInfo);
3777
0
  replaceImage(newImage);
3778
0
  ThrowImageException;
3779
0
}
3780
3781
void Magick::Image::opaque(const Color &opaqueColor_,const Color &penColor_,
3782
  const bool invert_)
3783
0
{
3784
0
  std::string
3785
0
    opaqueColor,
3786
0
    penColor;
3787
3788
0
  PixelInfo
3789
0
    opaque,
3790
0
    pen;
3791
3792
0
  if (!opaqueColor_.isValid())
3793
0
    throwExceptionExplicit(MagickCore::OptionError,
3794
0
      "Opaque color argument is invalid");
3795
3796
0
  if (!penColor_.isValid())
3797
0
    throwExceptionExplicit(MagickCore::OptionError,
3798
0
      "Pen color argument is invalid");
3799
3800
0
  modifyImage();
3801
0
  opaqueColor=opaqueColor_;
3802
0
  penColor=penColor_;
3803
3804
0
  GetPPException;
3805
0
  (void) QueryColorCompliance(opaqueColor.c_str(),AllCompliance,&opaque,
3806
0
    exceptionInfo);
3807
0
  (void) QueryColorCompliance(penColor.c_str(),AllCompliance,&pen,
3808
0
    exceptionInfo);
3809
0
  OpaquePaintImage(image(),&opaque,&pen,invert_ ? MagickTrue : MagickFalse,
3810
0
    exceptionInfo);
3811
0
  ThrowImageException;
3812
0
}
3813
3814
void Magick::Image::orderedDither(std::string thresholdMap_)
3815
0
{
3816
0
  modifyImage();
3817
0
  GetPPException;
3818
0
  (void) OrderedDitherImage(image(),thresholdMap_.c_str(),exceptionInfo);
3819
0
  ThrowImageException;
3820
0
}
3821
3822
void Magick::Image::orderedDitherChannel(const ChannelType channel_,
3823
  std::string thresholdMap_)
3824
0
{
3825
0
  modifyImage();
3826
0
  GetPPException;
3827
0
  GetAndSetPPChannelMask(channel_);
3828
0
  (void)OrderedDitherImage(image(),thresholdMap_.c_str(),exceptionInfo);
3829
0
  RestorePPChannelMask;
3830
0
  ThrowImageException;
3831
0
}
3832
3833
void Magick::Image::perceptible(const double epsilon_)
3834
0
{
3835
0
  modifyImage();
3836
0
  GetPPException;
3837
0
  PerceptibleImage(image(),epsilon_,exceptionInfo);
3838
0
  ThrowImageException;
3839
0
}
3840
3841
void Magick::Image::perceptibleChannel(const ChannelType channel_,
3842
  const double epsilon_)
3843
0
{
3844
0
  modifyImage();
3845
0
  GetPPException;
3846
0
  GetAndSetPPChannelMask(channel_);
3847
0
  PerceptibleImage(image(),epsilon_,exceptionInfo);
3848
0
  RestorePPChannelMask;
3849
0
  ThrowImageException;
3850
0
}
3851
3852
 Magick::ImagePerceptualHash Magick::Image::perceptualHash() const
3853
0
{
3854
0
  return(ImagePerceptualHash(*this));
3855
0
}
3856
3857
void Magick::Image::ping(const std::string &imageSpec_)
3858
0
{
3859
0
  MagickCore::Image
3860
0
    *newImage;
3861
3862
0
  GetPPException;
3863
0
  options()->fileName(imageSpec_);
3864
0
  newImage=PingImage(imageInfo(),exceptionInfo);
3865
0
  read(newImage,exceptionInfo);
3866
0
}
3867
3868
void Magick::Image::ping(const Blob& blob_)
3869
39.9k
{
3870
39.9k
  MagickCore::Image
3871
39.9k
    *newImage;
3872
3873
39.9k
  GetPPException;
3874
39.9k
  newImage=PingBlob(imageInfo(),blob_.data(),blob_.length(),exceptionInfo);
3875
39.9k
  read(newImage,exceptionInfo);
3876
39.9k
}
3877
3878
void Magick::Image::pixelColor(const ssize_t x_,const ssize_t y_,
3879
  const Color &color_)
3880
0
{
3881
0
  PixelInfo
3882
0
    packet;
3883
3884
0
  Quantum
3885
0
    *pixel;
3886
3887
  // Test arguments to ensure they are within the image.
3888
0
  if (y_ > (ssize_t) rows() || x_ > (ssize_t) columns())
3889
0
    throwExceptionExplicit(MagickCore::OptionError,
3890
0
      "Access outside of image boundary");
3891
3892
0
  modifyImage();
3893
3894
  // Set image to DirectClass
3895
0
  classType(DirectClass );
3896
3897
  // Get pixel view
3898
0
  Pixels pixels(*this);
3899
    // Set pixel value
3900
0
  pixel=pixels.get(x_, y_, 1, 1 );
3901
0
  packet=color_;
3902
0
  MagickCore::SetPixelViaPixelInfo(constImage(),&packet,pixel);
3903
  // Tell ImageMagick that pixels have been updated
3904
0
  pixels.sync();
3905
0
}
3906
3907
Magick::Color Magick::Image::pixelColor(const ssize_t x_,
3908
  const ssize_t y_) const
3909
0
{
3910
0
  const Quantum
3911
0
    *pixel;
3912
3913
0
  pixel=getConstPixels(x_,y_,1,1);
3914
0
  if (pixel)
3915
0
    {
3916
0
      PixelInfo
3917
0
        packet;
3918
3919
0
      MagickCore::GetPixelInfoPixel(constImage(),pixel,&packet);
3920
0
      return(Color(packet));
3921
0
    }
3922
3923
0
  return(Color()); // invalid
3924
0
}
3925
3926
void Magick::Image::polaroid(const std::string &caption_,const double angle_,
3927
  const PixelInterpolateMethod method_)
3928
0
{
3929
0
  MagickCore::Image
3930
0
    *newImage;
3931
3932
0
  GetPPException;
3933
0
  newImage=PolaroidImage(constImage(),options()->drawInfo(),caption_.c_str(),
3934
0
    angle_,method_,exceptionInfo);
3935
0
  replaceImage(newImage);
3936
0
  ThrowImageException;
3937
0
}
3938
3939
void Magick::Image::posterize(const size_t levels_,const DitherMethod method_)
3940
0
{
3941
0
  modifyImage();
3942
0
  GetPPException;
3943
0
  PosterizeImage(image(),levels_,method_,exceptionInfo);
3944
0
  ThrowImageException;
3945
0
}
3946
3947
void Magick::Image::posterizeChannel(const ChannelType channel_,
3948
  const size_t levels_,const DitherMethod method_)
3949
0
{
3950
0
  modifyImage();
3951
0
  GetPPException;
3952
0
  GetAndSetPPChannelMask(channel_);
3953
0
  PosterizeImage(image(),levels_,method_,exceptionInfo);
3954
0
  RestorePPChannelMask;
3955
0
  ThrowImageException;
3956
0
}
3957
3958
void Magick::Image::process(std::string name_,const ssize_t argc,
3959
  const char **argv)
3960
0
{
3961
0
  modifyImage();
3962
3963
0
  GetPPException;
3964
0
  (void) InvokeDynamicImageFilter(name_.c_str(),&image(),(int) argc,argv,
3965
0
    exceptionInfo);
3966
0
  ThrowImageException;
3967
0
}
3968
3969
void Magick::Image::profile(const std::string name_,
3970
  const Magick::Blob &profile_)
3971
4.02k
{
3972
4.02k
  modifyImage();
3973
4.02k
  GetPPException;
3974
4.02k
  (void) ProfileImage(image(),name_.c_str(),(unsigned char *)profile_.data(),
3975
4.02k
    profile_.length(),exceptionInfo);
3976
4.02k
  ThrowImageException;
3977
4.02k
}
3978
3979
Magick::Blob Magick::Image::profile(const std::string name_) const
3980
0
{
3981
0
  const StringInfo
3982
0
    *profile;
3983
3984
0
  profile=GetImageProfile(constImage(),name_.c_str());
3985
3986
0
  if (profile == (StringInfo *) NULL)
3987
0
    return(Blob());
3988
0
  return(Blob((void*) GetStringInfoDatum(profile),GetStringInfoLength(
3989
0
    profile)));
3990
0
}
3991
3992
void Magick::Image::quantize(const bool measureError_)
3993
0
{
3994
0
  modifyImage();
3995
 
3996
0
  if (measureError_)
3997
0
    options()->quantizeInfo()->measure_error=MagickTrue;
3998
0
  else
3999
0
    options()->quantizeInfo()->measure_error=MagickFalse;
4000
4001
0
  GetPPException;
4002
0
  QuantizeImage(options()->quantizeInfo(),image(),exceptionInfo);
4003
0
  ThrowImageException;
4004
0
}
4005
4006
void Magick::Image::raise(const Geometry &geometry_,const bool raisedFlag_)
4007
0
{
4008
0
  RectangleInfo
4009
0
    raiseInfo=geometry_;
4010
4011
0
  GetPPException;
4012
0
  modifyImage();
4013
0
  RaiseImage(image(),&raiseInfo,raisedFlag_ == true ? MagickTrue : MagickFalse,
4014
0
    exceptionInfo);
4015
0
  ThrowImageException;
4016
0
}
4017
4018
void Magick::Image::randomThreshold(const double low_,const double high_)
4019
0
{
4020
0
  GetPPException;
4021
0
  (void) RandomThresholdImage(image(),low_,high_,exceptionInfo);
4022
0
  ThrowImageException;
4023
0
}
4024
4025
void Magick::Image::randomThresholdChannel(const ChannelType channel_,
4026
  const double low_,const double high_)
4027
0
{
4028
0
  modifyImage();
4029
0
  GetPPException;
4030
0
  GetAndSetPPChannelMask(channel_);
4031
0
  (void) RandomThresholdImage(image(),low_,high_,exceptionInfo);
4032
0
  RestorePPChannelMask;
4033
0
  ThrowImageException;
4034
0
}
4035
4036
void Magick::Image::read(const Blob &blob_)
4037
526k
{
4038
526k
  MagickCore::Image
4039
526k
    *newImage;
4040
4041
526k
  GetPPException;
4042
526k
  newImage=BlobToImage(imageInfo(),static_cast<const void *>(blob_.data()),
4043
526k
    blob_.length(),exceptionInfo);
4044
526k
  read(newImage,exceptionInfo);
4045
526k
}
4046
4047
void Magick::Image::read(const Blob &blob_,const Geometry &size_)
4048
0
{
4049
0
  size(size_);
4050
0
  read(blob_);
4051
0
}
4052
4053
void Magick::Image::read(const Blob &blob_,const Geometry &size_,
4054
  const size_t depth_)
4055
0
{
4056
0
  size(size_);
4057
0
  depth(depth_);
4058
0
  read(blob_);
4059
0
}
4060
4061
void Magick::Image::read(const Blob &blob_,const Geometry &size_,
4062
  const size_t depth_,const std::string &magick_)
4063
0
{
4064
0
  size(size_);
4065
0
  depth(depth_);
4066
0
  magick(magick_);
4067
  // Set explicit image format
4068
0
  fileName(magick_ + ':');
4069
0
  read(blob_);
4070
0
}
4071
4072
void Magick::Image::read(const Blob &blob_,const Geometry &size_,
4073
  const std::string &magick_)
4074
0
{
4075
0
  size(size_);
4076
0
  magick(magick_);
4077
  // Set explicit image format
4078
0
  fileName(magick_ + ':');
4079
0
  read(blob_);
4080
0
}
4081
4082
void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
4083
0
{
4084
0
  size(size_);
4085
0
  read(imageSpec_);
4086
0
}
4087
4088
void Magick::Image::read(const size_t width_,const size_t height_,
4089
  const std::string &map_,const StorageType type_,const void *pixels_)
4090
0
{
4091
0
  MagickCore::Image
4092
0
    *newImage;
4093
4094
0
  GetPPException;
4095
0
  newImage=ConstituteImage(width_,height_,map_.c_str(),type_, pixels_,
4096
0
    exceptionInfo);
4097
0
  replaceImage(newImage);
4098
0
  ThrowImageException;
4099
0
}
4100
4101
void Magick::Image::read(const std::string &imageSpec_)
4102
33.3k
{
4103
33.3k
  MagickCore::Image
4104
33.3k
    *newImage;
4105
4106
33.3k
  GetPPException;
4107
33.3k
  options()->fileName(imageSpec_);
4108
33.3k
  newImage=ReadImage(imageInfo(),exceptionInfo);
4109
33.3k
  read(newImage,exceptionInfo);
4110
33.3k
}
4111
4112
void Magick::Image::readMask(const Magick::Image &mask_)
4113
0
{
4114
0
  mask(mask_,ReadPixelMask);
4115
0
}
4116
4117
Magick::Image Magick::Image::readMask(void) const
4118
0
{
4119
0
  return(mask(ReadPixelMask));
4120
0
}
4121
4122
void Magick::Image::readPixels(const Magick::QuantumType quantum_,
4123
  const unsigned char *source_)
4124
0
{
4125
0
  QuantumInfo
4126
0
    *quantum_info;
4127
4128
0
  quantum_info=AcquireQuantumInfo(imageInfo(),image());
4129
0
  GetPPException;
4130
0
  ImportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4131
0
    quantum_,source_,exceptionInfo);
4132
0
  quantum_info=DestroyQuantumInfo(quantum_info);
4133
0
  ThrowImageException;
4134
0
}
4135
4136
void Magick::Image::reduceNoise(void)
4137
0
{
4138
0
  reduceNoise(3);
4139
0
}
4140
4141
void Magick::Image::reduceNoise(const size_t order_)
4142
0
{
4143
0
  MagickCore::Image
4144
0
    *newImage;
4145
4146
0
  GetPPException;
4147
0
  newImage=StatisticImage(constImage(),NonpeakStatistic,order_,
4148
0
    order_,exceptionInfo);
4149
0
  replaceImage(newImage);
4150
0
  ThrowImageException;
4151
0
}
4152
4153
void Magick::Image::repage()
4154
0
{
4155
0
  modifyImage();
4156
0
  options()->page(Geometry());
4157
0
  image()->page.width = 0;
4158
0
  image()->page.height = 0;
4159
0
  image()->page.x = 0;
4160
0
  image()->page.y = 0;
4161
0
}
4162
4163
void Magick::Image::resample(const Point &density_)
4164
0
{
4165
0
  MagickCore::Image
4166
0
    *newImage;
4167
4168
0
  GetPPException;
4169
0
  newImage=ResampleImage(constImage(),density_.x(),density_.y(),
4170
0
    image()->filter,exceptionInfo);
4171
0
  replaceImage(newImage);
4172
0
  ThrowImageException;
4173
0
}
4174
4175
void Magick::Image::resize(const Geometry &geometry_)
4176
0
{
4177
0
  MagickCore::Image
4178
0
    *newImage;
4179
4180
0
  size_t
4181
0
    height=rows(),
4182
0
    width=columns();
4183
4184
0
  ssize_t
4185
0
    x=0,
4186
0
    y=0;
4187
4188
  // Calculate new size.  This code should be supported using binary arguments
4189
  // in the ImageMagick library.
4190
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4191
0
    &height);
4192
4193
0
  GetPPException;
4194
0
  newImage=ResizeImage(constImage(),width,height,image()->filter,
4195
0
    exceptionInfo);
4196
0
  replaceImage(newImage);
4197
0
  ThrowImageException;
4198
0
}
4199
4200
void Magick::Image::roll(const Geometry &roll_)
4201
0
{
4202
0
  MagickCore::Image
4203
0
    *newImage;
4204
4205
0
  GetPPException;
4206
0
  newImage=RollImage(constImage(),roll_.xOff(),roll_.yOff(),exceptionInfo);
4207
0
  replaceImage(newImage);
4208
0
  ThrowImageException;
4209
0
}
4210
4211
void Magick::Image::roll(const ssize_t columns_,const ssize_t rows_)
4212
0
{
4213
0
  MagickCore::Image
4214
0
    *newImage;
4215
4216
0
  GetPPException;
4217
0
  newImage=RollImage(constImage(),columns_, rows_,exceptionInfo);
4218
0
  replaceImage(newImage);
4219
0
  ThrowImageException;
4220
0
}
4221
4222
void Magick::Image::rotate(const double degrees_)
4223
0
{
4224
0
  MagickCore::Image
4225
0
    *newImage;
4226
4227
0
  GetPPException;
4228
0
  newImage=RotateImage(constImage(),degrees_,exceptionInfo);
4229
0
  replaceImage(newImage);
4230
0
  ThrowImageException;
4231
0
}
4232
4233
void Magick::Image::rotationalBlur(const double angle_)
4234
0
{
4235
0
  MagickCore::Image
4236
0
    *newImage;
4237
4238
0
  GetPPException;
4239
0
  newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4240
0
  replaceImage(newImage);
4241
0
  ThrowImageException;
4242
0
}
4243
4244
void Magick::Image::rotationalBlurChannel(const ChannelType channel_,
4245
  const double angle_)
4246
0
{
4247
0
  MagickCore::Image
4248
0
    *newImage;
4249
4250
0
  GetPPException;
4251
0
  GetAndSetPPChannelMask(channel_);
4252
0
  newImage=RotationalBlurImage(constImage(),angle_,exceptionInfo);
4253
0
  RestorePPChannelMask;
4254
0
  replaceImage(newImage);
4255
0
  ThrowImageException;
4256
0
}
4257
4258
void Magick::Image::sample(const Geometry &geometry_)
4259
0
{
4260
0
  MagickCore::Image
4261
0
    *newImage;
4262
4263
0
  size_t
4264
0
    height=rows(),
4265
0
    width=columns();
4266
4267
0
  ssize_t
4268
0
    x=0,
4269
0
    y=0;
4270
4271
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4272
0
    &height);
4273
4274
0
  GetPPException;
4275
0
  newImage=SampleImage(constImage(),width,height,exceptionInfo);
4276
0
  replaceImage(newImage);
4277
0
  ThrowImageException;
4278
0
}
4279
4280
void Magick::Image::scale(const Geometry &geometry_)
4281
0
{
4282
0
  MagickCore::Image
4283
0
    *newImage;
4284
4285
0
  size_t
4286
0
    height=rows(),
4287
0
    width=columns();
4288
4289
0
  ssize_t
4290
0
    x=0,
4291
0
    y=0;
4292
4293
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4294
0
    &height);
4295
4296
0
  GetPPException;
4297
0
  newImage=ScaleImage(constImage(),width,height,exceptionInfo);
4298
0
  replaceImage(newImage);
4299
0
  ThrowImageException;
4300
0
}
4301
4302
void Magick::Image::segment(const double clusterThreshold_,
4303
  const double smoothingThreshold_)
4304
0
{
4305
0
  modifyImage();
4306
0
  GetPPException;
4307
0
  SegmentImage(image(),options()->quantizeColorSpace(),
4308
0
    (MagickBooleanType) options()->verbose(),clusterThreshold_,
4309
0
    smoothingThreshold_,exceptionInfo);
4310
0
  SyncImage(image(),exceptionInfo);
4311
0
  ThrowImageException;
4312
0
}
4313
4314
void Magick::Image::selectiveBlur(const double radius_,const double sigma_,
4315
  const double threshold_)
4316
0
{
4317
0
  MagickCore::Image
4318
0
    *newImage;
4319
4320
0
  GetPPException;
4321
0
  newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4322
0
    exceptionInfo);
4323
0
  replaceImage(newImage);
4324
0
  ThrowImageException;
4325
0
}
4326
4327
void Magick::Image::selectiveBlurChannel(const ChannelType channel_,
4328
  const double radius_,const double sigma_,const double threshold_)
4329
0
{
4330
0
  MagickCore::Image
4331
0
    *newImage;
4332
4333
0
  GetPPException;
4334
0
  GetAndSetPPChannelMask(channel_);
4335
0
  newImage=SelectiveBlurImage(constImage(),radius_,sigma_,threshold_,
4336
0
    exceptionInfo);
4337
0
  RestorePPChannelMask;
4338
0
  replaceImage(newImage);
4339
0
  ThrowImageException;
4340
0
}
4341
4342
Magick::Image Magick::Image::separate(const ChannelType channel_) const
4343
0
{
4344
0
  MagickCore::Image
4345
0
    *image;
4346
4347
0
  GetPPException;
4348
0
  image=SeparateImage(constImage(),channel_,exceptionInfo);
4349
0
  ThrowImageException;
4350
0
  if (image == (MagickCore::Image *) NULL)
4351
0
    return(Magick::Image());
4352
0
  else
4353
0
    return(Magick::Image(image));
4354
0
}
4355
4356
void Magick::Image::sepiaTone(const double threshold_)
4357
0
{
4358
0
  MagickCore::Image
4359
0
    *newImage;
4360
4361
0
  GetPPException;
4362
0
  newImage=SepiaToneImage(constImage(),threshold_,exceptionInfo);
4363
0
  replaceImage(newImage);
4364
0
  ThrowImageException;
4365
0
}
4366
4367
bool Magick::Image::setColorMetric(const Image &reference_)
4368
0
{
4369
0
  bool
4370
0
    status;
4371
4372
0
  Image
4373
0
    ref=reference_;
4374
4375
0
  GetPPException;
4376
0
  modifyImage();
4377
0
  status=static_cast<bool>(SetImageColorMetric(image(),ref.constImage(),
4378
0
    exceptionInfo));
4379
0
  ThrowImageException;
4380
0
  return(status);
4381
0
}
4382
4383
Magick::Quantum *Magick::Image::setPixels(const ssize_t x_,const ssize_t y_,
4384
  const size_t columns_,const size_t rows_)
4385
0
{
4386
0
  Quantum
4387
0
    *result;
4388
4389
0
  modifyImage();
4390
0
  GetPPException;
4391
0
  result=QueueAuthenticPixels(image(),x_,y_,columns_,rows_,exceptionInfo);
4392
0
  ThrowImageException;
4393
0
  return(result);
4394
0
}
4395
4396
void Magick::Image::shade(const double azimuth_,const double elevation_,
4397
  const bool colorShading_)
4398
0
{
4399
0
  MagickCore::Image
4400
0
    *newImage;
4401
4402
0
  GetPPException;
4403
0
  newImage=ShadeImage(constImage(),colorShading_ == true ?
4404
0
    MagickTrue : MagickFalse,azimuth_,elevation_,exceptionInfo);
4405
0
  replaceImage(newImage);
4406
0
  ThrowImageException;
4407
0
}
4408
4409
void Magick::Image::shadow(const double percent_opacity_,const double sigma_,
4410
  const ssize_t x_,const ssize_t y_)
4411
0
{
4412
0
  MagickCore::Image
4413
0
    *newImage;
4414
4415
0
  GetPPException;
4416
0
  newImage=ShadowImage(constImage(),percent_opacity_, sigma_,x_, y_,
4417
0
    exceptionInfo);
4418
0
  replaceImage(newImage);
4419
0
  ThrowImageException;
4420
0
}
4421
4422
void Magick::Image::sharpen(const double radius_,const double sigma_)
4423
0
{
4424
0
  MagickCore::Image
4425
0
    *newImage;
4426
4427
0
  GetPPException;
4428
0
  newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4429
0
  replaceImage(newImage);
4430
0
  ThrowImageException;
4431
0
}
4432
4433
void Magick::Image::sharpenChannel(const ChannelType channel_,
4434
  const double radius_,const double sigma_)
4435
0
{
4436
0
  MagickCore::Image
4437
0
    *newImage;
4438
4439
0
  GetPPException;
4440
0
  GetAndSetPPChannelMask(channel_);
4441
0
  newImage=SharpenImage(constImage(),radius_,sigma_,exceptionInfo);
4442
0
  RestorePPChannelMask;
4443
0
  replaceImage(newImage);
4444
0
  ThrowImageException;
4445
0
}
4446
4447
void Magick::Image::shave(const Geometry &geometry_)
4448
0
{
4449
0
  MagickCore::Image
4450
0
    *newImage;
4451
4452
0
  RectangleInfo
4453
0
    shaveInfo=geometry_;
4454
4455
0
  GetPPException;
4456
0
  newImage=ShaveImage(constImage(),&shaveInfo,exceptionInfo);
4457
0
  replaceImage(newImage);
4458
0
  ThrowImageException;
4459
0
}
4460
4461
void Magick::Image::shear(const double xShearAngle_,const double yShearAngle_)
4462
0
{
4463
0
  MagickCore::Image
4464
0
    *newImage;
4465
4466
0
  GetPPException;
4467
0
  newImage=ShearImage(constImage(),xShearAngle_,yShearAngle_,exceptionInfo);
4468
0
  replaceImage(newImage);
4469
0
  ThrowImageException;
4470
0
}
4471
4472
void Magick::Image::sigmoidalContrast(const bool sharpen_,
4473
  const double contrast,const double midpoint)
4474
0
{
4475
0
  modifyImage();
4476
0
  GetPPException;
4477
0
  (void) SigmoidalContrastImage(image(),(MagickBooleanType) sharpen_,contrast,
4478
0
    midpoint,exceptionInfo);
4479
0
  ThrowImageException;
4480
0
}
4481
4482
std::string Magick::Image::signature(const bool force_) const
4483
0
{
4484
0
  return(_imgRef->signature(force_));
4485
0
}
4486
4487
void Magick::Image::sketch(const double radius_,const double sigma_,
4488
  const double angle_)
4489
0
{
4490
0
  MagickCore::Image
4491
0
    *newImage;
4492
4493
0
  GetPPException;
4494
0
  newImage=SketchImage(constImage(),radius_,sigma_,angle_,exceptionInfo);
4495
0
  replaceImage(newImage);
4496
0
  ThrowImageException;
4497
0
}
4498
4499
void Magick::Image::solarize(const double factor_)
4500
0
{
4501
0
  modifyImage();
4502
0
  GetPPException;
4503
0
  SolarizeImage(image(),factor_,exceptionInfo);
4504
0
  ThrowImageException;
4505
0
}
4506
4507
void Magick::Image::sparseColor(const ChannelType channel_,
4508
  const SparseColorMethod method_,const size_t numberArguments_,
4509
  const double *arguments_)
4510
0
{
4511
0
  MagickCore::Image
4512
0
    *newImage;
4513
4514
0
  GetPPException;
4515
0
  GetAndSetPPChannelMask(channel_);
4516
0
  newImage=SparseColorImage(constImage(),method_,numberArguments_,arguments_,
4517
0
    exceptionInfo);
4518
0
  RestorePPChannelMask;
4519
0
  replaceImage(newImage);
4520
0
  ThrowImageException;
4521
0
}
4522
4523
void Magick::Image::splice(const Geometry &geometry_)
4524
0
{
4525
0
  MagickCore::Image
4526
0
    *newImage;
4527
4528
0
  RectangleInfo
4529
0
    spliceInfo=geometry_;
4530
4531
0
  GetPPException;
4532
0
  newImage=SpliceImage(constImage(),&spliceInfo,exceptionInfo);
4533
0
  replaceImage(newImage);
4534
0
  ThrowImageException;
4535
0
}
4536
4537
void Magick::Image::splice(const Geometry &geometry_,
4538
  const Color &backgroundColor_)
4539
0
{
4540
0
  backgroundColor(backgroundColor_);
4541
0
  splice(geometry_);
4542
0
}
4543
4544
void Magick::Image::splice(const Geometry &geometry_,
4545
  const Color &backgroundColor_,const GravityType gravity_)
4546
0
{
4547
0
  backgroundColor(backgroundColor_);
4548
0
  image()->gravity=gravity_;
4549
0
  splice(geometry_);
4550
0
}
4551
4552
void Magick::Image::spread(const double amount_)
4553
0
{
4554
0
  MagickCore::Image
4555
0
    *newImage;
4556
4557
0
  GetPPException;
4558
0
  newImage=SpreadImage(constImage(),image()->interpolate,amount_,exceptionInfo);
4559
0
  replaceImage(newImage);
4560
0
  ThrowImageException;
4561
0
}
4562
4563
Magick::ImageStatistics Magick::Image::statistics() const
4564
0
{
4565
0
  return(ImageStatistics(*this));
4566
0
}
4567
4568
void Magick::Image::stegano(const Image &watermark_)
4569
0
{
4570
0
  MagickCore::Image
4571
0
    *newImage;
4572
4573
0
  GetPPException;
4574
0
  newImage=SteganoImage(constImage(),watermark_.constImage(),exceptionInfo);
4575
0
  replaceImage(newImage);
4576
0
  ThrowImageException;
4577
0
}
4578
4579
void Magick::Image::stereo(const Image &rightImage_)
4580
0
{
4581
0
  MagickCore::Image
4582
0
    *newImage;
4583
4584
0
  GetPPException;
4585
0
  newImage=StereoImage(constImage(),rightImage_.constImage(),exceptionInfo);
4586
0
  replaceImage(newImage);
4587
0
  ThrowImageException;
4588
0
}
4589
4590
void Magick::Image::strip(void)
4591
0
{
4592
0
  modifyImage();
4593
0
  GetPPException;
4594
0
  StripImage(image(),exceptionInfo);
4595
0
  ThrowImageException;
4596
0
}
4597
4598
Magick::Image Magick::Image::subImageSearch(const Image &reference_,
4599
  const MetricType metric_,Geometry *offset_,double *similarityMetric_,
4600
  const double similarityThreshold)
4601
0
{
4602
0
  MagickCore::Image
4603
0
    *newImage;
4604
4605
0
  RectangleInfo
4606
0
    offset;
4607
4608
0
  GetPPException;
4609
0
  newImage=SimilarityImage(image(),reference_.constImage(),metric_,
4610
0
    similarityThreshold,&offset,similarityMetric_,exceptionInfo);
4611
0
  ThrowImageException;
4612
0
  if (offset_ != (Geometry *) NULL)
4613
0
    *offset_=offset;
4614
0
  if (newImage == (MagickCore::Image *) NULL)
4615
0
    return(Magick::Image());
4616
0
  else
4617
0
    return(Magick::Image(newImage));
4618
0
}
4619
4620
void Magick::Image::swirl(const double degrees_)
4621
0
{
4622
0
  MagickCore::Image
4623
0
    *newImage;
4624
4625
0
  GetPPException;
4626
0
  newImage=SwirlImage(constImage(),degrees_,image()->interpolate,
4627
0
    exceptionInfo);
4628
0
  replaceImage(newImage);
4629
0
  ThrowImageException;
4630
0
}
4631
4632
void Magick::Image::syncPixels(void)
4633
0
{
4634
0
  GetPPException;
4635
0
  (void) SyncAuthenticPixels(image(),exceptionInfo);
4636
0
  ThrowImageException;
4637
0
}
4638
4639
void Magick::Image::texture(const Image &texture_)
4640
0
{
4641
0
  modifyImage();
4642
0
  GetPPException;
4643
0
  TextureImage(image(),texture_.constImage(),exceptionInfo);
4644
0
  ThrowImageException;
4645
0
}
4646
4647
void Magick::Image::threshold(const double threshold_)
4648
0
{
4649
0
  modifyImage();
4650
0
  GetPPException;
4651
0
  BilevelImage(image(),threshold_,exceptionInfo);
4652
0
  ThrowImageException;
4653
0
}
4654
4655
void Magick::Image::thumbnail(const Geometry &geometry_)
4656
0
{
4657
0
  MagickCore::Image
4658
0
    *newImage;
4659
4660
0
  size_t
4661
0
    height=rows(),
4662
0
    width=columns();
4663
4664
0
  ssize_t
4665
0
    x=0,
4666
0
    y=0;
4667
4668
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
4669
0
    &height);
4670
4671
0
  GetPPException;
4672
0
  newImage=ThumbnailImage(constImage(),width,height,exceptionInfo);
4673
0
  replaceImage(newImage);
4674
0
  ThrowImageException;
4675
0
}
4676
4677
void Magick::Image::tint(const std::string opacity_)
4678
0
{
4679
0
  MagickCore::Image
4680
0
    *newImage;
4681
4682
0
  PixelInfo
4683
0
    color;
4684
4685
0
  GetPPException;
4686
0
  color=static_cast<PixelInfo>(constOptions()->fillColor());
4687
0
  newImage=TintImage(constImage(),opacity_.c_str(),&color,exceptionInfo);
4688
0
  replaceImage(newImage);
4689
0
  ThrowImageException;
4690
0
}
4691
4692
void Magick::Image::transformOrigin(const double x_,const double y_)
4693
0
{
4694
0
  modifyImage();
4695
0
  options()->transformOrigin(x_,y_);
4696
0
}
4697
4698
void Magick::Image::transformReset(void)
4699
0
{
4700
0
  modifyImage();
4701
0
  options()->transformReset();
4702
0
}
4703
4704
void Magick::Image::transformScale(const double sx_,const double sy_)
4705
0
{
4706
0
  modifyImage();
4707
0
  options()->transformScale(sx_,sy_);
4708
0
}
4709
4710
void Magick::Image::transparent(const Color &color_,const bool inverse_)
4711
0
{
4712
0
  PixelInfo
4713
0
    target;
4714
4715
0
  std::string
4716
0
    color;
4717
4718
0
  if (!color_.isValid())
4719
0
    throwExceptionExplicit(MagickCore::OptionError,
4720
0
      "Color argument is invalid");
4721
4722
0
  color=color_;
4723
0
  GetPPException;
4724
0
  (void) QueryColorCompliance(color.c_str(),AllCompliance,&target,
4725
0
    exceptionInfo);
4726
0
  modifyImage();
4727
0
  TransparentPaintImage(image(),&target,TransparentAlpha,
4728
0
    inverse_ == true ? MagickTrue : MagickFalse,exceptionInfo);
4729
0
  ThrowImageException;
4730
0
}
4731
4732
void Magick::Image::transparentChroma(const Color &colorLow_,
4733
  const Color &colorHigh_)
4734
0
{
4735
0
  std::string
4736
0
    colorHigh,
4737
0
    colorLow;
4738
4739
0
  PixelInfo
4740
0
    targetHigh,
4741
0
    targetLow;
4742
4743
0
  if (!colorLow_.isValid() || !colorHigh_.isValid())
4744
0
    throwExceptionExplicit(MagickCore::OptionError,
4745
0
      "Color argument is invalid");
4746
4747
0
  colorLow=colorLow_;
4748
0
  colorHigh=colorHigh_;
4749
4750
0
  GetPPException;
4751
0
  (void) QueryColorCompliance(colorLow.c_str(),AllCompliance,&targetLow,
4752
0
    exceptionInfo);
4753
0
  (void) QueryColorCompliance(colorHigh.c_str(),AllCompliance,&targetHigh,
4754
0
    exceptionInfo);
4755
0
  modifyImage();
4756
0
  TransparentPaintImageChroma(image(),&targetLow,&targetHigh,TransparentAlpha,
4757
0
    MagickFalse,exceptionInfo);
4758
0
  ThrowImageException;
4759
0
}
4760
4761
void Magick::Image::transpose(void)
4762
0
{
4763
0
  MagickCore::Image
4764
0
    *newImage;
4765
4766
0
  GetPPException;
4767
0
  newImage=TransposeImage(constImage(),exceptionInfo);
4768
0
  replaceImage(newImage);
4769
0
  ThrowImageException;
4770
0
}
4771
4772
void Magick::Image::transverse(void)
4773
0
{
4774
0
  MagickCore::Image
4775
0
    *newImage;
4776
4777
0
  GetPPException;
4778
0
  newImage=TransverseImage(constImage(),exceptionInfo);
4779
0
  replaceImage(newImage);
4780
0
  ThrowImageException;
4781
0
}
4782
4783
void Magick::Image::trim(void)
4784
0
{
4785
0
  MagickCore::Image
4786
0
    *newImage;
4787
4788
0
  GetPPException;
4789
0
  newImage=TrimImage(constImage(),exceptionInfo);
4790
0
  replaceImage(newImage);
4791
0
  ThrowImageException;
4792
0
}
4793
4794
Magick::Image Magick::Image::uniqueColors(void) const
4795
0
{
4796
0
  MagickCore::Image
4797
0
    *image;
4798
4799
0
  GetPPException;
4800
0
  image=UniqueImageColors(constImage(),exceptionInfo);
4801
0
  ThrowImageException;
4802
0
  if (image == (MagickCore::Image *) NULL)
4803
0
    return(Magick::Image());
4804
0
  else
4805
0
    return(Magick::Image(image));
4806
0
}
4807
4808
void Magick::Image::unsharpmask(const double radius_,const double sigma_,
4809
  const double amount_,const double threshold_)
4810
0
{
4811
0
  MagickCore::Image
4812
0
    *newImage;
4813
4814
0
  GetPPException;
4815
0
  newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4816
0
    exceptionInfo);
4817
0
  replaceImage(newImage);
4818
0
  ThrowImageException;
4819
0
}
4820
4821
void Magick::Image::unsharpmaskChannel(const ChannelType channel_,
4822
  const double radius_,const double sigma_,const double amount_,
4823
  const double threshold_)
4824
0
{
4825
0
  MagickCore::Image
4826
0
    *newImage;
4827
4828
0
  GetPPException;
4829
0
  GetAndSetPPChannelMask(channel_);
4830
0
  newImage=UnsharpMaskImage(constImage(),radius_,sigma_,amount_,threshold_,
4831
0
    exceptionInfo);
4832
0
  RestorePPChannelMask;
4833
0
  replaceImage(newImage);
4834
0
  ThrowImageException;
4835
0
}
4836
4837
void Magick::Image::vignette(const double radius_,const double sigma_,
4838
  const ssize_t x_,const ssize_t y_)
4839
0
{
4840
0
  MagickCore::Image
4841
0
    *newImage;
4842
4843
0
  GetPPException;
4844
0
  newImage=VignetteImage(constImage(),radius_,sigma_,x_,y_,exceptionInfo);
4845
0
  replaceImage(newImage);
4846
0
  ThrowImageException;
4847
0
}
4848
4849
void Magick::Image::wave(const double amplitude_,const double wavelength_)
4850
0
{
4851
0
  MagickCore::Image
4852
0
    *newImage;
4853
4854
0
  GetPPException;
4855
0
  newImage=WaveImage(constImage(),amplitude_,wavelength_,image()->interpolate,
4856
0
    exceptionInfo);
4857
0
  replaceImage(newImage);
4858
0
  ThrowImageException;
4859
0
}
4860
4861
void Magick::Image::waveletDenoise(const double threshold_,
4862
  const double softness_)
4863
0
{
4864
0
  MagickCore::Image
4865
0
    *newImage;
4866
4867
0
  GetPPException;
4868
0
  newImage=WaveletDenoiseImage(constImage(),threshold_,softness_,
4869
0
    exceptionInfo);
4870
0
  replaceImage(newImage);
4871
0
  ThrowImageException;
4872
0
}
4873
4874
void Magick::Image::whiteThreshold(const std::string &threshold_)
4875
0
{
4876
0
  modifyImage();
4877
0
  GetPPException;
4878
0
  WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4879
0
  ThrowImageException;
4880
0
}
4881
4882
void Magick::Image::whiteThresholdChannel(const ChannelType channel_,
4883
  const std::string &threshold_)
4884
0
{
4885
0
  modifyImage();
4886
0
  GetPPException;
4887
0
  GetAndSetPPChannelMask(channel_);
4888
0
  WhiteThresholdImage(image(),threshold_.c_str(),exceptionInfo);
4889
0
  RestorePPChannelMask;
4890
0
  ThrowImageException;
4891
0
}
4892
4893
void Magick::Image::write(Blob *blob_)
4894
0
{
4895
0
  size_t
4896
0
    length=0;
4897
4898
0
  void
4899
0
    *data;
4900
4901
0
  modifyImage();
4902
0
  GetPPException;
4903
0
  data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4904
0
  if (length > 0)
4905
0
    blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4906
0
  else
4907
0
    data=RelinquishMagickMemory(data);
4908
0
  ThrowImageException;
4909
0
}
4910
4911
void Magick::Image::write(Blob *blob_,const std::string &magick_)
4912
61.5k
{
4913
61.5k
  size_t
4914
61.5k
    length=0;
4915
4916
61.5k
  void
4917
61.5k
    *data;
4918
4919
61.5k
  modifyImage();
4920
61.5k
  magick(magick_);
4921
61.5k
  GetPPException;
4922
61.5k
  data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4923
61.5k
  if (length > 0)
4924
61.2k
    blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4925
254
  else
4926
254
    data=RelinquishMagickMemory(data);
4927
61.5k
  ThrowImageException;
4928
61.5k
}
4929
4930
void Magick::Image::write(Blob *blob_,const std::string &magick_,
4931
  const size_t depth_)
4932
0
{
4933
0
  size_t
4934
0
    length=0;
4935
4936
0
  void
4937
0
    *data;
4938
4939
0
  modifyImage();
4940
0
  magick(magick_);
4941
0
  depth(depth_);
4942
0
  GetPPException;
4943
0
  data=ImagesToBlob(constImageInfo(),image(),&length,exceptionInfo);
4944
0
  if (length > 0)
4945
0
    blob_->updateNoCopy(data,length,Blob::MallocAllocator);
4946
0
  else
4947
0
    data=RelinquishMagickMemory(data);
4948
0
  ThrowImageException;
4949
0
}
4950
4951
void Magick::Image::write(const ssize_t x_,const ssize_t y_,
4952
  const size_t columns_,const size_t rows_,const std::string &map_,
4953
  const StorageType type_,void *pixels_)
4954
0
{
4955
0
  GetPPException;
4956
0
  ExportImagePixels(image(),x_,y_,columns_,rows_,map_.c_str(),type_,pixels_,
4957
0
    exceptionInfo);
4958
0
  ThrowImageException;
4959
0
}
4960
4961
void Magick::Image::write(const std::string &imageSpec_)
4962
0
{
4963
0
  modifyImage();
4964
0
  fileName(imageSpec_);
4965
0
  GetPPException;
4966
0
  WriteImage(constImageInfo(),image(),exceptionInfo);
4967
0
  ThrowImageException;
4968
0
}
4969
4970
void Magick::Image::writeMask(const Magick::Image &mask_)
4971
0
{
4972
0
  mask(mask_,WritePixelMask);
4973
0
}
4974
4975
Magick::Image Magick::Image::writeMask(void) const
4976
0
{
4977
0
  return(mask(WritePixelMask));
4978
0
}
4979
4980
void Magick::Image::writePixels(const Magick::QuantumType quantum_,
4981
  unsigned char *destination_)
4982
0
{
4983
0
  QuantumInfo
4984
0
    *quantum_info;
4985
4986
0
  quantum_info=AcquireQuantumInfo(imageInfo(),image());
4987
0
  GetPPException;
4988
0
  ExportQuantumPixels(image(),(MagickCore::CacheView *) NULL,quantum_info,
4989
0
    quantum_,destination_, exceptionInfo);
4990
0
  quantum_info=DestroyQuantumInfo(quantum_info);
4991
0
  ThrowImageException;
4992
0
}
4993
4994
void Magick::Image::zoom(const Geometry &geometry_)
4995
0
{
4996
0
  MagickCore::Image
4997
0
    *newImage;
4998
4999
0
  size_t
5000
0
    height=rows(),
5001
0
    width=columns();
5002
5003
0
  ssize_t
5004
0
    x=0,
5005
0
    y=0;
5006
5007
0
  ParseMetaGeometry(static_cast<std::string>(geometry_).c_str(),&x,&y,&width,
5008
0
    &height);
5009
5010
0
  GetPPException;
5011
0
  newImage=ResizeImage(constImage(),width,height,image()->filter,exceptionInfo);
5012
0
  replaceImage(newImage);
5013
0
  ThrowImageException;
5014
0
}
5015
5016
Magick::Image::Image(MagickCore::Image *image_)
5017
0
  : _imgRef(new ImageRef(image_))
5018
0
{
5019
0
}
5020
5021
MagickCore::Image *&Magick::Image::image(void)
5022
2.30M
{
5023
2.30M
  return(_imgRef->image());
5024
2.30M
}
5025
5026
const MagickCore::Image *Magick::Image::constImage(void) const
5027
0
{
5028
0
  return(_imgRef->image());
5029
0
}
5030
5031
MagickCore::ImageInfo *Magick::Image::imageInfo(void)
5032
599k
{
5033
599k
  return(_imgRef->options()->imageInfo());
5034
599k
}
5035
5036
const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
5037
429k
{
5038
429k
  return(_imgRef->options()->imageInfo());
5039
429k
}
5040
5041
Magick::Options *Magick::Image::options(void)
5042
1.16M
{
5043
1.16M
  return(_imgRef->options());
5044
1.16M
}
5045
5046
const Magick::Options *Magick::Image::constOptions(void) const
5047
1.03M
{
5048
1.03M
  return(_imgRef->options());
5049
1.03M
}
5050
5051
MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
5052
0
{
5053
0
  return(_imgRef->options()->quantizeInfo());
5054
0
}
5055
5056
const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
5057
0
{
5058
0
  return(_imgRef->options()->quantizeInfo());
5059
0
}
5060
5061
void Magick::Image::modifyImage(void)
5062
1.19M
{
5063
1.19M
  if (!_imgRef->isShared())
5064
1.19M
    return;
5065
5066
0
  GetPPException;
5067
0
  replaceImage(CloneImage(image(),0,0,MagickTrue,exceptionInfo));
5068
0
  ThrowImageException;
5069
0
}
5070
5071
MagickCore::Image *Magick::Image::replaceImage(MagickCore::Image *replacement_)
5072
599k
{
5073
599k
  MagickCore::Image
5074
599k
    *image;
5075
5076
599k
  if (replacement_)
5077
232k
    image=replacement_;
5078
367k
  else
5079
367k
    {
5080
367k
      GetPPException;
5081
367k
      image=AcquireImage(constImageInfo(),exceptionInfo);
5082
367k
      ThrowImageException;
5083
367k
    }
5084
5085
599k
  _imgRef=ImageRef::replaceImage(_imgRef,image);
5086
599k
  return(image);
5087
599k
}
5088
5089
void Magick::Image::read(MagickCore::Image *image,
5090
  MagickCore::ExceptionInfo *exceptionInfo)
5091
599k
{
5092
  // Ensure that multiple image frames were not read.
5093
599k
  if (image != (MagickCore::Image *) NULL &&
5094
232k
      image->next != (MagickCore::Image *) NULL)
5095
13.4k
    {
5096
13.4k
      MagickCore::Image
5097
13.4k
        *next;
5098
5099
      // Destroy any extra image frames
5100
13.4k
      next=image->next;
5101
13.4k
      image->next=(MagickCore::Image *) NULL;
5102
13.4k
      next->previous=(MagickCore::Image *) NULL;
5103
13.4k
      DestroyImageList(next);
5104
13.4k
    }
5105
599k
  replaceImage(image);
5106
599k
  if (exceptionInfo->severity == MagickCore::UndefinedException &&
5107
92.2k
      image == (MagickCore::Image *) NULL)
5108
7.90k
    {
5109
7.90k
      (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
5110
7.90k
      if (!quiet())
5111
7.90k
        throwExceptionExplicit(MagickCore::ImageWarning,
5112
7.90k
          "No image was loaded.");
5113
7.90k
      return;
5114
7.90k
    }
5115
592k
  ThrowImageException;
5116
592k
}
5117
5118
void Magick::Image::floodFill(const ssize_t x_,const ssize_t y_,
5119
  const Magick::Image *fillPattern_,const Magick::Color &fill_,
5120
  const MagickCore::PixelInfo *target_,const bool invert_)
5121
0
{
5122
0
  Magick::Color
5123
0
    fillColor;
5124
5125
0
  MagickCore::Image
5126
0
    *fillPattern;
5127
5128
  // Set drawing fill pattern or fill color
5129
0
  fillColor=options()->fillColor();
5130
0
  fillPattern=(MagickCore::Image *)NULL;
5131
0
  if (options()->fillPattern() != (MagickCore::Image *)NULL)
5132
0
    {
5133
0
      GetPPException;
5134
0
      fillPattern=CloneImage(options()->fillPattern(),0,0,MagickTrue,
5135
0
        exceptionInfo);
5136
0
      ThrowImageException;
5137
0
    }
5138
5139
0
  if (fillPattern_ == (Magick::Image *)NULL)
5140
0
    {
5141
0
      options()->fillPattern((MagickCore::Image *)NULL);
5142
0
      options()->fillColor(fill_);
5143
0
    }
5144
0
  else
5145
0
    options()->fillPattern(fillPattern_->constImage());
5146
5147
0
  GetPPException;
5148
0
  (void) FloodfillPaintImage(image(),options()->drawInfo(),
5149
0
    target_,static_cast<ssize_t>(x_),static_cast<ssize_t>(y_),
5150
0
    (MagickBooleanType) invert_,exceptionInfo);
5151
5152
0
  options()->fillColor(fillColor);
5153
0
  options()->fillPattern(fillPattern);
5154
0
  ThrowImageException;
5155
0
}
5156
5157
void Magick::Image::mask(const Magick::Image &mask_,const PixelMask type)
5158
0
{
5159
0
  modifyImage();
5160
5161
0
  GetPPException;
5162
0
  if (mask_.isValid())
5163
0
    SetImageMask(image(),type,mask_.constImage(),exceptionInfo);
5164
0
  else
5165
0
    SetImageMask(image(),type,(MagickCore::Image *) NULL,exceptionInfo);
5166
0
  ThrowImageException;
5167
0
}
5168
5169
Magick::Image Magick::Image::mask(const PixelMask type) const
5170
0
{
5171
0
  MagickCore::Image
5172
0
    *image;
5173
5174
0
  GetPPException;
5175
0
  image = GetImageMask(constImage(),type,exceptionInfo);
5176
0
  ThrowImageException;
5177
5178
0
  if (image == (MagickCore::Image *) NULL)
5179
0
    return(Magick::Image());
5180
0
  else
5181
0
    return(Magick::Image(image));
5182
0
}