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