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