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
26 using 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
33 MagickPPExport const char *Magick::borderGeometryDefault="6x6+0+0";
34 MagickPPExport const char *Magick::frameGeometryDefault="25x25+6+6";
35 MagickPPExport const char *Magick::raiseGeometryDefault="6x6+0+0";
36
operator ==(const Magick::Image & left_,const Magick::Image & right_)37 MagickPPExport 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
operator !=(const Magick::Image & left_,const Magick::Image & right_)46 MagickPPExport int Magick::operator != (const Magick::Image &left_,
47 const Magick::Image &right_)
48 {
49 return(!(left_ == right_));
50 }
51
operator >(const Magick::Image & left_,const Magick::Image & right_)52 MagickPPExport int Magick::operator > (const Magick::Image &left_,
53 const Magick::Image &right_)
54 {
55 return(!(left_ < right_) && (left_ != right_));
56 }
57
operator <(const Magick::Image & left_,const Magick::Image & right_)58 MagickPPExport 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
operator >=(const Magick::Image & left_,const Magick::Image & right_)66 MagickPPExport int Magick::operator >= (const Magick::Image &left_,
67 const Magick::Image &right_)
68 {
69 return((left_ > right_) || (left_ == right_));
70 }
71
operator <=(const Magick::Image & left_,const Magick::Image & right_)72 MagickPPExport int Magick::operator <= (const Magick::Image &left_,
73 const Magick::Image &right_)
74 {
75 return((left_ < right_) || (left_ == right_));
76 }
77
Image(void)78 Magick::Image::Image(void)
79 : _imgRef(new ImageRef)
80 {
81 }
82
Image(const Blob & blob_)83 Magick::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
Image(const Blob & blob_,const Geometry & size_)101 Magick::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
Image(const Blob & blob_,const Geometry & size_,const size_t depth_)119 Magick::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
Image(const Blob & blob_,const Geometry & size_,const size_t depth_,const std::string & magick_)138 Magick::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
Image(const Blob & blob_,const Geometry & size_,const std::string & magick_)157 Magick::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
Image(const Geometry & size_,const Color & color_)176 Magick::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
Image(const Image & image_)201 Magick::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
Image(const Image & image_,const Geometry & geometry_)210 Magick::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
Image(const size_t width_,const size_t height_,const std::string & map_,const StorageType type_,const void * pixels_)234 Magick::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
Image(const std::string & imageSpec_)252 Magick::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
~Image()270 Magick::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
operator =(const Magick::Image & image_)287 Magick::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
adjoin(const bool flag_)319 void Magick::Image::adjoin(const bool flag_)
320 {
321 modifyImage();
322 options()->adjoin(flag_);
323 }
324
adjoin(void) const325 bool Magick::Image::adjoin(void) const
326 {
327 return(constOptions()->adjoin());
328 }
329
antiAlias(const bool flag_)330 void Magick::Image::antiAlias(const bool flag_)
331 {
332 modifyImage();
333 options()->antiAlias(flag_);
334 }
335
antiAlias(void) const336 bool Magick::Image::antiAlias(void) const
337 {
338 return(constOptions()->antiAlias());
339 }
340
animationDelay(const size_t delay_)341 void Magick::Image::animationDelay(const size_t delay_)
342 {
343 modifyImage();
344 image()->delay=delay_;
345 }
346
animationDelay(void) const347 size_t Magick::Image::animationDelay(void) const
348 {
349 return(constImage()->delay);
350 }
351
animationIterations(const size_t iterations_)352 void Magick::Image::animationIterations(const size_t iterations_)
353 {
354 modifyImage();
355 image()->iterations=iterations_;
356 }
357
animationIterations(void) const358 size_t Magick::Image::animationIterations(void) const
359 {
360 return(constImage()->iterations);
361 }
362
attenuate(const double attenuate_)363 void 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
backgroundColor(const Color & backgroundColor_)373 void 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
backgroundColor(void) const385 Magick::Color Magick::Image::backgroundColor(void) const
386 {
387 return(constOptions()->backgroundColor());
388 }
389
backgroundTexture(const std::string & backgroundTexture_)390 void Magick::Image::backgroundTexture(const std::string &backgroundTexture_)
391 {
392 modifyImage();
393 options()->backgroundTexture(backgroundTexture_);
394 }
395
backgroundTexture(void) const396 std::string Magick::Image::backgroundTexture(void) const
397 {
398 return(constOptions()->backgroundTexture());
399 }
400
baseColumns(void) const401 size_t Magick::Image::baseColumns(void) const
402 {
403 return(constImage()->magick_columns);
404 }
405
baseFilename(void) const406 std::string Magick::Image::baseFilename(void) const
407 {
408 return(std::string(constImage()->magick_filename));
409 }
410
baseRows(void) const411 size_t Magick::Image::baseRows(void) const
412 {
413 return(constImage()->magick_rows);
414 }
415
blackPointCompensation(const bool flag_)416 void Magick::Image::blackPointCompensation(const bool flag_)
417 {
418 image()->black_point_compensation=(MagickBooleanType) flag_;
419 }
420
blackPointCompensation(void) const421 bool Magick::Image::blackPointCompensation(void) const
422 {
423 return(static_cast<bool>(constImage()->black_point_compensation));
424 }
425
borderColor(const Color & borderColor_)426 void 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
borderColor(void) const438 Magick::Color Magick::Image::borderColor(void) const
439 {
440 return(constOptions()->borderColor());
441 }
442
boundingBox(void) const443 Magick::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
boxColor(const Color & boxColor_)454 void Magick::Image::boxColor(const Color &boxColor_)
455 {
456 modifyImage();
457 options()->boxColor(boxColor_);
458 }
459
boxColor(void) const460 Magick::Color Magick::Image::boxColor(void) const
461 {
462 return(constOptions()->boxColor());
463 }
464
cacheThreshold(const size_t threshold_)465 void Magick::Image::cacheThreshold(const size_t threshold_)
466 {
467 ResourceLimits::memory((MagickSizeType) threshold_);
468 }
469
classType(const ClassType class_)470 void 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
clipMask(const Magick::Image & clipMask_)492 void 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
clipMask(void) const502 Magick::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
colorFuzz(const double fuzz_)517 void Magick::Image::colorFuzz(const double fuzz_)
518 {
519 modifyImage();
520 image()->fuzz=fuzz_;
521 options()->colorFuzz(fuzz_);
522 }
523
colorFuzz(void) const524 double Magick::Image::colorFuzz(void) const
525 {
526 return(constOptions()->colorFuzz());
527 }
528
colorMapSize(const size_t entries_)529 void 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
colorMapSize(void) const539 size_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
colorSpace(const ColorspaceType colorSpace_)547 void 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
colorSpace(void) const557 Magick::ColorspaceType Magick::Image::colorSpace(void) const
558 {
559 return(constImage()->colorspace);
560 }
561
colorspaceType(const ColorspaceType colorSpace_)562 void Magick::Image::colorspaceType(const ColorspaceType colorSpace_)
563 {
564 modifyImage();
565 SetImageColorspace(image(),colorSpace_);
566 throwImageException();
567 options()->colorspaceType(colorSpace_);
568 }
569
colorspaceType(void) const570 Magick::ColorspaceType Magick::Image::colorspaceType(void) const
571 {
572 return(constOptions()->colorspaceType());
573 }
574
comment(const std::string & comment_)575 void 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
comment(void) const584 std::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
compose(const CompositeOperator compose_)597 void Magick::Image::compose(const CompositeOperator compose_)
598 {
599 image()->compose=compose_;
600 }
601
compose(void) const602 Magick::CompositeOperator Magick::Image::compose(void) const
603 {
604 return(constImage()->compose);
605 }
606
compressType(const CompressionType compressType_)607 void Magick::Image::compressType(const CompressionType compressType_)
608 {
609 modifyImage();
610 image()->compression=compressType_;
611 options()->compressType(compressType_);
612 }
613
compressType(void) const614 Magick::CompressionType Magick::Image::compressType(void) const
615 {
616 return(constImage()->compression);
617 }
618
debug(const bool flag_)619 void Magick::Image::debug(const bool flag_)
620 {
621 modifyImage();
622 options()->debug(flag_);
623 }
624
debug(void) const625 bool Magick::Image::debug(void) const
626 {
627 return(constOptions()->debug());
628 }
629
density(const Geometry & density_)630 void 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
density(void) const650 Magick::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
depth(const size_t depth_)670 void Magick::Image::depth(const size_t depth_)
671 {
672 modifyImage();
673 image()->depth=depth_;
674 options()->depth(depth_);
675 }
676
depth(void) const677 size_t Magick::Image::depth(void) const
678 {
679 return(constImage()->depth);
680 }
681
directory(void) const682 std::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
endian(const Magick::EndianType endian_)693 void Magick::Image::endian(const Magick::EndianType endian_)
694 {
695 modifyImage();
696 options()->endian(endian_);
697 image()->endian=endian_;
698 }
699
endian(void) const700 Magick::EndianType Magick::Image::endian(void) const
701 {
702 return(constImage()->endian);
703 }
704
exifProfile(const Magick::Blob & exifProfile_)705 void 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
exifProfile(void) const720 Magick::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
fileName(const std::string & fileName_)733 void 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
fileName(void) const750 std::string Magick::Image::fileName(void) const
751 {
752 return(constOptions()->fileName());
753 }
754
fileSize(void) const755 off_t Magick::Image::fileSize(void) const
756 {
757 return((off_t) GetBlobSize(constImage()));
758 }
759
fillColor(const Magick::Color & fillColor_)760 void Magick::Image::fillColor(const Magick::Color &fillColor_)
761 {
762 modifyImage();
763 options()->fillColor(fillColor_);
764 }
765
fillColor(void) const766 Magick::Color Magick::Image::fillColor(void) const
767 {
768 return(constOptions()->fillColor());
769 }
770
fillRule(const Magick::FillRule & fillRule_)771 void Magick::Image::fillRule(const Magick::FillRule &fillRule_)
772 {
773 modifyImage();
774 options()->fillRule(fillRule_);
775 }
776
fillRule(void) const777 Magick::FillRule Magick::Image::fillRule(void) const
778 {
779 return(constOptions()->fillRule());
780 }
781
fillPattern(const Image & fillPattern_)782 void 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
fillPattern(void) const791 Magick::Image Magick::Image::fillPattern(void) const
792 {
793 // FIXME: This is inordinately innefficient
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
filterType(const Magick::FilterTypes filterType_)816 void Magick::Image::filterType(const Magick::FilterTypes filterType_)
817 {
818 modifyImage();
819 image()->filter=filterType_;
820 }
821
filterType(void) const822 Magick::FilterTypes Magick::Image::filterType(void) const
823 {
824 return(constImage()->filter);
825 }
826
font(const std::string & font_)827 void Magick::Image::font(const std::string &font_)
828 {
829 modifyImage();
830 options()->font(font_);
831 }
832
font(void) const833 std::string Magick::Image::font(void) const
834 {
835 return(constOptions()->font());
836 }
837
fontFamily(const std::string & family_)838 void Magick::Image::fontFamily(const std::string &family_)
839 {
840 modifyImage();
841 options()->fontFamily(family_);
842 }
843
fontFamily(void) const844 std::string Magick::Image::fontFamily(void) const
845 {
846 return(constOptions()->fontFamily());
847 }
848
849
fontPointsize(const double pointSize_)850 void Magick::Image::fontPointsize(const double pointSize_)
851 {
852 modifyImage();
853 options()->fontPointsize(pointSize_);
854 }
855
fontPointsize(void) const856 double Magick::Image::fontPointsize(void) const
857 {
858 return(constOptions()->fontPointsize());
859 }
860
format(void) const861 std::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
fontStyle(const StyleType pointSize_)877 void Magick::Image::fontStyle(const StyleType pointSize_)
878 {
879 modifyImage();
880 options()->fontStyle(pointSize_);
881 }
882
fontStyle(void) const883 Magick::StyleType Magick::Image::fontStyle(void) const
884 {
885 return(constOptions()->fontStyle());
886 }
887
fontWeight(const size_t weight_)888 void Magick::Image::fontWeight(const size_t weight_)
889 {
890 modifyImage();
891 options()->fontWeight(weight_);
892 }
893
fontWeight(void) const894 size_t Magick::Image::fontWeight(void) const
895 {
896 return(constOptions()->fontWeight());
897 }
898
899
formatExpression(const std::string expression)900 std::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
gamma(void) const919 double Magick::Image::gamma(void) const
920 {
921 return(constImage()->gamma);
922 }
923
geometry(void) const924 Magick::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
gifDisposeMethod(const size_t disposeMethod_)934 void Magick::Image::gifDisposeMethod(const size_t disposeMethod_)
935 {
936 modifyImage();
937 image()->dispose=(DisposeType) disposeMethod_;
938 }
939
gifDisposeMethod(void) const940 size_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
highlightColor(const Color color_)946 void Magick::Image::highlightColor(const Color color_)
947 {
948 std::string
949 value;
950
951 value=color_;
952 artifact("highlight-color",value);
953 }
954
iccColorProfile(const Magick::Blob & colorProfile_)955 void Magick::Image::iccColorProfile(const Magick::Blob &colorProfile_)
956 {
957 profile("icc",colorProfile_);
958 }
959
iccColorProfile(void) const960 Magick::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
interlaceType(const InterlaceType interlace_)973 void Magick::Image::interlaceType(const InterlaceType interlace_)
974 {
975 modifyImage();
976 image()->interlace=interlace_;
977 options()->interlaceType(interlace_);
978 }
979
interlaceType(void) const980 Magick::InterlaceType Magick::Image::interlaceType(void) const
981 {
982 return constImage()->interlace;
983 }
984
interpolate(const InterpolatePixelMethod interpolate_)985 void Magick::Image::interpolate(const InterpolatePixelMethod interpolate_)
986 {
987 modifyImage();
988 image()->interpolate=interpolate_;
989 }
990
interpolate(void) const991 Magick::InterpolatePixelMethod Magick::Image::interpolate(void) const
992 {
993 return constImage()->interpolate;
994 }
995
iptcProfile(const Magick::Blob & iptcProfile_)996 void 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
iptcProfile(void) const1011 Magick::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
isOpaque(void) const1023 bool 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
isValid(const bool isValid_)1034 void 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
isValid(void) const1050 bool Magick::Image::isValid(void) const
1051 {
1052 return(rows() && columns());
1053 }
1054
label(const std::string & label_)1055 void 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
label(void) const1064 std::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
lowlightColor(const Color color_)1077 void Magick::Image::lowlightColor(const Color color_)
1078 {
1079 std::string
1080 value;
1081
1082 value=color_;
1083 artifact("lowlight-color",value);
1084 }
1085
magick(const std::string & magick_)1086 void 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
magick(void) const1104 std::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
mask(const Magick::Image & mask_)1112 void 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
mask(void) const1122 Magick::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
matte(const bool matteFlag_)1137 void 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
matte(void) const1151 bool Magick::Image::matte(void) const
1152 {
1153 if (constImage()->matte)
1154 return true;
1155 else
1156 return false;
1157 }
1158
matteColor(const Color & matteColor_)1159 void 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
matteColor(void) const1179 Magick::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
meanErrorPerPixel(void) const1185 double Magick::Image::meanErrorPerPixel(void) const
1186 {
1187 return(constImage()->error.mean_error_per_pixel);
1188 }
1189
modulusDepth(const size_t depth_)1190 void Magick::Image::modulusDepth(const size_t depth_)
1191 {
1192 modifyImage();
1193 SetImageDepth(image(),depth_);
1194 options()->depth(depth_);
1195 }
1196
modulusDepth(void) const1197 size_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
monochrome(const bool monochromeFlag_)1208 void Magick::Image::monochrome(const bool monochromeFlag_)
1209 {
1210 modifyImage();
1211 options()->monochrome(monochromeFlag_);
1212 }
1213
monochrome(void) const1214 bool Magick::Image::monochrome(void) const
1215 {
1216 return(constOptions()->monochrome());
1217 }
1218
montageGeometry(void) const1219 Magick::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
normalizedMaxError(void) const1230 double Magick::Image::normalizedMaxError(void) const
1231 {
1232 return(constImage()->error.normalized_maximum_error);
1233 }
1234
normalizedMeanError(void) const1235 double Magick::Image::normalizedMeanError(void) const
1236 {
1237 return (constImage()->error.normalized_mean_error);
1238 }
1239
orientation(const Magick::OrientationType orientation_)1240 void Magick::Image::orientation(const Magick::OrientationType orientation_)
1241 {
1242 modifyImage();
1243 image()->orientation=orientation_;
1244 }
1245
orientation(void) const1246 Magick::OrientationType Magick::Image::orientation(void) const
1247 {
1248 return(constImage()->orientation);
1249 }
1250
page(const Magick::Geometry & pageSize_)1251 void Magick::Image::page(const Magick::Geometry &pageSize_)
1252 {
1253 modifyImage();
1254 options()->page(pageSize_);
1255 image()->page=pageSize_;
1256 }
1257
page(void) const1258 Magick::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
penColor(const Color & penColor_)1266 void Magick::Image::penColor(const Color &penColor_)
1267 {
1268 modifyImage();
1269 options()->fillColor(penColor_);
1270 options()->strokeColor(penColor_);
1271 }
1272
penColor(void) const1273 Magick::Color Magick::Image::penColor(void) const
1274 {
1275 return(constOptions()->fillColor());
1276 }
1277
penTexture(const Image & penTexture_)1278 void 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
penTexture(void) const1287 Magick::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
quality(const size_t quality_)1311 void Magick::Image::quality(const size_t quality_)
1312 {
1313 modifyImage();
1314 image()->quality=quality_;
1315 options()->quality(quality_);
1316 }
1317
quality(void) const1318 size_t Magick::Image::quality(void) const
1319 {
1320 return(constImage()->quality);
1321 }
1322
quantizeColors(const size_t colors_)1323 void Magick::Image::quantizeColors(const size_t colors_)
1324 {
1325 modifyImage();
1326 options()->quantizeColors(colors_);
1327 }
1328
quantizeColors(void) const1329 size_t Magick::Image::quantizeColors(void) const
1330 {
1331 return(constOptions()->quantizeColors());
1332 }
1333
quantizeColorSpace(const Magick::ColorspaceType colorSpace_)1334 void Magick::Image::quantizeColorSpace(
1335 const Magick::ColorspaceType colorSpace_)
1336 {
1337 modifyImage();
1338 options()->quantizeColorSpace(colorSpace_);
1339 }
1340
quantizeColorSpace(void) const1341 Magick::ColorspaceType Magick::Image::quantizeColorSpace(void) const
1342 {
1343 return(constOptions()->quantizeColorSpace());
1344 }
1345
quantizeDither(const bool ditherFlag_)1346 void Magick::Image::quantizeDither(const bool ditherFlag_)
1347 {
1348 modifyImage();
1349 options()->quantizeDither(ditherFlag_);
1350 }
1351
quantizeDither(void) const1352 bool Magick::Image::quantizeDither(void) const
1353 {
1354 return(constOptions()->quantizeDither());
1355 }
1356
quantizeDitherMethod(const DitherMethod ditherMethod_)1357 void Magick::Image::quantizeDitherMethod(const DitherMethod ditherMethod_)
1358 {
1359 modifyImage();
1360 options()->quantizeDitherMethod(ditherMethod_);
1361 }
1362
quantizeDitherMethod(void) const1363 MagickCore::DitherMethod Magick::Image::quantizeDitherMethod(void) const
1364 {
1365 return(constOptions()->quantizeDitherMethod());
1366 }
1367
quantizeTreeDepth(const size_t treeDepth_)1368 void Magick::Image::quantizeTreeDepth(const size_t treeDepth_)
1369 {
1370 modifyImage();
1371 options()->quantizeTreeDepth(treeDepth_);
1372 }
1373
quantizeTreeDepth(void) const1374 size_t Magick::Image::quantizeTreeDepth(void) const
1375 {
1376 return(constOptions()->quantizeTreeDepth());
1377 }
1378
quiet(const bool quiet_)1379 void Magick::Image::quiet(const bool quiet_)
1380 {
1381 modifyImage();
1382 options()->quiet(quiet_);
1383 }
1384
quiet(void) const1385 bool Magick::Image::quiet(void) const
1386 {
1387 return(constOptions()->quiet());
1388 }
1389
renderingIntent(const Magick::RenderingIntent renderingIntent_)1390 void Magick::Image::renderingIntent(
1391 const Magick::RenderingIntent renderingIntent_)
1392 {
1393 modifyImage();
1394 image()->rendering_intent=renderingIntent_;
1395 }
1396
renderingIntent(void) const1397 Magick::RenderingIntent Magick::Image::renderingIntent(void) const
1398 {
1399 return(static_cast<Magick::RenderingIntent>(
1400 constImage()->rendering_intent));
1401 }
1402
resolutionUnits(const Magick::ResolutionType resolutionUnits_)1403 void Magick::Image::resolutionUnits(
1404 const Magick::ResolutionType resolutionUnits_)
1405 {
1406 modifyImage();
1407 image()->units=resolutionUnits_;
1408 options()->resolutionUnits(resolutionUnits_);
1409 }
1410
resolutionUnits(void) const1411 Magick::ResolutionType Magick::Image::resolutionUnits(void) const
1412 {
1413 return(static_cast<Magick::ResolutionType>(constImage()->units));
1414 }
1415
scene(const size_t scene_)1416 void Magick::Image::scene(const size_t scene_)
1417 {
1418 modifyImage();
1419 image()->scene=scene_;
1420 }
1421
scene(void) const1422 size_t Magick::Image::scene(void) const
1423 {
1424 return(constImage()->scene);
1425 }
1426
size(const Geometry & geometry_)1427 void 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
size(void) const1435 Magick::Geometry Magick::Image::size(void) const
1436 {
1437 return(Magick::Geometry(constImage()->columns,constImage()->rows));
1438 }
1439
strokeAntiAlias(const bool flag_)1440 void Magick::Image::strokeAntiAlias(const bool flag_)
1441 {
1442 modifyImage();
1443 options()->strokeAntiAlias(flag_);
1444 }
1445
strokeAntiAlias(void) const1446 bool Magick::Image::strokeAntiAlias(void) const
1447 {
1448 return(constOptions()->strokeAntiAlias());
1449 }
1450
strokeColor(const Magick::Color & strokeColor_)1451 void 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
strokeColor(void) const1462 Magick::Color Magick::Image::strokeColor(void) const
1463 {
1464 return(constOptions()->strokeColor());
1465 }
1466
strokeDashArray(const double * strokeDashArray_)1467 void Magick::Image::strokeDashArray(const double *strokeDashArray_)
1468 {
1469 modifyImage();
1470 options()->strokeDashArray(strokeDashArray_);
1471 }
1472
strokeDashArray(void) const1473 const double *Magick::Image::strokeDashArray(void) const
1474 {
1475 return(constOptions()->strokeDashArray());
1476 }
1477
strokeDashOffset(const double strokeDashOffset_)1478 void Magick::Image::strokeDashOffset(const double strokeDashOffset_)
1479 {
1480 modifyImage();
1481 options()->strokeDashOffset(strokeDashOffset_);
1482 }
1483
strokeDashOffset(void) const1484 double Magick::Image::strokeDashOffset(void) const
1485 {
1486 return(constOptions()->strokeDashOffset());
1487 }
1488
strokeLineCap(const Magick::LineCap lineCap_)1489 void Magick::Image::strokeLineCap(const Magick::LineCap lineCap_)
1490 {
1491 modifyImage();
1492 options()->strokeLineCap(lineCap_);
1493 }
1494
strokeLineCap(void) const1495 Magick::LineCap Magick::Image::strokeLineCap(void) const
1496 {
1497 return(constOptions()->strokeLineCap());
1498 }
1499
strokeLineJoin(const Magick::LineJoin lineJoin_)1500 void Magick::Image::strokeLineJoin(const Magick::LineJoin lineJoin_)
1501 {
1502 modifyImage();
1503 options()->strokeLineJoin(lineJoin_);
1504 }
1505
strokeLineJoin(void) const1506 Magick::LineJoin Magick::Image::strokeLineJoin(void) const
1507 {
1508 return(constOptions()->strokeLineJoin());
1509 }
1510
strokeMiterLimit(const size_t strokeMiterLimit_)1511 void Magick::Image::strokeMiterLimit(const size_t strokeMiterLimit_)
1512 {
1513 modifyImage();
1514 options()->strokeMiterLimit(strokeMiterLimit_);
1515 }
1516
strokeMiterLimit(void) const1517 size_t Magick::Image::strokeMiterLimit(void) const
1518 {
1519 return constOptions()->strokeMiterLimit();
1520 }
1521
strokePattern(const Image & strokePattern_)1522 void 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
strokePattern(void) const1531 Magick::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
strokeWidth(const double strokeWidth_)1554 void 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
strokeWidth(void) const1565 double Magick::Image::strokeWidth(void) const
1566 {
1567 return(constOptions()->strokeWidth());
1568 }
1569
subImage(const size_t subImage_)1570 void Magick::Image::subImage(const size_t subImage_)
1571 {
1572 modifyImage();
1573 options()->subImage(subImage_);
1574 }
1575
subImage(void) const1576 size_t Magick::Image::subImage(void) const
1577 {
1578 return(constOptions()->subImage());
1579 }
1580
subRange(const size_t subRange_)1581 void Magick::Image::subRange(const size_t subRange_)
1582 {
1583 modifyImage();
1584 options()->subRange(subRange_);
1585 }
1586
subRange(void) const1587 size_t Magick::Image::subRange(void) const
1588 {
1589 return(constOptions()->subRange());
1590 }
1591
textDirection(DirectionType direction_)1592 void Magick::Image::textDirection(DirectionType direction_)
1593 {
1594 modifyImage();
1595 options()->textDirection(direction_);
1596 }
1597
textDirection(void) const1598 Magick::DirectionType Magick::Image::textDirection(void) const
1599 {
1600 return(constOptions()->textDirection());
1601 }
1602
textEncoding(const std::string & encoding_)1603 void Magick::Image::textEncoding(const std::string &encoding_)
1604 {
1605 modifyImage();
1606 options()->textEncoding(encoding_);
1607 }
1608
textEncoding(void) const1609 std::string Magick::Image::textEncoding(void) const
1610 {
1611 return(constOptions()->textEncoding());
1612 }
1613
textGravity(GravityType gravity_)1614 void Magick::Image::textGravity(GravityType gravity_)
1615 {
1616 modifyImage();
1617 options()->textGravity(gravity_);
1618 }
1619
textGravity(void) const1620 Magick::GravityType Magick::Image::textGravity(void) const
1621 {
1622 return(constOptions()->textGravity());
1623 }
1624
textInterlineSpacing(double spacing_)1625 void Magick::Image::textInterlineSpacing(double spacing_)
1626 {
1627 modifyImage();
1628 options()->textInterlineSpacing(spacing_);
1629 }
1630
textInterlineSpacing(void) const1631 double Magick::Image::textInterlineSpacing(void) const
1632 {
1633 return(constOptions()->textInterlineSpacing());
1634 }
1635
textInterwordSpacing(double spacing_)1636 void Magick::Image::textInterwordSpacing(double spacing_)
1637 {
1638 modifyImage();
1639 options()->textInterwordSpacing(spacing_);
1640 }
1641
textInterwordSpacing(void) const1642 double Magick::Image::textInterwordSpacing(void) const
1643 {
1644 return(constOptions()->textInterwordSpacing());
1645 }
1646
textKerning(double kerning_)1647 void Magick::Image::textKerning(double kerning_)
1648 {
1649 modifyImage();
1650 options()->textKerning(kerning_);
1651 }
1652
textKerning(void) const1653 double Magick::Image::textKerning(void) const
1654 {
1655 return(constOptions()->textKerning());
1656 }
1657
textUnderColor(const Color & underColor_)1658 void Magick::Image::textUnderColor(const Color &underColor_)
1659 {
1660 modifyImage();
1661 options()->textUnderColor(underColor_);
1662 }
1663
textUnderColor(void) const1664 Magick::Color Magick::Image::textUnderColor(void) const
1665 {
1666 return(constOptions()->textUnderColor());
1667 }
1668
tileName(const std::string & tileName_)1669 void Magick::Image::tileName(const std::string &tileName_)
1670 {
1671 modifyImage();
1672 options()->tileName(tileName_);
1673 }
1674
tileName(void) const1675 std::string Magick::Image::tileName(void) const
1676 {
1677 return(constOptions()->tileName());
1678 }
1679
totalColors(void) const1680 size_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
transformRotation(const double angle_)1691 void Magick::Image::transformRotation(const double angle_)
1692 {
1693 modifyImage();
1694 options()->transformRotation(angle_);
1695 }
1696
transformSkewX(const double skewx_)1697 void Magick::Image::transformSkewX(const double skewx_)
1698 {
1699 modifyImage();
1700 options()->transformSkewX(skewx_);
1701 }
1702
transformSkewY(const double skewy_)1703 void Magick::Image::transformSkewY(const double skewy_)
1704 {
1705 modifyImage();
1706 options()->transformSkewY(skewy_);
1707 }
1708
type(const Magick::ImageType type_)1709 void Magick::Image::type(const Magick::ImageType type_)
1710 {
1711 modifyImage();
1712 options()->type(type_);
1713 SetImageType(image(),type_);
1714 }
1715
type(void) const1716 Magick::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
verbose(const bool verboseFlag_)1726 void Magick::Image::verbose(const bool verboseFlag_)
1727 {
1728 modifyImage();
1729 options()->verbose(verboseFlag_);
1730 }
1731
verbose(void) const1732 bool Magick::Image::verbose(void) const
1733 {
1734 return(constOptions()->verbose());
1735 }
1736
view(const std::string & view_)1737 void Magick::Image::view(const std::string &view_)
1738 {
1739 modifyImage();
1740 options()->view(view_);
1741 }
1742
view(void) const1743 std::string Magick::Image::view(void) const
1744 {
1745 return(constOptions()->view());
1746 }
1747
virtualPixelMethod(const VirtualPixelMethod virtual_pixel_method_)1748 void 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
virtualPixelMethod(void) const1756 Magick::VirtualPixelMethod Magick::Image::virtualPixelMethod(void) const
1757 {
1758 return(GetImageVirtualPixelMethod(constImage()));
1759 }
1760
x11Display(const std::string & display_)1761 void Magick::Image::x11Display(const std::string &display_)
1762 {
1763 modifyImage();
1764 options()->x11Display(display_);
1765 }
1766
x11Display(void) const1767 std::string Magick::Image::x11Display(void) const
1768 {
1769 return(constOptions()->x11Display());
1770 }
1771
xResolution(void) const1772 double Magick::Image::xResolution(void) const
1773 {
1774 return(constImage()->x_resolution);
1775 }
1776
yResolution(void) const1777 double Magick::Image::yResolution(void) const
1778 {
1779 return(constImage()->y_resolution);
1780 }
1781
adaptiveBlur(const double radius_,const double sigma_)1782 void 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
adaptiveResize(const Geometry & geometry_)1793 void 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
adaptiveSharpen(const double radius_,const double sigma_)1815 void 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
adaptiveSharpenChannel(const ChannelType channel_,const double radius_,const double sigma_)1826 void 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
adaptiveThreshold(const size_t width_,const size_t height_,const ssize_t offset_)1839 void 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
addNoise(const NoiseType noiseType_)1852 void 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
addNoiseChannel(const ChannelType channel_,const NoiseType noiseType_)1863 void 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
affineTransform(const DrawableAffine & affine_)1876 void 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
alphaChannel(AlphaChannelType alphaType_)1897 void Magick::Image::alphaChannel(AlphaChannelType alphaType_)
1898 {
1899 modifyImage();
1900 SetImageAlphaChannel(image(), alphaType_);
1901 throwImageException();
1902 }
1903
annotate(const std::string & text_,const Geometry & location_)1904 void Magick::Image::annotate(const std::string &text_,
1905 const Geometry &location_)
1906 {
1907 annotate(text_,location_,NorthWestGravity,0.0);
1908 }
1909
annotate(const std::string & text_,const Geometry & boundingArea_,const GravityType gravity_)1910 void Magick::Image::annotate(const std::string &text_,
1911 const Geometry &boundingArea_,const GravityType gravity_)
1912 {
1913 annotate(text_,boundingArea_,gravity_,0.0);
1914 }
1915
annotate(const std::string & text_,const Geometry & boundingArea_,const GravityType gravity_,const double degrees_)1916 void 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
annotate(const std::string & text_,const GravityType gravity_)1991 void 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
artifact(const std::string & name_,const std::string & value_)2012 void 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
artifact(const std::string & name_) const2019 std::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
attribute(const std::string name_,const char * value_)2030 void Magick::Image::attribute(const std::string name_,const char *value_)
2031 {
2032 modifyImage();
2033 SetImageProperty(image(),name_.c_str(),value_);
2034 }
2035
attribute(const std::string name_,const std::string value_)2036 void 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
attribute(const std::string name_) const2042 std::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
autoGamma(void)2055 void Magick::Image::autoGamma(void)
2056 {
2057 modifyImage();
2058 (void) AutoGammaImage(image());
2059 throwImageException();
2060 }
2061
autoGammaChannel(const ChannelType channel_)2062 void Magick::Image::autoGammaChannel(const ChannelType channel_)
2063 {
2064 modifyImage();
2065 (void) AutoGammaImageChannel(image(),channel_);
2066 throwImageException();
2067 }
2068
autoLevel(void)2069 void Magick::Image::autoLevel(void)
2070 {
2071 modifyImage();
2072 (void) AutoLevelImage(image());
2073 throwImageException();
2074 }
2075
autoLevelChannel(const ChannelType channel_)2076 void Magick::Image::autoLevelChannel(const ChannelType channel_)
2077 {
2078 modifyImage();
2079 (void) AutoLevelImageChannel(image(),channel_);
2080 throwImageException();
2081 }
2082
autoOrient(void)2083 void 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
blackThreshold(const std::string & threshold_)2098 void Magick::Image::blackThreshold(const std::string &threshold_)
2099 {
2100 modifyImage();
2101 BlackThresholdImage(image(),threshold_.c_str());
2102 throwImageException();
2103 }
2104
blackThresholdChannel(const ChannelType channel_,const std::string & threshold_)2105 void 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
blueShift(const double factor_)2115 void 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
blur(const double radius_,const double sigma_)2127 void 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
blurChannel(const ChannelType channel_,const double radius_,const double sigma_)2138 void 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
border(const Geometry & geometry_)2151 void 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
brightnessContrast(const double brightness_,const double contrast_)2165 void Magick::Image::brightnessContrast(const double brightness_,
2166 const double contrast_)
2167 {
2168 modifyImage();
2169 BrightnessContrastImage(image(),brightness_,contrast_);
2170 throwImageException();
2171 }
2172
brightnessContrastChannel(const ChannelType channel_,const double brightness_,const double contrast_)2173 void 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
cannyEdge(const double radius_,const double sigma_,const double lowerPercent_,const double upperPercent_)2181 void 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
cdl(const std::string & cdl_)2195 void Magick::Image::cdl(const std::string &cdl_)
2196 {
2197 modifyImage();
2198 (void) ColorDecisionListImage(image(),cdl_.c_str());
2199 throwImageException();
2200 }
2201
channel(const ChannelType channel_)2202 void Magick::Image::channel(const ChannelType channel_)
2203 {
2204 modifyImage();
2205 SeparateImageChannel(image(),channel_);
2206 throwImageException();
2207 }
2208
channelDepth(const ChannelType channel_,const size_t depth_)2209 void Magick::Image::channelDepth(const ChannelType channel_,
2210 const size_t depth_)
2211 {
2212 modifyImage();
2213 SetImageChannelDepth(image(),channel_,depth_);
2214 throwImageException();
2215 }
2216
channelDepth(const ChannelType channel_)2217 size_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
charcoal(const double radius_,const double sigma_)2228 void 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
chop(const Geometry & geometry_)2239 void 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
chromaBluePrimary(const double x_,const double y_)2253 void 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
chromaBluePrimary(double * x_,double * y_) const2260 void 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
chromaGreenPrimary(const double x_,const double y_)2266 void 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
chromaGreenPrimary(double * x_,double * y_) const2273 void 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
chromaRedPrimary(const double x_,const double y_)2279 void 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
chromaRedPrimary(double * x_,double * y_) const2286 void 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
chromaWhitePoint(const double x_,const double y_)2292 void 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
chromaWhitePoint(double * x_,double * y_) const2299 void 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
clamp(void)2305 void Magick::Image::clamp(void)
2306 {
2307 modifyImage();
2308 ClampImage(image());
2309 throwImageException();
2310 }
2311
clampChannel(const ChannelType channel_)2312 void Magick::Image::clampChannel(const ChannelType channel_)
2313 {
2314 modifyImage();
2315 ClampImageChannel(image(),channel_);
2316 throwImageException();
2317 }
2318
clip(void)2319 void Magick::Image::clip(void )
2320 {
2321 modifyImage();
2322 ClipImage(image());
2323 throwImageException();
2324 }
2325
clipPath(const std::string pathname_,const bool inside_)2326 void 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
clut(const Image & clutImage_)2333 void Magick::Image::clut(const Image &clutImage_)
2334 {
2335 modifyImage();
2336 ClutImage(image(),clutImage_.constImage());
2337 throwImageException();
2338 }
2339
clutChannel(const ChannelType channel_,const Image & clutImage_)2340 void Magick::Image::clutChannel(const ChannelType channel_,
2341 const Image &clutImage_)
2342 {
2343 modifyImage();
2344 ClutImageChannel(image(),channel_,clutImage_.constImage());
2345 throwImageException();
2346 }
2347
colorize(const unsigned int opacityRed_,const unsigned int opacityGreen_,const unsigned int opacityBlue_,const Color & penColor_)2348 void 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
colorize(const unsigned int opacity_,const Color & penColor_)2370 void Magick::Image::colorize(const unsigned int opacity_,
2371 const Color &penColor_)
2372 {
2373 colorize(opacity_,opacity_,opacity_,penColor_);
2374 }
2375
colorMap(const size_t index_,const Color & color_)2376 void 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
colorMap(const size_t index_) const2395 Magick::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
colorMatrix(const size_t order_,const double * color_matrix_)2409 void 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
compare(const Image & reference_)2434 bool 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
compare(const Image & reference_,const MetricType metric_)2449 double 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
compareChannel(const ChannelType channel_,const Image & reference_,const MetricType metric_)2461 double 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
compare(const Image & reference_,const MetricType metric_,double * distortion)2474 Magick::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
compareChannel(const ChannelType channel_,const Image & reference_,const MetricType metric_,double * distortion)2490 Magick::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
composite(const Image & compositeImage_,const Geometry & offset_,const CompositeOperator compose_)2506 void 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
composite(const Image & compositeImage_,const GravityType gravity_,const CompositeOperator compose_)2525 void 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
composite(const Image & compositeImage_,const ssize_t xOffset_,const ssize_t yOffset_,const CompositeOperator compose_)2541 void 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
connectedComponents(const size_t connectivity_)2554 void 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
contrast(const size_t sharpen_)2565 void Magick::Image::contrast(const size_t sharpen_)
2566 {
2567 modifyImage();
2568 ContrastImage(image(),(MagickBooleanType) sharpen_);
2569 throwImageException();
2570 }
2571
contrastStretch(const double black_point_,const double white_point_)2572 void 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
contrastStretchChannel(const ChannelType channel_,const double black_point_,const double white_point_)2581 void 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
convolve(const size_t order_,const double * kernel_)2589 void 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
copyPixels(const Image & source_,const Geometry & geometry_,const Offset & offset_)2600 void 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
crop(const Geometry & geometry_)2616 void 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
cycleColormap(const ssize_t amount_)2630 void Magick::Image::cycleColormap(const ssize_t amount_)
2631 {
2632 modifyImage();
2633 CycleColormapImage(image(),amount_);
2634 throwImageException();
2635 }
2636
decipher(const std::string & passphrase_)2637 void Magick::Image::decipher(const std::string &passphrase_)
2638 {
2639 modifyImage();
2640 GetPPException;
2641 DecipherImage(image(),passphrase_.c_str(),exceptionInfo);
2642 ThrowImageException;
2643 }
2644
defineSet(const std::string & magick_,const std::string & key_,bool flag_)2645 void 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
defineSet(const std::string & magick_,const std::string & key_) const2659 bool 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
defineValue(const std::string & magick_,const std::string & key_,const std::string & value_)2675 void 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
defineValue(const std::string & magick_,const std::string & key_) const2686 std::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
deskew(const double threshold_)2702 void 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
despeckle(void)2713 void 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
determineType(void) const2724 Magick::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
display(void)2735 void Magick::Image::display(void)
2736 {
2737 DisplayImages(imageInfo(),image());
2738 }
2739
distort(const DistortImageMethod method_,const size_t number_arguments_,const double * arguments_,const bool bestfit_)2740 void 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
draw(const Magick::Drawable & drawable_)2753 void 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
draw(const std::list<Magick::Drawable> & drawable_)2775 void 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
edge(const double radius_)2803 void 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
emboss(const double radius_,const double sigma_)2814 void 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
encipher(const std::string & passphrase_)2825 void Magick::Image::encipher(const std::string &passphrase_)
2826 {
2827 modifyImage();
2828 GetPPException;
2829 EncipherImage(image(),passphrase_.c_str(),exceptionInfo);
2830 ThrowImageException;
2831 }
2832
enhance(void)2833 void 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
equalize(void)2844 void Magick::Image::equalize(void)
2845 {
2846 modifyImage();
2847 EqualizeImage(image());
2848 throwImageException();
2849 }
2850
erase(void)2851 void Magick::Image::erase(void)
2852 {
2853 modifyImage();
2854 (void) SetImageBackgroundColor(image());
2855 throwImageException();
2856 }
2857
extent(const Geometry & geometry_)2858 void 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
extent(const Geometry & geometry_,const Color & backgroundColor_)2877 void Magick::Image::extent(const Geometry &geometry_,
2878 const Color &backgroundColor_)
2879 {
2880 backgroundColor(backgroundColor_);
2881 extent(geometry_);
2882 }
2883
extent(const Geometry & geometry_,const Color & backgroundColor_,const GravityType gravity_)2884 void 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
extent(const Geometry & geometry_,const GravityType gravity_)2892 void 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
flip(void)2905 void 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
floodFillColor(const Geometry & point_,const Magick::Color & fillColor_)2916 void Magick::Image::floodFillColor(const Geometry &point_,
2917 const Magick::Color &fillColor_)
2918 {
2919 floodFillColor(point_.xOff(),point_.yOff(),fillColor_,false);
2920 }
2921
floodFillColor(const Geometry & point_,const Magick::Color & fillColor_,const bool invert_)2922 void 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
floodFillColor(const ssize_t x_,const ssize_t y_,const Magick::Color & fillColor_)2928 void 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
floodFillColor(const ssize_t x_,const ssize_t y_,const Magick::Color & fillColor_,const bool invert_)2934 void 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
floodFillColor(const Geometry & point_,const Magick::Color & fillColor_,const Magick::Color & borderColor_)2946 void 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
floodFillColor(const Geometry & point_,const Magick::Color & fillColor_,const Magick::Color & borderColor_,const bool invert_)2952 void 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
floodFillColor(const ssize_t x_,const ssize_t y_,const Magick::Color & fillColor_,const Magick::Color & borderColor_)2959 void 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
floodFillColor(const ssize_t x_,const ssize_t y_,const Magick::Color & fillColor_,const Magick::Color & borderColor_,const bool invert_)2965 void 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
floodFillOpacity(const ssize_t x_,const ssize_t y_,const unsigned int opacity_,const bool invert_)2978 void 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
floodFillOpacity(const ssize_t x_,const ssize_t y_,const unsigned int opacity_,const PaintMethod method_)3000 void 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
floodFillOpacity(const::ssize_t x_,const::ssize_t y_,const unsigned int opacity_,const Color & target_,const bool invert_)3006 void 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
floodFillTexture(const Magick::Geometry & point_,const Magick::Image & texture_)3028 void Magick::Image::floodFillTexture(const Magick::Geometry &point_,
3029 const Magick::Image &texture_)
3030 {
3031 floodFillTexture(point_.xOff(),point_.yOff(),texture_,false);
3032 }
3033
floodFillTexture(const Magick::Geometry & point_,const Magick::Image & texture_,const bool invert_)3034 void 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
floodFillTexture(const ssize_t x_,const ssize_t y_,const Magick::Image & texture_)3040 void 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
floodFillTexture(const ssize_t x_,const ssize_t y_,const Magick::Image & texture_,const bool invert_)3046 void 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
floodFillTexture(const Magick::Geometry & point_,const Magick::Image & texture_,const Magick::Color & borderColor_)3058 void 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
floodFillTexture(const Magick::Geometry & point_,const Magick::Image & texture_,const Magick::Color & borderColor_,const bool invert_)3064 void 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
floodFillTexture(const ssize_t x_,const ssize_t y_,const Magick::Image & texture_,const Magick::Color & borderColor_)3071 void 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
floodFillTexture(const ssize_t x_,const ssize_t y_,const Magick::Image & texture_,const Magick::Color & borderColor_,const bool invert_)3077 void 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
flop(void)3090 void 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
fontTypeMetrics(const std::string & text_,TypeMetric * metrics)3101 void 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
fontTypeMetricsMultiline(const std::string & text_,TypeMetric * metrics)3114 void 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 GetMultilineTypeMetrics(image(),drawInfo,&(metrics->_typeMetric));
3123 drawInfo->text=0;
3124 }
3125
frame(const Geometry & geometry_)3126 void 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
frame(const size_t width_,const size_t height_,const ssize_t innerBevel_,const ssize_t outerBevel_)3147 void 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
fx(const std::string expression)3169 void 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
fx(const std::string expression,const Magick::ChannelType channel)3181 void 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
gamma(const double gamma_)3194 void 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
gamma(const double gammaRed_,const double gammaGreen_,const double gammaBlue_)3205 void 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
gaussianBlur(const double width_,const double sigma_)3219 void 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
gaussianBlurChannel(const ChannelType channel_,const double width_,const double sigma_)3230 void 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
getConstIndexes(void) const3243 const 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
getConstPixels(const ssize_t x_,const ssize_t y_,const size_t columns_,const size_t rows_) const3255 const 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
getIndexes(void)3267 Magick::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
getPixels(const ssize_t x_,const ssize_t y_,const size_t columns_,const size_t rows_)3280 Magick::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
grayscale(const PixelIntensityMethod method_)3293 void Magick::Image::grayscale(const PixelIntensityMethod method_)
3294 {
3295 modifyImage();
3296 (void) GrayscaleImage(image(),method_);
3297 throwImageException();
3298 }
3299
haldClut(const Image & clutImage_)3300 void Magick::Image::haldClut(const Image &clutImage_)
3301 {
3302 modifyImage();
3303 (void) HaldClutImage(image(),clutImage_.constImage());
3304 throwImageException();
3305 }
3306
houghLine(const size_t width_,const size_t height_,const size_t threshold_)3307 void 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
implode(const double factor_)3320 void 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
inverseFourierTransform(const Image & phase_)3331 void Magick::Image::inverseFourierTransform(const Image &phase_)
3332 {
3333 inverseFourierTransform(phase_,true);
3334 }
3335
inverseFourierTransform(const Image & phase_,const bool magnitude_)3336 void 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
kuwahara(const double radius_,const double sigma_)3349 void 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
kuwaharaChannel(const ChannelType channel_,const double radius_,const double sigma_)3360 void 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
level(const double black_point,const double white_point,const double gamma)3373 void 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
levelChannel(const Magick::ChannelType channel,const double black_point,const double white_point,const double gamma)3386 void 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
levelColors(const Color & blackColor_,const Color & whiteColor_,const bool invert_)3394 void 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
levelColorsChannel(const ChannelType channel_,const Color & blackColor_,const Color & whiteColor_,const bool invert_)3425 void 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
levelize(const double blackPoint_,const double whitePoint_,const double gamma_)3456 void 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
levelizeChannel(const ChannelType channel_,const double blackPoint_,const double whitePoint_,const double gamma_)3464 void 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
linearStretch(const double blackPoint_,const double whitePoint_)3472 void Magick::Image::linearStretch(const double blackPoint_,
3473 const double whitePoint_)
3474 {
3475 modifyImage();
3476 LinearStretchImage(image(),blackPoint_,whitePoint_);
3477 throwImageException();
3478 }
3479
liquidRescale(const Geometry & geometry_)3480 void 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
localContrast(const double radius_,const double strength_)3502 void 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
magnify(void)3513 void 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
map(const Image & mapImage_,const bool dither_)3524 void 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
matteFloodfill(const Color & target_,const unsigned int opacity_,const ssize_t x_,const ssize_t y_,const Magick::PaintMethod method_)3532 void 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
medianFilter(const double radius_)3540 void 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
mergeLayers(const ImageLayerMethod layerMethod_)3552 void 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
minify(void)3563 void 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
modulate(const double brightness_,const double saturation_,const double hue_)3574 void 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
moments(void) const3588 Magick::ImageMoments Magick::Image::moments(void) const
3589 {
3590 return(ImageMoments(*this));
3591 }
3592
morphology(const MorphologyMethod method_,const std::string kernel_,const ssize_t iterations_)3593 void 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
morphology(const MorphologyMethod method_,const KernelInfoType kernel_,const std::string arguments_,const ssize_t iterations_)3614 void 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
morphologyChannel(const ChannelType channel_,const MorphologyMethod method_,const std::string kernel_,const ssize_t iterations_)3638 void 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
morphologyChannel(const ChannelType channel_,const MorphologyMethod method_,const KernelInfoType kernel_,const std::string arguments_,const ssize_t iterations_)3663 void 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
motionBlur(const double radius_,const double sigma_,const double angle_)3687 void 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
negate(const bool grayscale_)3699 void Magick::Image::negate(const bool grayscale_)
3700 {
3701 modifyImage();
3702 NegateImage(image(),(MagickBooleanType) grayscale_);
3703 throwImageException();
3704 }
3705
negateChannel(const ChannelType channel_,const bool grayscale_)3706 void Magick::Image::negateChannel(const ChannelType channel_,
3707 const bool grayscale_)
3708 {
3709 modifyImage();
3710 NegateImageChannel(image(),channel_,(MagickBooleanType) grayscale_);
3711 throwImageException();
3712 }
3713
normalize(void)3714 void Magick::Image::normalize(void)
3715 {
3716 modifyImage();
3717 NormalizeImage(image());
3718 throwImageException();
3719 }
3720
oilPaint(const double radius_)3721 void 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
opacity(const unsigned int opacity_)3732 void Magick::Image::opacity(const unsigned int opacity_)
3733 {
3734 modifyImage();
3735 SetImageOpacity(image(),opacity_);
3736 }
opaque(const Color & opaqueColor_,const Color & penColor_,const bool invert_)3737 void 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
orderedDither(std::string thresholdMap_)3764 void Magick::Image::orderedDither(std::string thresholdMap_)
3765 {
3766 modifyImage();
3767 GetPPException;
3768 (void) OrderedPosterizeImage(image(),thresholdMap_.c_str(),exceptionInfo);
3769 ThrowImageException;
3770 }
3771
orderedDitherChannel(const ChannelType channel_,std::string thresholdMap_)3772 void 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
perceptible(const double epsilon_)3782 void Magick::Image::perceptible(const double epsilon_)
3783 {
3784 modifyImage();
3785 PerceptibleImage(image(),epsilon_);
3786 throwImageException();
3787 }
3788
perceptibleChannel(const ChannelType channel_,const double epsilon_)3789 void Magick::Image::perceptibleChannel(const ChannelType channel_,
3790 const double epsilon_)
3791 {
3792 modifyImage();
3793 PerceptibleImageChannel(image(),channel_,epsilon_);
3794 throwImageException();
3795 }
3796
ping(const Blob & blob_)3797 void 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
ping(const std::string & imageSpec_)3807 void 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
pixelColor(const ssize_t x_,const ssize_t y_,const Color & color_)3818 void 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
pixelColor(const ssize_t x_,const ssize_t y_) const3838 Magick::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
polaroid(const std::string & caption_,const double angle_)3867 void 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
posterize(const size_t levels_,const bool dither_)3880 void Magick::Image::posterize(const size_t levels_,const bool dither_)
3881 {
3882 modifyImage();
3883 PosterizeImage(image(),levels_,(MagickBooleanType) dither_);
3884 throwImageException();
3885 }
3886
posterizeChannel(const ChannelType channel_,const size_t levels_,const bool dither_)3887 void 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
process(std::string name_,const ssize_t argc,const char ** argv)3896 void 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
profile(const std::string name_,const Magick::Blob & profile_)3911 void 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
profile(const std::string name_) const3925 Magick::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
quantize(const bool measureError_)3938 void 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
quantumOperator(const ChannelType channel_,const MagickEvaluateOperator operator_,double rvalue_)3952 void 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
quantumOperator(const ChannelType channel_,const MagickFunction function_,const size_t number_parameters_,const double * parameters_)3960 void 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
quantumOperator(const ssize_t x_,const ssize_t y_,const size_t columns_,const size_t rows_,const ChannelType channel_,const MagickEvaluateOperator operator_,const double rvalue_)3970 void 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
raise(const Geometry & geometry_,const bool raisedFlag_)3993 void 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
randomThreshold(const Geometry & thresholds_)4005 void 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
randomThresholdChannel(const Geometry & thresholds_,const ChannelType channel_)4014 void 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
read(const Blob & blob_)4024 void 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
read(const Blob & blob_,const Geometry & size_)4035 void Magick::Image::read(const Blob &blob_,const Geometry &size_)
4036 {
4037 size(size_);
4038 read(blob_);
4039 }
4040
read(const Blob & blob_,const Geometry & size_,const size_t depth_)4041 void 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
read(const Blob & blob_,const Geometry & size_,const size_t depth_,const std::string & magick_)4049 void 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
read(const Blob & blob_,const Geometry & size_,const std::string & magick_)4059 void 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
read(const Geometry & size_,const std::string & imageSpec_)4068 void Magick::Image::read(const Geometry &size_,const std::string &imageSpec_)
4069 {
4070 size(size_);
4071 read(imageSpec_);
4072 }
4073
read(const size_t width_,const size_t height_,const std::string & map_,const StorageType type_,const void * pixels_)4074 void 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
read(const std::string & imageSpec_)4089 void 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
readPixels(const Magick::QuantumType quantum_,const unsigned char * source_)4101 void 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
reduceNoise(const double order_)4115 void 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
repage()4127 void 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
resample(const Geometry & geometry_)4137 void 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
resize(const Geometry & geometry_)4160 void 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
roll(const Geometry & roll_)4183 void 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
roll(const size_t columns_,const size_t rows_)4203 void 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
rotate(const double degrees_)4215 void 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
rotationalBlur(const double angle_)4226 void 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
rotationalBlurChannel(const ChannelType channel_,const double angle_)4237 void 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
sample(const Geometry & geometry_)4250 void 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
scale(const Geometry & geometry_)4272 void 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
segment(const double clusterThreshold_,const double smoothingThreshold_)4294 void 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
selectiveBlur(const double radius_,const double sigma_,const double threshold_)4306 void 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
selectiveBlurChannel(const ChannelType channel_,const double radius_,const double sigma_,const double threshold_)4319 void 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
separate(const ChannelType channel_) const4332 Magick::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
sepiaTone(const double threshold_)4346 void 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
setPixels(const ssize_t x_,const ssize_t y_,const size_t columns_,const size_t rows_)4357 Magick::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
shade(const double azimuth_,const double elevation_,const bool colorShading_)4370 void 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
shadow(const double percent_opacity_,const double sigma_,const ssize_t x_,const ssize_t y_)4383 void 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
sharpen(const double radius_,const double sigma_)4395 void 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
sharpenChannel(const ChannelType channel_,const double radius_,const double sigma_)4406 void 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
shave(const Geometry & geometry_)4419 void 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
shear(const double xShearAngle_,const double yShearAngle_)4433 void 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
sigmoidalContrast(const size_t sharpen_,const double contrast,const double midpoint)4444 void 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
signature(const bool force_) const4453 std::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
sketch(const double radius_,const double sigma_,const double angle_)4470 void 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
solarize(const double factor_)4482 void Magick::Image::solarize(const double factor_)
4483 {
4484 modifyImage();
4485 SolarizeImage(image(),factor_);
4486 throwImageException();
4487 }
4488
sparseColor(const ChannelType channel,const SparseColorMethod method,const size_t number_arguments,const double * arguments)4489 void 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
splice(const Geometry & geometry_)4503 void 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
splice(const Geometry & geometry_,const Color & backgroundColor_)4517 void Magick::Image::splice(const Geometry &geometry_,
4518 const Color &backgroundColor_)
4519 {
4520 backgroundColor(backgroundColor_);
4521 splice(geometry_);
4522 }
4523
splice(const Geometry & geometry_,const Color & backgroundColor_,const GravityType gravity_)4524 void 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
spread(const size_t amount_)4532 void 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
statistics(ImageStatistics * statistics) const4543 void 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
stegano(const Image & watermark_)4587 void 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
stereo(const Image & rightImage_)4598 void 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
strip(void)4609 void Magick::Image::strip(void)
4610 {
4611 modifyImage();
4612 StripImage(image());
4613 throwImageException();
4614 }
4615
subImageSearch(const Image & reference_,const MetricType metric_,Geometry * offset_,double * similarityMetric_,const double similarityThreshold)4616 Magick::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
swirl(const double degrees_)4645 void 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
syncPixels(void)4656 void Magick::Image::syncPixels(void)
4657 {
4658 GetPPException;
4659 (void) SyncAuthenticPixels(image(),exceptionInfo);
4660 ThrowImageException;
4661 }
4662
texture(const Image & texture_)4663 void Magick::Image::texture(const Image &texture_)
4664 {
4665 modifyImage();
4666 TextureImage(image(),texture_.constImage());
4667 throwImageException();
4668 }
4669
threshold(const double threshold_)4670 void Magick::Image::threshold(const double threshold_)
4671 {
4672 modifyImage();
4673 BilevelImage(image(),threshold_);
4674 throwImageException();
4675 }
4676
thumbnail(const Geometry & geometry_)4677 void 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
tint(const std::string opacity_)4699 void 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
transform(const Geometry & imageGeometry_)4711 void Magick::Image::transform(const Geometry &imageGeometry_)
4712 {
4713 modifyImage();
4714 TransformImage(&(image()),0,std::string(imageGeometry_).c_str());
4715 throwImageException();
4716 }
4717
transform(const Geometry & imageGeometry_,const Geometry & cropGeometry_)4718 void 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
transformOrigin(const double x_,const double y_)4727 void Magick::Image::transformOrigin(const double x_,const double y_)
4728 {
4729 modifyImage();
4730 options()->transformOrigin(x_,y_);
4731 }
4732
transformReset(void)4733 void Magick::Image::transformReset(void)
4734 {
4735 modifyImage();
4736 options()->transformReset();
4737 }
4738
transformScale(const double sx_,const double sy_)4739 void Magick::Image::transformScale(const double sx_,const double sy_)
4740 {
4741 modifyImage();
4742 options()->transformScale(sx_,sy_);
4743 }
4744
transparent(const Color & color_)4745 void 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
transparentChroma(const Color & colorLow_,const Color & colorHigh_)4765 void 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
transpose(void)4790 void 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
transverse(void)4801 void 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
trim(void)4812 void 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
uniqueColors(void) const4823 Magick::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
unsharpmask(const double radius_,const double sigma_,const double amount_,const double threshold_)4837 void 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
unsharpmaskChannel(const ChannelType channel_,const double radius_,const double sigma_,const double amount_,const double threshold_)4850 void 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
vignette(const double radius_,const double sigma_,const ssize_t x_,const ssize_t y_)4864 void 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
wave(const double amplitude_,const double wavelength_)4876 void 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
waveletDenoise(const double threshold_,const double softness_)4887 void 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
whiteThreshold(const std::string & threshold_)4900 void Magick::Image::whiteThreshold(const std::string &threshold_)
4901 {
4902 modifyImage();
4903 WhiteThresholdImage(image(),threshold_.c_str());
4904 throwImageException();
4905 }
4906
whiteThresholdChannel(const ChannelType channel_,const std::string & threshold_)4907 void 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
write(Blob * blob_)4917 void 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
write(Blob * blob_,const std::string & magick_)4936 void 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
write(Blob * blob_,const std::string & magick_,const size_t depth_)4956 void 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
write(const ssize_t x_,const ssize_t y_,const size_t columns_,const size_t rows_,const std::string & map_,const StorageType type_,void * pixels_)4978 void 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
write(const std::string & imageSpec_)4988 void Magick::Image::write(const std::string &imageSpec_)
4989 {
4990 modifyImage();
4991 fileName(imageSpec_);
4992 WriteImage(constImageInfo(),image());
4993 throwImageException();
4994 }
4995
writePixels(const Magick::QuantumType quantum_,unsigned char * destination_)4996 void 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
zoom(const Geometry & geometry_)5010 void 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
Image(MagickCore::Image * image_)5033 Magick::Image::Image(MagickCore::Image *image_)
5034 : _imgRef(new ImageRef(image_))
5035 {
5036 }
5037
image(void)5038 MagickCore::Image *&Magick::Image::image(void)
5039 {
5040 return(_imgRef->image());
5041 }
5042
constImage(void) const5043 const MagickCore::Image *Magick::Image::constImage(void) const
5044 {
5045 return(_imgRef->image());
5046 }
5047
imageInfo(void)5048 MagickCore::ImageInfo *Magick::Image::imageInfo(void)
5049 {
5050 return(_imgRef->options()->imageInfo());
5051 }
5052
constImageInfo(void) const5053 const MagickCore::ImageInfo *Magick::Image::constImageInfo(void) const
5054 {
5055 return(_imgRef->options()->imageInfo());
5056 }
5057
options(void)5058 Magick::Options *Magick::Image::options(void)
5059 {
5060 return(_imgRef->options());
5061 }
5062
constOptions(void) const5063 const Magick::Options *Magick::Image::constOptions(void) const
5064 {
5065 return(_imgRef->options());
5066 }
5067
quantizeInfo(void)5068 MagickCore::QuantizeInfo *Magick::Image::quantizeInfo(void)
5069 {
5070 return(_imgRef->options()->quantizeInfo());
5071 }
5072
constQuantizeInfo(void) const5073 const MagickCore::QuantizeInfo *Magick::Image::constQuantizeInfo(void) const
5074 {
5075 return(_imgRef->options()->quantizeInfo());
5076 }
5077
modifyImage(void)5078 void 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
replaceImage(MagickCore::Image * replacement_)5092 MagickCore::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
throwImageException(void) const5121 void 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
read(MagickCore::Image * image,MagickCore::ExceptionInfo * exceptionInfo)5128 void 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
floodFill(const ssize_t x_,const ssize_t y_,const Magick::Image * fillPattern_,const Magick::Color & fill_,const MagickCore::PixelPacket * target_,const bool invert_)5162 void 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 }
5207