www/api/Magick++/STL_8h_source.html
| Magick++ 7.1.0 |
STL.h
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 //
5 // Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
6 // dedicated to making software imaging solutions freely available.
7 //
8 // Definition and implementation of template functions for using
9 // Magick::Image with STL containers.
10 //
11
12 #ifndef Magick_STL_header
13 #define Magick_STL_header
14
15 #include "Magick++/Include.h"
16 #include <algorithm>
17 #include <functional>
18 #include <iterator>
19 #include <map>
20 #include <utility>
21
22 #include "Magick++/CoderInfo.h"
23 #include "Magick++/Drawable.h"
24 #include "Magick++/Exception.h"
25 #include "Magick++/Montage.h"
26
27 namespace Magick
28 {
29//
30// STL function object declarations/definitions
31//
32
33// Function objects provide the means to invoke an operation on one
34// or more image objects in an STL-compatable container. The
35// arguments to the function object constructor(s) are compatable
36// with the arguments to the equivalent Image class method and
37// provide the means to supply these options when the function
38// object is invoked.
39
40// For example, to read a GIF animation, set the color red to
41// transparent for all frames, and write back out:
42//
43// list<image> images;
44// readImages( &images, "animation.gif" );
45// for_each( images.begin(), images.end(), transparentImage( "red" ) );
46// writeImages( images.begin(), images.end(), "animation.gif" );
47
48// Adaptive-blur image with specified blur factor
49class MagickPPExport adaptiveBlurImage
50 {
51public:
52adaptiveBlurImage( const double radius_ = 1, const double sigma_ = 0.5 );
53
54void operator()( Image &image_ ) const;
55
56private:
57double _radius;
58double _sigma;
59 };
60
61// Local adaptive threshold image
62// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm
63// Width x height define the size of the pixel neighborhood
64// offset = constant to subtract from pixel neighborhood mean
65class MagickPPExport adaptiveThresholdImage
66 {
67public:
68adaptiveThresholdImage( const size_t width_,
69const size_t height_,
70 const ::ssize_t offset_ = 0 );
71
72void operator()( Image &image_ ) const;
73
74private:
75size_t _width;
76size_t _height;
77 ::ssize_t _offset;
78 };
79
80// Add noise to image with specified noise type
81class MagickPPExport addNoiseImage
82 {
83public:
84addNoiseImage(const NoiseType noiseType_,const double attenuate_ = 1.0);
85
86void operator()(Image &image_) const;
87
88private:
89 NoiseType _noiseType;
90double _attenuate;
91 };
92
93// Transform image by specified affine (or free transform) matrix.
94class MagickPPExport affineTransformImage
95 {
96public:
97affineTransformImage( const DrawableAffine &affine_ );
98
99void operator()( Image &image_ ) const;
100
101private:
102DrawableAffine _affine;
103 };
104
105// Annotate image (draw text on image)
106class MagickPPExport annotateImage
107 {
108public:
109// Annotate using specified text, and placement location
110annotateImage ( const std::string &text_,
111const Geometry &geometry_ );
112
113// Annotate using specified text, bounding area, and placement
114// gravity
115annotateImage ( const std::string &text_,
116const Geometry &geometry_,
117const GravityType gravity_ );
118
119// Annotate with text using specified text, bounding area,
120// placement gravity, and rotation.
121annotateImage ( const std::string &text_,
122const Geometry &geometry_,
123const GravityType gravity_,
124const double degrees_ );
125
126// Annotate with text (bounding area is entire image) and
127// placement gravity.
128annotateImage ( const std::string &text_,
129const GravityType gravity_ );
130
131void operator()( Image &image_ ) const;
132
133private:
134const std::string _text;
135const Geometry _geometry;
136const GravityType _gravity;
137const double _degrees;
138 };
139
140// Blur image with specified blur factor
141class MagickPPExport blurImage
142 {
143public:
144blurImage( const double radius_ = 1, const double sigma_ = 0.5 );
145
146void operator()( Image &image_ ) const;
147
148private:
149double _radius;
150double _sigma;
151 };
152
153// Border image (add border to image)
154class MagickPPExport borderImage
155 {
156public:
157borderImage( const Geometry &geometry_ = borderGeometryDefault );
158
159void operator()( Image &image_ ) const;
160
161private:
162Geometry _geometry;
163 };
164
165// Extract channel from image
166class MagickPPExport channelImage
167 {
168public:
169channelImage( const ChannelType channel_ );
170
171void operator()( Image &image_ ) const;
172
173private:
174 ChannelType _channel;
175 };
176
177// Charcoal effect image (looks like charcoal sketch)
178class MagickPPExport charcoalImage
179 {
180public:
181charcoalImage( const double radius_ = 1, const double sigma_ = 0.5 );
182
183void operator()( Image &image_ ) const;
184
185private:
186double _radius;
187double _sigma;
188 };
189
190// Chop image (remove vertical or horizontal subregion of image)
191class MagickPPExport chopImage
192 {
193public:
194chopImage( const Geometry &geometry_ );
195
196void operator()( Image &image_ ) const;
197
198private:
199Geometry _geometry;
200 };
201
202// Accepts a lightweight Color Correction Collection (CCC) file which solely
203// contains one or more color corrections and applies the correction to the
204// image.
205class MagickPPExport cdlImage
206 {
207public:
208cdlImage( const std::string &cdl_ );
209
210void operator()( Image &image_ ) const;
211
212private:
213 std::string _cdl;
214 };
215
216// Colorize image using pen color at specified percent alpha
217class MagickPPExport colorizeImage
218 {
219public:
220colorizeImage( const unsigned int alphaRed_,
221const unsigned int alphaGreen_,
222const unsigned int alphaBlue_,
223const Color &penColor_ );
224
225colorizeImage( const unsigned int alpha_,
226const Color &penColor_ );
227
228void operator()( Image &image_ ) const;
229
230private:
231unsigned int _alphaRed;
232unsigned int _alphaGreen;
233unsigned int _alphaBlue;
234Color _penColor;
235 };
236
237// Apply a color matrix to the image channels. The user supplied
238// matrix may be of order 1 to 5 (1x1 through 5x5).
239class MagickPPExport colorMatrixImage
240 {
241public:
242colorMatrixImage( const size_t order_,
243const double *color_matrix_ );
244
245void operator()( Image &image_ ) const;
246
247private:
248size_t _order;
249const double *_color_matrix;
250 };
251
252// Convert the image colorspace representation
253class MagickPPExport colorSpaceImage
254 {
255public:
256colorSpaceImage( ColorspaceType colorSpace_ );
257
258void operator()( Image &image_ ) const;
259
260private:
261 ColorspaceType _colorSpace;
262 };
263
264// Comment image (add comment string to image)
265class MagickPPExport commentImage
266 {
267public:
268commentImage( const std::string &comment_ );
269
270void operator()( Image &image_ ) const;
271
272private:
273 std::string _comment;
274 };
275
276// Compose an image onto another at specified offset and using
277// specified algorithm
278class MagickPPExport compositeImage
279 {
280public:
281compositeImage( const Image &compositeImage_,
282 ::ssize_t xOffset_,
283 ::ssize_t yOffset_,
284 CompositeOperator compose_ = InCompositeOp );
285
286compositeImage( const Image &compositeImage_,
287const Geometry &offset_,
288 CompositeOperator compose_ = InCompositeOp );
289
290void operator()( Image &image_ ) const;
291
292private:
293Image _compositeImage;
294 ::ssize_t _xOffset;
295 ::ssize_t _yOffset;
296 CompositeOperator _compose;
297 };
298
299// Contrast image (enhance intensity differences in image)
300class MagickPPExport contrastImage
301 {
302public:
303contrastImage( const size_t sharpen_ );
304
305void operator()( Image &image_ ) const;
306
307private:
308size_t _sharpen;
309 };
310
311// Crop image (subregion of original image)
312class MagickPPExport cropImage
313 {
314public:
315cropImage( const Geometry &geometry_ );
316
317void operator()( Image &image_ ) const;
318
319private:
320Geometry _geometry;
321 };
322
323// Cycle image colormap
324class MagickPPExport cycleColormapImage
325 {
326public:
327cycleColormapImage( const ::ssize_t amount_ );
328
329void operator()( Image &image_ ) const;
330
331private:
332 ::ssize_t _amount;
333 };
334
335// Despeckle image (reduce speckle noise)
336class MagickPPExport despeckleImage
337 {
338public:
339despeckleImage( void );
340
341void operator()( Image &image_ ) const;
342
343private:
344 };
345
346// Distort image. distorts an image using various distortion methods, by
347// mapping color lookups of the source image to a new destination image
348// usally of the same size as the source image, unless 'bestfit' is set to
349// true.
350class MagickPPExport distortImage
351 {
352public:
353distortImage( const Magick::DistortMethod method_,
354const size_t number_arguments_,
355const double *arguments_,
356const bool bestfit_ );
357
358distortImage( const Magick::DistortMethod method_,
359const size_t number_arguments_,
360const double *arguments_ );
361
362void operator()( Image &image_ ) const;
363
364private:
365 DistortMethod _method;
366size_t _number_arguments;
367const double *_arguments;
368bool _bestfit;
369 };
370
371// Draw on image
372class MagickPPExport drawImage
373 {
374public:
375// Draw on image using a single drawable
376// Store in list to make implementation easier
377drawImage( const Drawable &drawable_ );
378
379// Draw on image using a drawable list
380drawImage( const DrawableList &drawable_ );
381
382void operator()( Image &image_ ) const;
383
384private:
385DrawableList _drawableList;
386 };
387
388// Edge image (hilight edges in image)
389class MagickPPExport edgeImage
390 {
391public:
392edgeImage( const double radius_ = 0.0 );
393
394void operator()( Image &image_ ) const;
395
396private:
397double _radius;
398 };
399
400// Emboss image (hilight edges with 3D effect)
401class MagickPPExport embossImage
402 {
403public:
404embossImage( void );
405embossImage( const double radius_, const double sigma_ );
406
407void operator()( Image &image_ ) const;
408
409private:
410double _radius;
411double _sigma;
412 };
413
414// Enhance image (minimize noise)
415class MagickPPExport enhanceImage
416 {
417public:
418enhanceImage( void );
419
420void operator()( Image &image_ ) const;
421
422private:
423 };
424
425// Equalize image (histogram equalization)
426class MagickPPExport equalizeImage
427 {
428public:
429equalizeImage( void );
430
431void operator()( Image &image_ ) const;
432
433private:
434 };
435
436// Color to use when filling drawn objects
437class MagickPPExport fillColorImage
438 {
439public:
440fillColorImage( const Color &fillColor_ );
441
442void operator()( Image &image_ ) const;
443
444private:
445Color _fillColor;
446 };
447
448// Flip image (reflect each scanline in the vertical direction)
449class MagickPPExport flipImage
450 {
451public:
452flipImage( void );
453
454void operator()( Image &image_ ) const;
455
456private:
457 };
458
459// Floodfill designated area with a matte value
460class MagickPPExport floodFillAlphaImage
461
462 {
463public:
464floodFillAlphaImage(const ::ssize_t x_,const ::ssize_t y_,
465const unsigned int alpha_,const Color &target_,const bool invert_=false);
466
467void operator()(Image &image_) const;
468
469private:
470Color _target;
471unsigned int _alpha;
472 ::ssize_t _x;
473 ::ssize_t _y;
474bool _invert;
475 };
476
477// Flood-fill image with color
478class MagickPPExport floodFillColorImage
479
480 {
481public:
482// Flood-fill color across pixels starting at target-pixel and
483// stopping at pixels matching specified border color.
484// Uses current fuzz setting when determining color match.
485floodFillColorImage(const Geometry &point_,const Color &fillColor_,
486const bool invert_=false);
487floodFillColorImage(const ::ssize_t x_,const ::ssize_t y_,
488const Color &fillColor_,const bool invert_=false);
489
490// Flood-fill color across pixels starting at target-pixel and
491// stopping at pixels matching specified border color.
492// Uses current fuzz setting when determining color match.
493floodFillColorImage(const Geometry &point_,const Color &fillColor_,
494const Color &borderColor_,const bool invert_=false);
495floodFillColorImage(const ::ssize_t x_,const ::ssize_t y_,
496const Color &fillColor_,const Color &borderColor_,
497const bool invert_=false);
498
499void operator()(Image &image_) const;
500
501private:
502 ::ssize_t _x;
503 ::ssize_t _y;
504Color _fillColor;
505Color _borderColor;
506bool _invert;
507 };
508
509// Flood-fill image with texture
510class MagickPPExport floodFillTextureImage
511
512 {
513public:
514// Flood-fill texture across pixels that match the color of the
515// target pixel and are neighbors of the target pixel.
516// Uses current fuzz setting when determining color match.
517floodFillTextureImage(const ::ssize_t x_,const ::ssize_t y_,
518const Image &texture_,const bool invert_=false);
519floodFillTextureImage(const Geometry &point_,const Image &texture_,
520const bool invert_=false);
521
522// Flood-fill texture across pixels starting at target-pixel and
523// stopping at pixels matching specified border color.
524// Uses current fuzz setting when determining color match.
525floodFillTextureImage(const ::ssize_t x_,const ::ssize_t y_,
526const Image &texture_,const Color &borderColor_,
527const bool invert_=false);
528
529floodFillTextureImage(const Geometry &point_,const Image &texture_,
530const Color &borderColor_,const bool invert_=false);
531
532void operator()(Image &image_) const;
533
534private:
535 ::ssize_t _x;
536 ::ssize_t _y;
537Image _texture;
538Color _borderColor;
539bool _invert;
540 };
541
542// Flop image (reflect each scanline in the horizontal direction)
543class MagickPPExport flopImage
544 {
545public:
546flopImage( void );
547
548void operator()( Image &image_ ) const;
549
550private:
551 };
552
553// Frame image
554class MagickPPExport frameImage
555 {
556public:
557frameImage( const Geometry &geometry_ = frameGeometryDefault );
558
559frameImage( const size_t width_, const size_t height_,
560 const ::ssize_t innerBevel_ = 6, const ::ssize_t outerBevel_ = 6 );
561
562void operator()( Image &image_ ) const;
563
564private:
565size_t _width;
566size_t _height;
567 ::ssize_t _outerBevel;
568 ::ssize_t _innerBevel;
569 };
570
571// Gamma correct image
572class MagickPPExport gammaImage
573 {
574public:
575gammaImage( const double gamma_ );
576
577gammaImage ( const double gammaRed_,
578const double gammaGreen_,
579const double gammaBlue_ );
580
581void operator()( Image &image_ ) const;
582
583private:
584double _gammaRed;
585double _gammaGreen;
586double _gammaBlue;
587 };
588
589// Gaussian blur image
590// The number of neighbor pixels to be included in the convolution
591// mask is specified by 'width_'. The standard deviation of the
592// gaussian bell curve is specified by 'sigma_'.
593class MagickPPExport gaussianBlurImage
594 {
595public:
596gaussianBlurImage( const double width_, const double sigma_ );
597
598void operator()( Image &image_ ) const;
599
600private:
601double _width;
602double _sigma;
603 };
604
605// Apply a color lookup table (Hald CLUT) to the image.
606class MagickPPExport haldClutImage
607 {
608public:
609haldClutImage( const Image &haldClutImage_ );
610
611void operator()( Image &image_ ) const;
612
613private:
614Image _haldClutImage;
615 };
616
617// Implode image (special effect)
618class MagickPPExport implodeImage
619 {
620public:
621implodeImage( const double factor_ = 50 );
622
623void operator()( Image &image_ ) const;
624
625private:
626double _factor;
627 };
628
629// implements the inverse discrete Fourier transform (IFT) of the image
630// either as a magnitude / phase or real / imaginary image pair.
631class MagickPPExport inverseFourierTransformImage
632 {
633public:
634inverseFourierTransformImage( const Image &phaseImage_ );
635
636void operator()( Image &image_ ) const;
637
638private:
639Image _phaseImage;
640 };
641
642// Set image validity. Valid images become empty (inValid) if
643// argument is false.
644class MagickPPExport isValidImage
645 {
646public:
647isValidImage( const bool isValid_ );
648
649void operator()( Image &image_ ) const;
650
651private:
652bool _isValid;
653 };
654
655// Label image
656class MagickPPExport labelImage
657 {
658public:
659labelImage( const std::string &label_ );
660
661void operator()( Image &image_ ) const;
662
663private:
664 std::string _label;
665 };
666
667
668// Level image
669class MagickPPExport levelImage
670 {
671public:
672levelImage( const double black_point,
673const double white_point,
674const double mid_point=1.0 );
675
676void operator()( Image &image_ ) const;
677
678private:
679double _black_point;
680double _white_point;
681double _mid_point;
682 };
683
684// Magnify image by integral size
685class MagickPPExport magnifyImage
686 {
687public:
688magnifyImage( void );
689
690void operator()( Image &image_ ) const;
691
692private:
693 };
694
695// Remap image colors with closest color from reference image
696class MagickPPExport mapImage
697 {
698public:
699mapImage( const Image &mapImage_ ,
700const bool dither_ = false );
701
702void operator()( Image &image_ ) const;
703
704private:
705Image _mapImage;
706bool _dither;
707 };
708
709// Filter image by replacing each pixel component with the median
710// color in a circular neighborhood
711class MagickPPExport medianConvolveImage
712 {
713public:
714medianConvolveImage( const double radius_ = 0.0 );
715
716void operator()( Image &image_ ) const;
717
718private:
719double _radius;
720 };
721
722// Merge image layers
723class MagickPPExport mergeLayersImage
724 {
725public:
726mergeLayersImage ( LayerMethod layerMethod_ );
727
728void operator()( Image &image_ ) const;
729
730private:
731 LayerMethod _layerMethod;
732 };
733
734// Reduce image by integral size
735class MagickPPExport minifyImage
736 {
737public:
738minifyImage( void );
739
740void operator()( Image &image_ ) const;
741
742private:
743 };
744
745// Modulate percent hue, saturation, and brightness of an image
746class MagickPPExport modulateImage
747 {
748public:
749modulateImage( const double brightness_,
750const double saturation_,
751const double hue_ );
752
753void operator()( Image &image_ ) const;
754
755private:
756double _brightness;
757double _saturation;
758double _hue;
759 };
760
761// Negate colors in image. Set grayscale to only negate grayscale
762// values in image.
763class MagickPPExport negateImage
764 {
765public:
766negateImage( const bool grayscale_ = false );
767
768void operator()( Image &image_ ) const;
769
770private:
771bool _grayscale;
772 };
773
774// Normalize image (increase contrast by normalizing the pixel
775// values to span the full range of color values)
776class MagickPPExport normalizeImage
777 {
778public:
779normalizeImage( void );
780
781void operator()( Image &image_ ) const;
782
783private:
784 };
785
786// Oilpaint image (image looks like oil painting)
787class MagickPPExport oilPaintImage
788 {
789public:
790oilPaintImage( const double radius_ = 3 );
791
792void operator()( Image &image_ ) const;
793
794private:
795double _radius;
796 };
797
798// Set or attenuate the image alpha channel. If the image pixels
799// are opaque then they are set to the specified alpha value,
800// otherwise they are blended with the supplied alpha value. The
801// value of alpha_ ranges from 0 (completely opaque) to
802// QuantumRange. The defines OpaqueAlpha and TransparentAlpha are
803// available to specify completely opaque or completely transparent,
804// respectively.
805class MagickPPExport alphaImage
806 {
807public:
808alphaImage( const unsigned int alpha_ );
809
810void operator()( Image &image_ ) const;
811
812private:
813unsigned int _alpha;
814 };
815
816// Change color of opaque pixel to specified pen color.
817class MagickPPExport opaqueImage
818 {
819public:
820opaqueImage( const Color &opaqueColor_,
821const Color &penColor_ );
822
823void operator()( Image &image_ ) const;
824
825private:
826Color _opaqueColor;
827Color _penColor;
828 };
829
830// Quantize image (reduce number of colors)
831class MagickPPExport quantizeImage
832 {
833public:
834quantizeImage( const bool measureError_ = false );
835
836void operator()( Image &image_ ) const;
837
838private:
839bool _measureError;
840 };
841
842// Raise image (lighten or darken the edges of an image to give a
843// 3-D raised or lowered effect)
844class MagickPPExport raiseImage
845 {
846public:
847raiseImage( const Geometry &geometry_ = raiseGeometryDefault,
848const bool raisedFlag_ = false );
849
850void operator()( Image &image_ ) const;
851
852private:
853Geometry _geometry;
854bool _raisedFlag;
855 };
856
857class MagickPPExport ReadOptions
858 {
859public:
860
861// Default constructor
862ReadOptions(void);
863
864// Copy constructor
865ReadOptions(const ReadOptions& options_);
866
867// Destructor
868 ~ReadOptions();
869
870// Vertical and horizontal resolution in pixels of the image
871void density(const Geometry &geomery_);
872Geometry density(void) const;
873
874// Image depth (8 or 16)
875void depth(size_t depth_);
876size_t depth(void) const;
877
878// Ping the image instead of reading it
879void ping(const bool flag_);
880bool ping(void) const;
881
882// Suppress all warning messages. Error messages are still reported.
883void quiet(const bool quiet_);
884bool quiet(void) const;
885
886// Image size (required for raw formats)
887void size(const Geometry &geometry_);
888Geometry size(void) const;
889
890//
891// Internal implementation methods. Please do not use.
892//
893
894 MagickCore::ImageInfo *imageInfo(void);
895
896private:
897
898// Assignment not supported
899ReadOptions& operator=(const ReadOptions&);
900
901 MagickCore::ImageInfo *_imageInfo;
902bool _quiet;
903 };
904
905// Reduce noise in image using a noise peak elimination filter
906class MagickPPExport reduceNoiseImage
907 {
908public:
909reduceNoiseImage( void );
910
911reduceNoiseImage (constsize_t order_ );
912
913void operator()( Image &image_ ) const;
914
915private:
916size_t _order;
917 };
918
919// Resize image to specified size.
920class MagickPPExport resizeImage
921 {
922public:
923resizeImage( const Geometry &geometry_ );
924
925void operator()( Image &image_ ) const;
926
927private:
928Geometry _geometry;
929 };
930
931// Roll image (rolls image vertically and horizontally) by specified
932// number of columnms and rows)
933class MagickPPExport rollImage
934 {
935public:
936rollImage( const Geometry &roll_ );
937
938rollImage( const ::ssize_t columns_, const ::ssize_t rows_ );
939
940void operator()( Image &image_ ) const;
941
942private:
943size_t _columns;
944size_t _rows;
945 };
946
947// Rotate image counter-clockwise by specified number of degrees.
948class MagickPPExport rotateImage
949 {
950public:
951rotateImage( const double degrees_ );
952
953void operator()( Image &image_ ) const;
954
955private:
956double _degrees;
957 };
958
959// Resize image by using pixel sampling algorithm
960class MagickPPExport sampleImage
961 {
962public:
963sampleImage( const Geometry &geometry_ );
964
965void operator()( Image &image_ ) const;
966
967private:
968Geometry _geometry;
969 };
970
971// Resize image by using simple ratio algorithm
972class MagickPPExport scaleImage
973 {
974public:
975scaleImage( const Geometry &geometry_ );
976
977void operator()( Image &image_ ) const;
978
979private:
980Geometry _geometry;
981 };
982
983// Segment (coalesce similar image components) by analyzing the
984// histograms of the color components and identifying units that are
985// homogeneous with the fuzzy c-means technique.
986// Also uses QuantizeColorSpace and Verbose image attributes
987class MagickPPExport segmentImage
988 {
989public:
990segmentImage( const double clusterThreshold_ = 1.0,
991const double smoothingThreshold_ = 1.5 );
992
993void operator()( Image &image_ ) const;
994
995private:
996double _clusterThreshold;
997double _smoothingThreshold;
998 };
999
1000// Shade image using distant light source
1001class MagickPPExport shadeImage
1002 {
1003public:
1004shadeImage( const double azimuth_ = 30,
1005const double elevation_ = 30,
1006const bool colorShading_ = false );
1007
1008void operator()( Image &image_ ) const;
1009
1010private:
1011double _azimuth;
1012double _elevation;
1013bool _colorShading;
1014 };
1015
1016// Shadow effect image (simulate an image shadow)
1017class MagickPPExport shadowImage
1018 {
1019public:
1020shadowImage( const double percent_opacity_ = 80, const double sigma_ = 0.5,
1021const ssize_t x_ = 5, const ssize_t y_ = 5 );
1022
1023void operator()( Image &image_ ) const;
1024
1025private:
1026double _percent_opacity;
1027double _sigma;
1028 ssize_t _x;
1029 ssize_t _y;
1030 };
1031
1032// Sharpen pixels in image
1033class MagickPPExport sharpenImage
1034 {
1035public:
1036sharpenImage( const double radius_ = 1, const double sigma_ = 0.5 );
1037
1038void operator()( Image &image_ ) const;
1039
1040private:
1041double _radius;
1042double _sigma;
1043 };
1044
1045// Shave pixels from image edges.
1046class MagickPPExport shaveImage
1047 {
1048public:
1049shaveImage( const Geometry &geometry_ );
1050
1051void operator()( Image &image_ ) const;
1052
1053private:
1054Geometry _geometry;
1055 };
1056
1057
1058// Shear image (create parallelogram by sliding image by X or Y axis)
1059class MagickPPExport shearImage
1060 {
1061public:
1062shearImage( const double xShearAngle_,
1063const double yShearAngle_ );
1064
1065void operator()( Image &image_ ) const;
1066
1067private:
1068double _xShearAngle;
1069double _yShearAngle;
1070 };
1071
1072// Solarize image (similar to effect seen when exposing a
1073// photographic film to light during the development process)
1074class MagickPPExport solarizeImage
1075 {
1076public:
1077solarizeImage( const double factor_ );
1078
1079void operator()( Image &image_ ) const;
1080
1081private:
1082double _factor;
1083 };
1084
1085// Splice the background color into the image.
1086class MagickPPExport spliceImage
1087 {
1088public:
1089spliceImage( const Geometry &geometry_ );
1090
1091void operator()( Image &image_ ) const;
1092
1093private:
1094Geometry _geometry;
1095 };
1096
1097// Spread pixels randomly within image by specified ammount
1098class MagickPPExport spreadImage
1099 {
1100public:
1101spreadImage( const size_t amount_ = 3 );
1102
1103void operator()( Image &image_ ) const;
1104
1105private:
1106size_t _amount;
1107 };
1108
1109// Add a digital watermark to the image (based on second image)
1110class MagickPPExport steganoImage
1111 {
1112public:
1113steganoImage( const Image &waterMark_ );
1114
1115void operator()( Image &image_ ) const;
1116
1117private:
1118Image _waterMark;
1119 };
1120
1121// Create an image which appears in stereo when viewed with red-blue glasses
1122// (Red image on left, blue on right)
1123class MagickPPExport stereoImage
1124 {
1125public:
1126stereoImage( const Image &rightImage_ );
1127
1128void operator()( Image &image_ ) const;
1129
1130private:
1131Image _rightImage;
1132 };
1133
1134// Color to use when drawing object outlines
1135class MagickPPExport strokeColorImage
1136 {
1137public:
1138strokeColorImage( const Color &strokeColor_ );
1139
1140void operator()( Image &image_ ) const;
1141
1142private:
1143Color _strokeColor;
1144 };
1145
1146// Swirl image (image pixels are rotated by degrees)
1147class MagickPPExport swirlImage
1148 {
1149public:
1150swirlImage( const double degrees_ );
1151
1152void operator()( Image &image_ ) const;
1153
1154private:
1155double _degrees;
1156 };
1157
1158// Channel a texture on image background
1159class MagickPPExport textureImage
1160 {
1161public:
1162textureImage( const Image &texture_ );
1163
1164void operator()( Image &image_ ) const;
1165
1166private:
1167Image _texture;
1168 };
1169
1170// Threshold image
1171class MagickPPExport thresholdImage
1172 {
1173public:
1174thresholdImage( const double threshold_ );
1175
1176void operator()( Image &image_ ) const;
1177
1178private:
1179double _threshold;
1180 };
1181
1182// Set image color to transparent
1183class MagickPPExport transparentImage
1184 {
1185public:
1186transparentImage( const Color& color_ );
1187
1188void operator()( Image &image_ ) const;
1189
1190private:
1191Color _color;
1192 };
1193
1194// Trim edges that are the background color from the image
1195class MagickPPExport trimImage
1196 {
1197public:
1198trimImage( void );
1199
1200void operator()( Image &image_ ) const;
1201
1202private:
1203 };
1204
1205// Map image pixels to a sine wave
1206class MagickPPExport waveImage
1207 {
1208public:
1209waveImage( const double amplitude_ = 25.0,
1210const double wavelength_ = 150.0 );
1211
1212void operator()( Image &image_ ) const;
1213
1214private:
1215double _amplitude;
1216double _wavelength;
1217 };
1218
1219// Zoom image to specified size.
1220class MagickPPExport zoomImage
1221 {
1222public:
1223zoomImage( const Geometry &geometry_ );
1224
1225void operator()( Image &image_ ) const;
1226
1227private:
1228Geometry _geometry;
1229 };
1230
1231//
1232// Function object image attribute accessors
1233//
1234
1235// Join images into a single multi-image file
1236class MagickPPExport adjoinImage
1237 {
1238public:
1239adjoinImage( const bool flag_ );
1240
1241void operator()( Image &image_ ) const;
1242
1243private:
1244bool _flag;
1245 };
1246
1247// Time in 1/100ths of a second which must expire before displaying
1248// the next image in an animated sequence.
1249class MagickPPExport animationDelayImage
1250 {
1251public:
1252animationDelayImage( const size_t delay_ );
1253
1254void operator()( Image &image_ ) const;
1255
1256private:
1257size_t _delay;
1258 };
1259
1260// Number of iterations to loop an animation (e.g. Netscape loop
1261// extension) for.
1262class MagickPPExport animationIterationsImage
1263 {
1264public:
1265animationIterationsImage( const size_t iterations_ );
1266
1267void operator()( Image &image_ ) const;
1268
1269private:
1270size_t _iterations;
1271 };
1272
1273// Image background color
1274class MagickPPExport backgroundColorImage
1275 {
1276public:
1277backgroundColorImage( const Color &color_ );
1278
1279void operator()( Image &image_ ) const;
1280
1281private:
1282Color _color;
1283 };
1284
1285// Name of texture image to tile onto the image background
1286class MagickPPExport backgroundTextureImage
1287 {
1288public:
1289backgroundTextureImage( const std::string &backgroundTexture_ );
1290
1291void operator()( Image &image_ ) const;
1292
1293private:
1294 std::string _backgroundTexture;
1295 };
1296
1297// Image border color
1298class MagickPPExport borderColorImage
1299 {
1300public:
1301borderColorImage( const Color &color_ );
1302
1303void operator()( Image &image_ ) const;
1304
1305private:
1306Color _color;
1307 };
1308
1309// Text bounding-box base color (default none)
1310class MagickPPExport boxColorImage
1311 {
1312public:
1313boxColorImage( const Color &boxColor_ );
1314
1315void operator()( Image &image_ ) const;
1316
1317private:
1318Color _boxColor;
1319 };
1320
1321// Chromaticity blue primary point.
1322class MagickPPExport chromaBluePrimaryImage
1323 {
1324public:
1325chromaBluePrimaryImage(const double x_,const double y_,const double z_);
1326
1327void operator()(Image &image_) const;
1328
1329private:
1330double _x;
1331double _y;
1332double _z;
1333 };
1334
1335// Chromaticity green primary point.
1336class MagickPPExport chromaGreenPrimaryImage
1337 {
1338public:
1339chromaGreenPrimaryImage(const double x_,const double y_,const double z_);
1340
1341void operator()(Image &image_) const;
1342
1343private:
1344double _x;
1345double _y;
1346double _z;
1347 };
1348
1349// Chromaticity red primary point.
1350class MagickPPExport chromaRedPrimaryImage
1351 {
1352public:
1353chromaRedPrimaryImage(const double x_,const double y_,const double z_);
1354
1355void operator()(Image &image_) const;
1356
1357private:
1358double _x;
1359double _y;
1360double _z;
1361 };
1362
1363// Chromaticity white point.
1364class MagickPPExport chromaWhitePointImage
1365 {
1366public:
1367chromaWhitePointImage(const double x_,const double y_,const double z_);
1368
1369void operator()(Image &image_) const;
1370
1371private:
1372double _x;
1373double _y;
1374double _z;
1375 };
1376
1377// Colors within this distance are considered equal
1378class MagickPPExport colorFuzzImage
1379 {
1380public:
1381colorFuzzImage( const double fuzz_ );
1382
1383void operator()( Image &image_ ) const;
1384
1385private:
1386double _fuzz;
1387 };
1388
1389// Color at colormap position index_
1390class MagickPPExport colorMapImage
1391 {
1392public:
1393colorMapImage( const size_t index_, const Color &color_ );
1394
1395void operator()( Image &image_ ) const;
1396
1397private:
1398size_t _index;
1399Color _color;
1400 };
1401
1402// Composition operator to be used when composition is implicitly used
1403// (such as for image flattening).
1404class MagickPPExport composeImage
1405 {
1406public:
1407composeImage( const CompositeOperator compose_ );
1408
1409void operator()( Image &image_ ) const;
1410
1411private:
1412 CompositeOperator _compose;
1413 };
1414
1415// Compression type
1416class MagickPPExport compressTypeImage
1417 {
1418public:
1419compressTypeImage( const CompressionType compressType_ );
1420
1421void operator()( Image &image_ ) const;
1422
1423private:
1424 CompressionType _compressType;
1425 };
1426
1427// Vertical and horizontal resolution in pixels of the image
1428class MagickPPExport densityImage
1429 {
1430public:
1431densityImage( const Point &point_ );
1432
1433void operator()( Image &image_ ) const;
1434
1435private:
1436Point _point;
1437 };
1438
1439// Image depth (bits allocated to red/green/blue components)
1440class MagickPPExport depthImage
1441 {
1442public:
1443depthImage( const size_t depth_ );
1444
1445void operator()( Image &image_ ) const;
1446
1447private:
1448size_t _depth;
1449 };
1450
1451// Endianness (LSBEndian like Intel or MSBEndian like SPARC) for image
1452// formats which support endian-specific options.
1453class MagickPPExport endianImage
1454 {
1455public:
1456endianImage( const EndianType endian_ );
1457
1458void operator()( Image &image_ ) const;
1459
1460private:
1461 EndianType _endian;
1462 };
1463
1464// Image file name
1465class MagickPPExport fileNameImage
1466 {
1467public:
1468fileNameImage( const std::string &fileName_ );
1469
1470void operator()( Image &image_ ) const;
1471
1472private:
1473 std::string _fileName;
1474 };
1475
1476// Filter to use when resizing image
1477class MagickPPExport filterTypeImage
1478 {
1479public:
1480filterTypeImage( const FilterType filterType_ );
1481
1482void operator()( Image &image_ ) const;
1483
1484private:
1485 FilterType _filterType;
1486 };
1487
1488// Text rendering font
1489class MagickPPExport fontImage
1490 {
1491public:
1492fontImage( const std::string &font_ );
1493
1494void operator()( Image &image_ ) const;
1495
1496private:
1497 std::string _font;
1498 };
1499
1500// Font point size
1501class MagickPPExport fontPointsizeImage
1502 {
1503public:
1504fontPointsizeImage( const size_t pointsize_ );
1505
1506void operator()( Image &image_ ) const;
1507
1508private:
1509size_t _pointsize;
1510 };
1511
1512// GIF disposal method
1513class MagickPPExport gifDisposeMethodImage
1514 {
1515public:
1516gifDisposeMethodImage( const DisposeType disposeMethod_ );
1517
1518void operator()( Image &image_ ) const;
1519
1520private:
1521 DisposeType _disposeMethod;
1522 };
1523
1524// Type of interlacing to use
1525class MagickPPExport interlaceTypeImage
1526 {
1527public:
1528interlaceTypeImage( const InterlaceType interlace_ );
1529
1530void operator()( Image &image_ ) const;
1531
1532private:
1533 InterlaceType _interlace;
1534 };
1535
1536// File type magick identifier (.e.g "GIF")
1537class MagickPPExport magickImage
1538 {
1539public:
1540magickImage( const std::string &magick_ );
1541
1542void operator()( Image &image_ ) const;
1543
1544private:
1545 std::string _magick;
1546 };
1547
1548// Image supports transparent color
1549class MagickPPExport alphaFlagImage
1550 {
1551public:
1552alphaFlagImage( const bool alphaFlag_ );
1553
1554void operator()( Image &image_ ) const;
1555
1556private:
1557bool _alphaFlag;
1558 };
1559
1560// Transparent color
1561class MagickPPExport matteColorImage
1562 {
1563public:
1564matteColorImage( const Color &matteColor_ );
1565
1566void operator()( Image &image_ ) const;
1567
1568private:
1569Color _matteColor;
1570 };
1571
1572// Indicate that image is black and white
1573class MagickPPExport monochromeImage
1574 {
1575public:
1576monochromeImage( const bool monochromeFlag_ );
1577
1578void operator()( Image &image_ ) const;
1579
1580private:
1581bool _monochromeFlag;
1582 };
1583
1584// Pen color
1585class MagickPPExport penColorImage
1586 {
1587public:
1588penColorImage( const Color &penColor_ );
1589
1590void operator()( Image &image_ ) const;
1591
1592private:
1593Color _penColor;
1594 };
1595
1596// Pen texture image.
1597class MagickPPExport penTextureImage
1598 {
1599public:
1600penTextureImage( const Image &penTexture_ );
1601
1602void operator()( Image &image_ ) const;
1603
1604private:
1605Image _penTexture;
1606 };
1607
1608// Set pixel color at location x & y.
1609class MagickPPExport pixelColorImage
1610 {
1611public:
1612pixelColorImage( const ::ssize_t x_,
1613 const ::ssize_t y_,
1614const Color &color_);
1615
1616void operator()( Image &image_ ) const;
1617
1618private:
1619 ::ssize_t _x;
1620 ::ssize_t _y;
1621Color _color;
1622 };
1623
1624// Postscript page size.
1625class MagickPPExport pageImage
1626 {
1627public:
1628pageImage( const Geometry &pageSize_ );
1629
1630void operator()( Image &image_ ) const;
1631
1632private:
1633Geometry _pageSize;
1634 };
1635
1636// JPEG/MIFF/PNG compression level (default 75).
1637class MagickPPExport qualityImage
1638 {
1639public:
1640qualityImage( const size_t quality_ );
1641
1642void operator()( Image &image_ ) const;
1643
1644private:
1645size_t _quality;
1646 };
1647
1648// Maximum number of colors to quantize to
1649class MagickPPExport quantizeColorsImage
1650 {
1651public:
1652quantizeColorsImage( const size_t colors_ );
1653
1654void operator()( Image &image_ ) const;
1655
1656private:
1657size_t _colors;
1658 };
1659
1660// Colorspace to quantize in.
1661class MagickPPExport quantizeColorSpaceImage
1662 {
1663public:
1664quantizeColorSpaceImage( const ColorspaceType colorSpace_ );
1665
1666void operator()( Image &image_ ) const;
1667
1668private:
1669 ColorspaceType _colorSpace;
1670 };
1671
1672// Dither image during quantization (default true).
1673class MagickPPExport quantizeDitherImage
1674 {
1675public:
1676quantizeDitherImage( const bool ditherFlag_ );
1677
1678void operator()( Image &image_ ) const;
1679
1680private:
1681bool _ditherFlag;
1682 };
1683
1684// Quantization tree-depth
1685class MagickPPExport quantizeTreeDepthImage
1686 {
1687public:
1688quantizeTreeDepthImage( const size_t treeDepth_ );
1689
1690void operator()( Image &image_ ) const;
1691
1692private:
1693size_t _treeDepth;
1694 };
1695
1696// The type of rendering intent
1697class MagickPPExport renderingIntentImage
1698 {
1699public:
1700renderingIntentImage( const RenderingIntent renderingIntent_ );
1701
1702void operator()( Image &image_ ) const;
1703
1704private:
1705 RenderingIntent _renderingIntent;
1706 };
1707
1708// Units of image resolution
1709class MagickPPExport resolutionUnitsImage
1710 {
1711public:
1712resolutionUnitsImage( const ResolutionType resolutionUnits_ );
1713
1714void operator()( Image &image_ ) const;
1715
1716private:
1717 ResolutionType _resolutionUnits;
1718 };
1719
1720// Image scene number
1721class MagickPPExport sceneImage
1722 {
1723public:
1724sceneImage( const size_t scene_ );
1725
1726void operator()( Image &image_ ) const;
1727
1728private:
1729size_t _scene;
1730 };
1731
1732// adjust the image contrast with a non-linear sigmoidal contrast algorithm
1733class MagickPPExport sigmoidalContrastImage
1734 {
1735public:
1736sigmoidalContrastImage( const size_t sharpen_,
1737const double contrast,
1738const double midpoint = QuantumRange / 2.0 );
1739
1740void operator()( Image &image_ ) const;
1741
1742private:
1743size_t _sharpen;
1744double contrast;
1745double midpoint;
1746 };
1747
1748// Width and height of a raw image
1749class MagickPPExport sizeImage
1750 {
1751public:
1752sizeImage( const Geometry &geometry_ );
1753
1754void operator()( Image &image_ ) const;
1755
1756private:
1757Geometry _geometry;
1758 };
1759
1760// stripImage strips an image of all profiles and comments.
1761class MagickPPExport stripImage
1762 {
1763public:
1764stripImage( void );
1765
1766void operator()( Image &image_ ) const;
1767
1768private:
1769 };
1770
1771// Subimage of an image sequence
1772class MagickPPExport subImageImage
1773 {
1774public:
1775subImageImage( const size_t subImage_ );
1776
1777void operator()( Image &image_ ) const;
1778
1779private:
1780size_t _subImage;
1781 };
1782
1783// Number of images relative to the base image
1784class MagickPPExport subRangeImage
1785 {
1786public:
1787subRangeImage( const size_t subRange_ );
1788
1789void operator()( Image &image_ ) const;
1790
1791private:
1792size_t _subRange;
1793 };
1794
1795// Anti-alias Postscript and TrueType fonts (default true)
1796class MagickPPExport textAntiAliasImage
1797 {
1798public:
1799textAntiAliasImage( const bool flag_ );
1800
1801void operator()( Image &image_ ) const;
1802
1803private:
1804bool _flag;
1805 };
1806
1807// Image storage type
1808class MagickPPExport typeImage
1809 {
1810public:
1811typeImage( const ImageType type_ );
1812
1813void operator()( Image &image_ ) const;
1814
1815private:
1816 Magick::ImageType _type;
1817 };
1818
1819
1820// Print detailed information about the image
1821class MagickPPExport verboseImage
1822 {
1823public:
1824verboseImage( const bool verbose_ );
1825
1826void operator()( Image &image_ ) const;
1827
1828private:
1829bool _verbose;
1830 };
1831
1832// X11 display to display to, obtain fonts from, or to capture
1833// image from
1834class MagickPPExport x11DisplayImage
1835 {
1836public:
1837x11DisplayImage( const std::string &display_ );
1838
1839void operator()( Image &image_ ) const;
1840
1841private:
1842 std::string _display;
1843 };
1844
1846//
1847// Implementation template definitions. Not for end-use.
1848//
1850
1851// Changes the channel mask of the images and places the old
1852// values in the container.
1853template<class InputIterator, class Container>
1854void channelMaskImages(InputIterator first_,InputIterator last_,
1855 Container *container_,const ChannelType channel_)
1856 {
1857 MagickCore::ChannelType
1858 channel_mask;
1859
1860 container_->clear();
1861for (InputIterator iter = first_; iter != last_; ++iter)
1862 {
1863 iter->modifyImage();
1864 channel_mask=MagickCore::SetImageChannelMask(iter->image(),channel_);
1865 container_->push_back(channel_mask);
1866 }
1867 }
1868
1869// Insert images in image list into existing container (appending to container)
1870// The images should not be deleted since only the image ownership is passed.
1871// The options are copied into the object.
1872template<class Container>
1873void insertImages(Container *sequence_,MagickCore::Image* images_)
1874 {
1876 *image,
1877 *next;
1878
1879 image=images_;
1880while (image != (MagickCore::Image *) NULL)
1881 {
1882 next=image->next;
1883 image->next=(MagickCore::Image *) NULL;
1884
1885if (next != (MagickCore::Image *) NULL)
1886 next->previous=(MagickCore::Image *) NULL;
1887
1888 sequence_->push_back(Magick::Image(image));
1889
1890 image=next;
1891 }
1892 }
1893
1894// Link images together into an image list based on the ordering of
1895// the container implied by the iterator. This step is done in
1896// preparation for use with ImageMagick functions which operate on
1897// lists of images.
1898// Images are selected by range, first_ to last_ so that a subset of
1899// the container may be selected. Specify first_ via the
1900// container's begin() method and last_ via the container's end()
1901// method in order to specify the entire container.
1902template<class InputIterator>
1903bool linkImages(InputIterator first_,InputIterator last_)
1904 {
1906 *current,
1907 *previous;
1908
1909 ::ssize_t
1910 scene;
1911
1912 scene=0;
1913 previous=(MagickCore::Image *) NULL;
1914for (InputIterator iter = first_; iter != last_; ++iter)
1915 {
1916// Unless we reduce the reference count to one, the same image
1917// structure may occur more than once in the container, causing
1918// the linked list to fail.
1919 iter->modifyImage();
1920
1921 current=iter->image();
1922
1923 current->previous=previous;
1924 current->next=(MagickCore::Image *) NULL;
1925 current->scene=scene++;
1926
1927if (previous != (MagickCore::Image *) NULL)
1928 previous->next=current;
1929
1930 previous=current;
1931 }
1932return(scene > 0 ? true : false);
1933 }
1934
1935// Restores the channel mask of the images.
1936template<class InputIterator, class Container>
1937void restoreChannelMaskImages(InputIterator first_,InputIterator last_,
1938 Container *container_)
1939 {
1940typename Container::iterator
1941 channel_mask;
1942
1943 channel_mask=container_->begin();
1944for (InputIterator iter = first_; iter != last_; ++iter)
1945 {
1946 iter->modifyImage();
1947 (void) MagickCore::SetImageChannelMask(iter->image(),
1948 (const MagickCore::ChannelType) *channel_mask);
1949 channel_mask++;
1950 }
1951 }
1952
1953// Remove links added by linkImages. This should be called after the
1954// ImageMagick function call has completed to reset the image list
1955// back to its pristine un-linked state.
1956template<class InputIterator>
1957void unlinkImages(InputIterator first_,InputIterator last_)
1958 {
1960 *image;
1961
1962for (InputIterator iter = first_; iter != last_; ++iter)
1963 {
1964 image=iter->image();
1965 image->previous=(MagickCore::Image *) NULL;
1966 image->next=(MagickCore::Image *) NULL;
1967 }
1968 }
1969
1971//
1972// Template definitions for documented API
1973//
1975
1976template <class InputIterator>
1977void animateImages( InputIterator first_,InputIterator last_)
1978 {
1979if (linkImages(first_,last_) == false)
1980return;
1981GetPPException;
1982 MagickCore::AnimateImages(first_->imageInfo(),first_->image(),
1983 exceptionInfo);
1984unlinkImages(first_,last_);
1985ThrowPPException(first_->quiet());
1986 }
1987
1988// Append images from list into single image in either horizontal or
1989// vertical direction.
1990template <class InputIterator>
1991void appendImages( Image *appendedImage_,
1992 InputIterator first_,
1993 InputIterator last_,
1994bool stack_ = false) {
1995if (linkImages(first_,last_) == false)
1996return;
1997GetPPException;
1998MagickCore::Image* image = MagickCore::AppendImages( first_->image(),
1999 (MagickBooleanType) stack_,
2000 exceptionInfo );
2001unlinkImages( first_, last_ );
2002 appendedImage_->replaceImage( image );
2003ThrowPPException(appendedImage_->quiet());
2004 }
2005
2006// Adds the names of the artifacts of the image to the container.
2007template <class Container>
2008void artifactNames(Container *names_,const Image* image_)
2009 {
2010const char*
2011 name;
2012
2013 names_->clear();
2014
2015 MagickCore::ResetImageArtifactIterator(image_->constImage());
2016 name=MagickCore::GetNextImageArtifact(image_->constImage());
2017while (name != (const char *) NULL)
2018 {
2019 names_->push_back(std::string(name));
2020 name=MagickCore::GetNextImageArtifact(image_->constImage());
2021 }
2022 }
2023
2024// Adds the names of the attributes of the image to the container.
2025template <class Container>
2026void attributeNames(Container *names_,const Image* image_)
2027 {
2028const char*
2029 name;
2030
2031 names_->clear();
2032
2033 MagickCore::ResetImagePropertyIterator(image_->constImage());
2034 name=MagickCore::GetNextImageProperty(image_->constImage());
2035while (name != (const char *) NULL)
2036 {
2037 names_->push_back(std::string(name));
2038 name=MagickCore::GetNextImageProperty(image_->constImage());
2039 }
2040 }
2041
2042// Average a set of images.
2043// All the input images must be the same size in pixels.
2044template <class InputIterator>
2045void averageImages( Image *averagedImage_,
2046 InputIterator first_,
2047 InputIterator last_ ) {
2048if (linkImages(first_,last_) == false)
2049return;
2050GetPPException;
2051MagickCore::Image* image = MagickCore::EvaluateImages( first_->image(),
2052 MagickCore::MeanEvaluateOperator, exceptionInfo );
2053unlinkImages( first_, last_ );
2054 averagedImage_->replaceImage( image );
2055ThrowPPException(averagedImage_->quiet());
2056 }
2057
2058// Merge a sequence of images.
2059// This is useful for GIF animation sequences that have page
2060// offsets and disposal methods. A container to contain
2061// the updated image sequence is passed via the coalescedImages_
2062// option.
2063template <class InputIterator, class Container >
2064void coalesceImages(Container *coalescedImages_,InputIterator first_,
2065 InputIterator last_)
2066 {
2067bool
2068 quiet;
2069
2071 *images;
2072
2073if (linkImages(first_,last_) == false)
2074return;
2075
2076GetPPException;
2077 quiet=first_->quiet();
2078 images=MagickCore::CoalesceImages(first_->image(),exceptionInfo);
2079
2080// Unlink image list
2081unlinkImages(first_,last_);
2082
2083// Ensure container is empty
2084 coalescedImages_->clear();
2085
2086// Move images to container
2087insertImages(coalescedImages_,images);
2088
2089// Report any error
2090ThrowPPException(quiet);
2091 }
2092
2093// Return format coders matching specified conditions.
2094//
2095// The default (if no match terms are supplied) is to return all
2096// available format coders.
2097//
2098// For example, to return all readable formats:
2099// list<CoderInfo> coderList;
2100// coderInfoList( &coderList, CoderInfo::TrueMatch, CoderInfo::AnyMatch, CoderInfo::AnyMatch)
2101//
2102template <class Container >
2103void coderInfoList( Container *container_,
2104CoderInfo::MatchType isReadable_ = CoderInfo::AnyMatch,
2105CoderInfo::MatchType isWritable_ = CoderInfo::AnyMatch,
2106CoderInfo::MatchType isMultiFrame_ = CoderInfo::AnyMatch
2107 ) {
2108// Obtain first entry in MagickInfo list
2109size_t number_formats;
2110GetPPException;
2111char **coder_list =
2112 MagickCore::GetMagickList( "*", &number_formats, exceptionInfo );
2113if( !coder_list )
2114 {
2115throwException(exceptionInfo);
2116throwExceptionExplicit(MagickCore::MissingDelegateError,
2117"Coder array not returned!", 0 );
2118 }
2119
2120// Clear out container
2121 container_->clear();
2122
2123for ( ::ssize_t i=0; i < (::ssize_t) number_formats; i++)
2124 {
2125const MagickCore::MagickInfo *magick_info =
2126 MagickCore::GetMagickInfo( coder_list[i], exceptionInfo );
2127if (!magick_info)
2128continue;
2129
2130 coder_list[i]=(char *)
2131 MagickCore::RelinquishMagickMemory( coder_list[i] );
2132
2133// Skip stealth coders
2134if ( MagickCore::GetMagickStealth(magick_info) )
2135continue;
2136
2137try {
2138CoderInfo coderInfo( magick_info->name );
2139
2140// Test isReadable_
2141if ( isReadable_ != CoderInfo::AnyMatch &&
2142 (( coderInfo.isReadable() && isReadable_ != CoderInfo::TrueMatch ) ||
2143 ( !coderInfo.isReadable() && isReadable_ != CoderInfo::FalseMatch )) )
2144continue;
2145
2146// Test isWritable_
2147if ( isWritable_ != CoderInfo::AnyMatch &&
2148 (( coderInfo.isWritable() && isWritable_ != CoderInfo::TrueMatch ) ||
2149 ( !coderInfo.isWritable() && isWritable_ != CoderInfo::FalseMatch )) )
2150continue;
2151
2152// Test isMultiFrame_
2153if ( isMultiFrame_ != CoderInfo::AnyMatch &&
2154 (( coderInfo.isMultiFrame() && isMultiFrame_ != CoderInfo::TrueMatch ) ||
2155 ( !coderInfo.isMultiFrame() && isMultiFrame_ != CoderInfo::FalseMatch )) )
2156continue;
2157
2158// Append matches to container
2159 container_->push_back( coderInfo );
2160 }
2161// Intentionally ignore missing module errors
2162catch (Magick::ErrorModule&)
2163 {
2164continue;
2165 }
2166 }
2167 coder_list=(char **) MagickCore::RelinquishMagickMemory( coder_list );
2168ThrowPPException(false);
2169 }
2170
2171//
2172// Fill container with color histogram.
2173// Entries are of type "std::pair<Color,size_t>". Use the pair
2174// "first" member to access the Color and the "second" member to access
2175// the number of times the color occurs in the image.
2176//
2177// For example:
2178//
2179// Using <map>:
2180//
2181// Image image("image.miff");
2182// map<Color,size_t> histogram;
2183// colorHistogram( &histogram, image );
2184// std::map<Color,size_t>::const_iterator p=histogram.begin();
2185// while (p != histogram.end())
2186// {
2187// cout << setw(10) << (int)p->second << ": ("
2188// << setw(quantum_width) << (int)p->first.redQuantum() << ","
2189// << setw(quantum_width) << (int)p->first.greenQuantum() << ","
2190// << setw(quantum_width) << (int)p->first.blueQuantum() << ")"
2191// << endl;
2192// p++;
2193// }
2194//
2195// Using <vector>:
2196//
2197// Image image("image.miff");
2198// std::vector<std::pair<Color,size_t> > histogram;
2199// colorHistogram( &histogram, image );
2200// std::vector<std::pair<Color,size_t> >::const_iterator p=histogram.begin();
2201// while (p != histogram.end())
2202// {
2203// cout << setw(10) << (int)p->second << ": ("
2204// << setw(quantum_width) << (int)p->first.redQuantum() << ","
2205// << setw(quantum_width) << (int)p->first.greenQuantum() << ","
2206// << setw(quantum_width) << (int)p->first.blueQuantum() << ")"
2207// << endl;
2208// p++;
2209// }
2210
2211template <class Container >
2212void colorHistogram( Container *histogram_, const Image image)
2213 {
2214GetPPException;
2215
2216// Obtain histogram array
2217size_t colors;
2218 MagickCore::PixelInfo *histogram_array =
2219 MagickCore::GetImageHistogram( image.constImage(), &colors, exceptionInfo );
2220ThrowPPException(image.quiet());
2221
2222// Clear out container
2223 histogram_->clear();
2224
2225// Transfer histogram array to container
2226for ( size_t i=0; i < colors; i++)
2227 {
2228 histogram_->insert( histogram_->end(), std::pair<const Color,size_t>
2229 ( Color(histogram_array[i]), (size_t) histogram_array[i].count) );
2230 }
2231
2232// Deallocate histogram array
2233 histogram_array=(MagickCore::PixelInfo *)
2234 MagickCore::RelinquishMagickMemory(histogram_array);
2235 }
2236
2237// Combines one or more images into a single image. The grayscale value of
2238// the pixels of each image in the sequence is assigned in order to the
2239// specified channels of the combined image. The typical ordering would be
2240// image 1 => Red, 2 => Green, 3 => Blue, etc.
2241template<class InputIterator >
2242void combineImages(Image *combinedImage_,InputIterator first_,
2243 InputIterator last_,const ChannelType channel_,
2244const ColorspaceType colorspace_ = MagickCore::sRGBColorspace)
2245 {
2247 *image;
2248
2249 std::vector<ChannelType>
2250 channelMask;
2251
2252if (linkImages(first_,last_) == false)
2253return;
2254GetPPException;
2255channelMaskImages(first_,last_,&channelMask,channel_);
2256 image=CombineImages(first_->image(),colorspace_,exceptionInfo);
2257restoreChannelMaskImages(first_,last_,&channelMask);
2258unlinkImages(first_,last_);
2259 combinedImage_->replaceImage(image);
2260ThrowPPException(combinedImage_->quiet());
2261 }
2262
2263template <class Container>
2264void cropToTiles(Container *tiledImages_,const Image image_,
2265const Geometry &geometry_)
2266 {
2267GetPPException;
2268MagickCore::Image* images=CropImageToTiles(image_.constImage(),
2269static_cast<std::string>(geometry_).c_str(),exceptionInfo);
2270 tiledImages_->clear();
2271insertImages(tiledImages_,images);
2272ThrowPPException(image_.quiet());
2273 }
2274
2275// Break down an image sequence into constituent parts. This is
2276// useful for creating GIF or MNG animation sequences.
2277template<class InputIterator,class Container>
2278void deconstructImages(Container *deconstructedImages_,
2279 InputIterator first_,InputIterator last_)
2280 {
2281bool
2282 quiet;
2283
2285 *images;
2286
2287if (linkImages(first_,last_) == false)
2288return;
2289GetPPException;
2290 quiet=first_->quiet();
2291 images=CompareImagesLayers(first_->image(),CompareAnyLayer,exceptionInfo);
2292unlinkImages(first_,last_);
2293
2294 deconstructedImages_->clear();
2295insertImages(deconstructedImages_,images);
2296
2297ThrowPPException(quiet);
2298 }
2299
2300//
2301// Display an image sequence
2302//
2303template <class InputIterator>
2304void displayImages(InputIterator first_,InputIterator last_)
2305 {
2306if (linkImages(first_,last_) == false)
2307return;
2308GetPPException;
2309 MagickCore::DisplayImages(first_->imageInfo(),first_->image(),
2310 exceptionInfo);
2311unlinkImages(first_,last_);
2312ThrowPPException(first_->quiet());
2313 }
2314
2315// Applies a value to the image with an arithmetic, relational,
2316// or logical operator to an image. Use these operations to lighten or darken
2317// an image, to increase or decrease contrast in an image, or to produce the
2318// "negative" of an image.
2319template <class InputIterator >
2320void evaluateImages( Image *evaluatedImage_,
2321 InputIterator first_,
2322 InputIterator last_,
2323const MagickEvaluateOperator operator_ ) {
2324if (linkImages(first_,last_) == false)
2325return;
2326GetPPException;
2327MagickCore::Image* image = EvaluateImages( first_->image(), operator_, exceptionInfo );
2328unlinkImages( first_, last_ );
2329 evaluatedImage_->replaceImage( image );
2330ThrowPPException(evaluatedImage_->quiet());
2331 }
2332
2333// Merge a sequence of image frames which represent image layers.
2334// This is useful for combining Photoshop layers into a single image.
2335template <class InputIterator>
2336void flattenImages( Image *flattendImage_,
2337 InputIterator first_,
2338 InputIterator last_ ) {
2339if (linkImages(first_,last_) == false)
2340return;
2341GetPPException;
2342MagickCore::Image* image = MagickCore::MergeImageLayers( first_->image(),
2343 FlattenLayer,exceptionInfo );
2344unlinkImages( first_, last_ );
2345 flattendImage_->replaceImage( image );
2346ThrowPPException(flattendImage_->quiet());
2347 }
2348
2349// Implements the discrete Fourier transform (DFT) of the image either as a
2350// magnitude / phase or real / imaginary image pair.
2351template <class Container >
2352void forwardFourierTransformImage( Container *fourierImages_,
2353const Image &image_ ) {
2354GetPPException;
2355
2356// Build image list
2357MagickCore::Image* images = ForwardFourierTransformImage(
2358 image_.constImage(), MagickTrue, exceptionInfo);
2359
2360// Ensure container is empty
2361 fourierImages_->clear();
2362
2363// Move images to container
2364insertImages( fourierImages_, images );
2365
2366// Report any error
2367ThrowPPException(image_.quiet());
2368 }
2369template <class Container >
2370void forwardFourierTransformImage( Container *fourierImages_,
2371const Image &image_, const bool magnitude_ ) {
2372GetPPException;
2373
2374// Build image list
2375MagickCore::Image* images = ForwardFourierTransformImage(
2376 image_.constImage(), magnitude_ == true ? MagickTrue : MagickFalse,
2377 exceptionInfo);
2378
2379// Ensure container is empty
2380 fourierImages_->clear();
2381
2382// Move images to container
2383insertImages( fourierImages_, images );
2384
2385// Report any error
2386ThrowPPException(image_.quiet());
2387 }
2388
2389// Applies a mathematical expression to a sequence of images.
2390template <class InputIterator>
2391void fxImages(Image *fxImage_,InputIterator first_,InputIterator last_,
2392const std::string expression)
2393 {
2395 *image;
2396
2397if (linkImages(first_,last_) == false)
2398return;
2399GetPPException;
2400 image=FxImage(first_->constImage(),expression.c_str(),exceptionInfo);
2401unlinkImages(first_,last_);
2402 fxImage_->replaceImage(image);
2403ThrowPPException(fxImage_->quiet());
2404 }
2405
2406// Replace the colors of a sequence of images with the closest color
2407// from a reference image.
2408// Set dither_ to true to enable dithering. Set measureError_ to
2409// true in order to evaluate quantization error.
2410template<class InputIterator>
2411void mapImages(InputIterator first_,InputIterator last_,
2412const Image& mapImage_,bool dither_=false,bool measureError_=false)
2413 {
2415 *image;
2416
2417 MagickCore::QuantizeInfo
2418 quantizeInfo;
2419
2420if (linkImages(first_,last_) == false)
2421return;
2422GetPPException;
2423 MagickCore::GetQuantizeInfo(&quantizeInfo);
2424 quantizeInfo.dither_method = dither_ ? MagickCore::RiemersmaDitherMethod :
2425 MagickCore::NoDitherMethod;
2426 MagickCore::RemapImages(&quantizeInfo,first_->image(),
2427 (mapImage_.isValid() ? mapImage_.constImage() :
2428 (const MagickCore::Image*) NULL),exceptionInfo);
2429unlinkImages(first_,last_);
2430if (exceptionInfo->severity != MagickCore::UndefinedException)
2431 {
2432unlinkImages(first_,last_);
2433throwException(exceptionInfo,mapImage_.quiet());
2434 }
2435
2436 image=first_->image();
2437while(image != (MagickCore::Image *) NULL)
2438 {
2439// Calculate quantization error
2440if (measureError_)
2441 {
2442 MagickCore::GetImageQuantizeError(image,exceptionInfo);
2443if (exceptionInfo->severity > MagickCore::UndefinedException)
2444 {
2445unlinkImages(first_,last_);
2446throwException(exceptionInfo,mapImage_.quiet());
2447 }
2448 }
2449
2450// Update DirectClass representation of pixels
2451 MagickCore::SyncImage(image,exceptionInfo);
2452if (exceptionInfo->severity > MagickCore::UndefinedException)
2453 {
2454unlinkImages(first_,last_);
2455throwException(exceptionInfo,mapImage_.quiet());
2456 }
2457
2458// Next image
2459 image=image->next;
2460 }
2461
2462unlinkImages(first_,last_);
2463 (void) MagickCore::DestroyExceptionInfo(exceptionInfo);
2464 }
2465
2466// Composes all the image layers from the current given
2467// image onward to produce a single image of the merged layers.
2468template <class InputIterator >
2469void mergeImageLayers( Image *mergedImage_,
2470 InputIterator first_,
2471 InputIterator last_,
2472const LayerMethod method_ ) {
2473if (linkImages(first_,last_) == false)
2474return;
2475GetPPException;
2476MagickCore::Image* image = MergeImageLayers( first_->image(), method_, exceptionInfo );
2477unlinkImages( first_, last_ );
2478 mergedImage_->replaceImage( image );
2479ThrowPPException(mergedImage_->quiet());
2480 }
2481
2482// Create a composite image by combining several separate images.
2483template <class Container, class InputIterator>
2484void montageImages(Container *montageImages_,InputIterator first_,
2485 InputIterator last_,const Montage &options_)
2486 {
2487bool
2488 quiet;
2489
2491 *images;
2492
2493 MagickCore::MontageInfo
2494 *montageInfo;
2495
2496if (linkImages(first_,last_) == false)
2497return;
2498
2499 montageInfo=static_cast<MagickCore::MontageInfo*>(
2500 MagickCore::AcquireMagickMemory(sizeof(MagickCore::MontageInfo)));
2501
2502// Update montage options with those set in montageOpts_
2503 options_.updateMontageInfo(*montageInfo);
2504
2505// Update options which must transfer to image options
2506if (options_.label().length() != 0)
2507 first_->label(options_.label());
2508
2509// Do montage
2510GetPPException;
2511 quiet=first_->quiet();
2512 images=MagickCore::MontageImages(first_->image(),montageInfo,
2513 exceptionInfo);
2514
2515// Unlink linked image list
2516unlinkImages(first_,last_);
2517
2518// Reset output container to pristine state
2519 montageImages_->clear();
2520
2521if (images != (MagickCore::Image *) NULL)
2522insertImages(montageImages_,images);
2523
2524// Clean up any allocated data in montageInfo
2525 MagickCore::DestroyMontageInfo(montageInfo);
2526
2527// Report any montage error
2528ThrowPPException(quiet);
2529
2530// Apply transparency to montage images
2531if (montageImages_->size() > 0 && options_.transparentColor().isValid())
2532 for_each(montageImages_->begin(),montageImages_->end(),transparentImage(
2533 options_.transparentColor()));
2534 }
2535
2536// Morph a set of images
2537template <class InputIterator, class Container >
2538void morphImages(Container *morphedImages_,InputIterator first_,
2539 InputIterator last_,size_t frames_)
2540 {
2541bool
2542 quiet;
2543
2545 *images;
2546
2547if (linkImages(first_,last_) == false)
2548return;
2549
2550GetPPException;
2551 quiet=first_->quiet();
2552 images=MagickCore::MorphImages(first_->image(),frames_,exceptionInfo);
2553
2554// Unlink image list
2555unlinkImages(first_,last_);
2556
2557// Ensure container is empty
2558 morphedImages_->clear();
2559
2560// Move images to container
2561insertImages(morphedImages_,images);
2562
2563// Report any error
2564ThrowPPException(quiet);
2565 }
2566
2567// Inlay a number of images to form a single coherent picture.
2568template <class InputIterator>
2569void mosaicImages( Image *mosaicImage_,
2570 InputIterator first_,
2571 InputIterator last_ ) {
2572if (linkImages(first_,last_) == false)
2573return;
2574GetPPException;
2575MagickCore::Image* image = MagickCore::MergeImageLayers( first_->image(),
2576 MosaicLayer,exceptionInfo );
2577unlinkImages( first_, last_ );
2578 mosaicImage_->replaceImage( image );
2579ThrowPPException(mosaicImage_->quiet());
2580 }
2581
2582// Compares each image the GIF disposed forms of the previous image in
2583// the sequence. From this it attempts to select the smallest cropped
2584// image to replace each frame, while preserving the results of the
2585// GIF animation.
2586template <class InputIterator, class Container >
2587void optimizeImageLayers(Container *optimizedImages_,InputIterator first_,
2588 InputIterator last_)
2589 {
2590bool
2591 quiet;
2592
2594 *images;
2595
2596if (linkImages(first_,last_) == false)
2597return;
2598
2599GetPPException;
2600 quiet=first_->quiet();
2601 images=OptimizeImageLayers(first_->image(),exceptionInfo);
2602
2603unlinkImages(first_,last_);
2604
2605 optimizedImages_->clear();
2606
2607insertImages(optimizedImages_,images);
2608
2609ThrowPPException(quiet);
2610 }
2611
2612// optimizeImagePlusLayers is exactly as optimizeImageLayers, but may
2613// also add or even remove extra frames in the animation, if it improves
2614// the total number of pixels in the resulting GIF animation.
2615template <class InputIterator, class Container >
2616void optimizePlusImageLayers(Container *optimizedImages_,
2617 InputIterator first_,InputIterator last_ )
2618 {
2619bool
2620 quiet;
2621
2623 *images;
2624
2625if (linkImages(first_,last_) == false)
2626return;
2627
2628GetPPException;
2629 quiet=first_->quiet();
2630 images=OptimizePlusImageLayers(first_->image(),exceptionInfo);
2631
2632unlinkImages(first_,last_);
2633
2634 optimizedImages_->clear();
2635
2636insertImages(optimizedImages_,images);
2637
2638ThrowPPException(quiet);
2639 }
2640
2641// Compares each image the GIF disposed forms of the previous image in the
2642// sequence. Any pixel that does not change the displayed result is replaced
2643// with transparency.
2644template<class InputIterator>
2645void optimizeTransparency(InputIterator first_,InputIterator last_)
2646 {
2647if (linkImages(first_,last_) == false)
2648return;
2649GetPPException;
2650 OptimizeImageTransparency(first_->image(),exceptionInfo);
2651unlinkImages(first_,last_ );
2652
2653ThrowPPException(first_->quiet());
2654 }
2655
2656// Ping images into existing container (appending to container)
2657template<class Container>
2658void pingImages(Container *sequence_,const std::string &imageSpec_,
2659ReadOptions &options)
2660 {
2661 options.ping(true);
2662readImages(sequence_,imageSpec_,options);
2663 }
2664
2665template<class Container>
2666void pingImages(Container *sequence_,const std::string &imageSpec_)
2667 {
2668ReadOptions options;
2669pingImages(sequence_,imageSpec_,options);
2670 }
2671
2672template<class Container>
2673void pingImages(Container *sequence_,const Blob &blob_,ReadOptions &options)
2674 {
2675 options.ping(true);
2676readImages(sequence_,blob_,options);
2677 }
2678
2679template<class Container>
2680void pingImages(Container *sequence_,const Blob &blob_)
2681 {
2682ReadOptions options;
2683pingImages(sequence_,blob_,options);
2684 }
2685
2686// Adds the names of the profiles of the image to the container.
2687template <class Container>
2688void profileNames(Container *names_,const Image* image_)
2689 {
2690const char*
2691 name;
2692
2693 names_->clear();
2694
2695 MagickCore::ResetImageProfileIterator(image_->constImage());
2696 name=MagickCore::GetNextImageProfile(image_->constImage());
2697while (name != (const char *) NULL)
2698 {
2699 names_->push_back(std::string(name));
2700 name=MagickCore::GetNextImageProfile(image_->constImage());
2701 }
2702 }
2703
2704// Quantize colors in images using current quantization settings
2705// Set measureError_ to true in order to measure quantization error
2706template <class InputIterator>
2707void quantizeImages(InputIterator first_,InputIterator last_,
2708bool measureError_ = false)
2709 {
2710if (linkImages(first_,last_) == false)
2711return;
2712GetPPException;
2713 MagickCore::QuantizeImages(first_->quantizeInfo(),first_->image(),
2714 exceptionInfo);
2715unlinkImages(first_,last_);
2716
2717MagickCore::Image *image=first_->image();
2718while (image != (MagickCore::Image *) NULL)
2719 {
2720// Calculate quantization error
2721if (measureError_)
2722 MagickCore::GetImageQuantizeError(image,exceptionInfo);
2723
2724// Update DirectClass representation of pixels
2725 MagickCore::SyncImage(image,exceptionInfo);
2726
2727 image=image->next;
2728 }
2729unlinkImages(first_,last_);
2730ThrowPPException(first_->quiet());
2731 }
2732
2733// Read images into existing container (appending to container)
2734template<class Container>
2735void readImages(Container *sequence_,const std::string &imageSpec_,
2736ReadOptions &options)
2737 {
2739 *images;
2740
2741 MagickCore::ImageInfo
2742 *imageInfo;
2743
2744 imageInfo=options.imageInfo();
2745 imageSpec_.copy(imageInfo->filename,MagickPathExtent-1);
2746 imageInfo->filename[imageSpec_.length()] = 0;
2747GetPPException;
2748 images=MagickCore::ReadImage(imageInfo,exceptionInfo);
2749insertImages(sequence_,images);
2750ThrowPPException(options.quiet());
2751 }
2752
2753template<class Container>
2754void readImages(Container *sequence_,const std::string &imageSpec_)
2755 {
2756ReadOptions options;
2757readImages(sequence_,imageSpec_,options);
2758 }
2759
2760template<class Container>
2761void readImages(Container *sequence_,const Blob &blob_,ReadOptions &options)
2762 {
2764 *images;
2765
2766GetPPException;
2767 images=MagickCore::BlobToImage(options.imageInfo(),blob_.data(),
2768 blob_.length(),exceptionInfo);
2769insertImages(sequence_,images);
2770ThrowPPException(options.quiet());
2771 }
2772
2773template<class Container>
2774void readImages(Container *sequence_,const Blob &blob_)
2775 {
2776ReadOptions options;
2777readImages(sequence_,blob_,options);
2778 }
2779
2780// Returns a separate grayscale image for each channel specified.
2781template<class Container>
2782void separateImages(Container *separatedImages_,Image &image_,
2783const ChannelType channel_)
2784 {
2785 MagickCore::ChannelType
2786 channel_mask;
2787
2789 *images;
2790
2791GetPPException;
2792 channel_mask=MagickCore::SetImageChannelMask(image_.image(),channel_);
2793 images=SeparateImages(image_.constImage(),exceptionInfo);
2794 MagickCore::SetPixelChannelMask(image_.image(),channel_mask);
2795
2796 separatedImages_->clear();
2797insertImages(separatedImages_,images);
2798
2799ThrowPPException(image_.quiet());
2800 }
2801
2802// Smush images from list into single image in either horizontal or
2803// vertical direction.
2804template<class InputIterator>
2805void smushImages(Image *smushedImage_,InputIterator first_,
2806 InputIterator last_,const ssize_t offset_,bool stack_=false)
2807 {
2809 *newImage;
2810
2811if (linkImages(first_,last_) == false)
2812return;
2813GetPPException;
2814 newImage=MagickCore::SmushImages(first_->constImage(),
2815 (MagickBooleanType) stack_,offset_,exceptionInfo);
2816unlinkImages(first_,last_);
2817 smushedImage_->replaceImage(newImage);
2818ThrowPPException(smushedImage_->quiet());
2819 }
2820
2821// Write Images
2822template <class InputIterator>
2823void writeImages( InputIterator first_,
2824 InputIterator last_,
2825const std::string &imageSpec_,
2826bool adjoin_ = true ) {
2827
2828if (linkImages(first_,last_) == false)
2829return;
2830
2831 first_->adjoin( adjoin_ );
2832
2833GetPPException;
2834 ::ssize_t errorStat = MagickCore::WriteImages( first_->constImageInfo(),
2835 first_->image(),
2836 imageSpec_.c_str(),
2837 exceptionInfo );
2838unlinkImages( first_, last_ );
2839
2840if ( errorStat != false )
2841 {
2842 (void) MagickCore::DestroyExceptionInfo( exceptionInfo );
2843return;
2844 }
2845
2846ThrowPPException(first_->quiet());
2847 }
2848// Write images to BLOB
2849template <class InputIterator>
2850void writeImages( InputIterator first_,
2851 InputIterator last_,
2852Blob *blob_,
2853bool adjoin_ = true) {
2854if (linkImages(first_,last_) == false)
2855return;
2856
2857 first_->adjoin( adjoin_ );
2858
2859GetPPException;
2860size_t length = 2048; // Efficient size for small images
2861void* data = MagickCore::ImagesToBlob( first_->imageInfo(),
2862 first_->image(),
2863 &length,
2864 exceptionInfo);
2865 blob_->updateNoCopy( data, length, Magick::Blob::MallocAllocator );
2866
2867unlinkImages( first_, last_ );
2868
2869ThrowPPException(first_->quiet());
2870 }
2871
2872 } // namespace Magick
2873
2874 #endif // Magick_STL_header
void attributeNames(Container *names_, const Image *image_)
Definition: STL.h:2026
void smushImages(Image *smushedImage_, InputIterator first_, InputIterator last_, const ssize_t offset_, bool stack_=false)
Definition: STL.h:2805
Definition: STL.h:49
Definition: STL.h:1549
class MagickPPExport Color
Definition: Color.h:18
void evaluateImages(Image *evaluatedImage_, InputIterator first_, InputIterator last_, const MagickEvaluateOperator operator_)
Definition: STL.h:2320
Magick::sigmoidalContrastImage
Definition: STL.h:1733
MagickPPExport const char * borderGeometryDefault
Definition: Image.cpp:34
void separateImages(Container *separatedImages_, Image &image_, const ChannelType channel_)
Definition: STL.h:2782
Definition: STL.h:94
Definition: STL.h:644
Definition: STL.h:278
void averageImages(Image *averagedImage_, InputIterator first_, InputIterator last_)
Definition: STL.h:2045
void pingImages(Container *sequence_, const std::string &imageSpec_, ReadOptions &options)
Definition: STL.h:2658
Definition: STL.h:1086
Definition: STL.h:1453
Definition: STL.h:1236
Definition: STL.h:1378
Definition: Blob.h:28
Definition: STL.h:415
Definition: Montage.h:24
Definition: STL.h:735
Definition: STL.h:106
void coderInfoList(Container *container_, CoderInfo::MatchType isReadable_=CoderInfo::AnyMatch, CoderInfo::MatchType isWritable_=CoderInfo::AnyMatch, CoderInfo::MatchType isMultiFrame_=CoderInfo::AnyMatch)
Definition: STL.h:2103
void mosaicImages(Image *mosaicImage_, InputIterator first_, InputIterator last_)
Definition: STL.h:2569
void unlinkImages(InputIterator first_, InputIterator last_)
Definition: STL.h:1957
Definition: STL.h:81
const MagickCore::Image * constImage(void) const
Definition: Image.cpp:5029
Definition: STL.h:1046
Definition: STL.h:401
void animateImages(InputIterator first_, InputIterator last_)
Definition: STL.h:1977
Definition: STL.h:178
MagickPPExport const char * raiseGeometryDefault
Definition: Image.cpp:36
bool isReadable(void) const
Definition: CoderInfo.cpp:122
Definition: STL.h:1761
void coalesceImages(Container *coalescedImages_, InputIterator first_, InputIterator last_)
Definition: STL.h:2064
Definition: STL.h:1110
Definition: STL.h:478
Definition: Geometry.h:208
Definition: STL.h:1537
Definition: STL.h:1364
Magick::restoreChannelMaskImages
void restoreChannelMaskImages(InputIterator first_, InputIterator last_, Container *container_)
Definition: STL.h:1937
Definition: STL.h:1808
Definition: STL.h:154
void quiet(const bool quiet_)
Definition: Image.cpp:1316
Definition: STL.h:217
void appendImages(Image *appendedImage_, InputIterator first_, InputIterator last_, bool stack_=false)
Definition: STL.h:1991
Definition: STL.h:1673
Definition: STL.h:460
Definition: STL.h:1195
Magick::quantizeColorSpaceImage
Definition: STL.h:1661
void mergeImageLayers(Image *mergedImage_, InputIterator first_, InputIterator last_, const LayerMethod method_)
Definition: STL.h:2469
Definition: STL.h:933
Magick::forwardFourierTransformImage
void forwardFourierTransformImage(Container *fourierImages_, const Image &image_)
Definition: STL.h:2352
Definition: STL.h:1206
Definition: STL.h:510
void insertImages(Container *sequence_, MagickCore::Image *images_)
Definition: STL.h:1873
Definition: STL.h:656
Definition: STL.h:437
Definition: STL.h:543
Magick::quantizeTreeDepthImage
Definition: STL.h:1685
Definition: STL.h:300
Definition: STL.h:1709
bool linkImages(InputIterator first_, InputIterator last_)
Definition: STL.h:1903
MagickCore::Image * replaceImage(MagickCore::Image *replacement_)
Definition: Image.cpp:5074
void optimizeImageLayers(Container *optimizedImages_, InputIterator first_, InputIterator last_)
Definition: STL.h:2587
Definition: STL.h:1513
void combineImages(Image *combinedImage_, InputIterator first_, InputIterator last_, const ChannelType channel_, const ColorspaceType colorspace_=MagickCore::sRGBColorspace)
Definition: STL.h:2242
Definition: STL.h:593
void cropToTiles(Container *tiledImages_, const Image image_, const Geometry &geometry_)
Definition: STL.h:2264
Magick::Montage::transparentColor
void transparentColor(const Color &transparentColor_)
Definition: Montage.cpp:173
Definition: STL.h:324
Definition: STL.h:831
Definition: STL.h:1159
Definition: STL.h:1310
Definition: STL.h:1597
Definition: STL.h:1147
Definition: STL.h:1573
Definition: STL.h:906
Definition: STL.h:685
void flattenImages(Image *flattendImage_, InputIterator first_, InputIterator last_)
Definition: STL.h:2336
Magick::chromaBluePrimaryImage
Definition: STL.h:1322
Definition: STL.h:1834
void colorHistogram(Container *histogram_, const Image image)
Definition: STL.h:2212
MagickPPExport void throwException(MagickCore::ExceptionInfo *exception_, const bool quiet_=false)
MagickCore::Image *& image(void)
Definition: Image.cpp:5024
void montageImages(Container *montageImages_, InputIterator first_, InputIterator last_, const Montage &options_)
Definition: STL.h:2484
Definition: STL.h:1477
Definition: STL.h:1465
void updateNoCopy(void *data_, const size_t length_, const Allocator allocator_=NewAllocator)
Definition: Blob.cpp:123
Magick::chromaGreenPrimaryImage
Definition: STL.h:1336
Definition: STL.h:669
Definition: Blob.h:22
Definition: STL.h:554
Definition: STL.h:1350
Definition: STL.h:191
void quiet(const bool quiet_)
Definition: STL.cpp:845
Definition: STL.h:1585
#define MagickPPExport
Definition: Include.h:297
Definition: STL.h:844
Definition: STL.h:1123
Definition: STL.h:1501
Definition: STL.h:1249
Definition: STL.h:1821
Definition: STL.h:205
Definition: STL.h:1135
Magick::CoderInfo::isMultiFrame
bool isMultiFrame(void) const
Definition: CoderInfo.cpp:132
std::vector< Magick::Drawable > DrawableList
Definition: Drawable.h:146
Definition: STL.h:1440
void writeImages(InputIterator first_, InputIterator last_, const std::string &imageSpec_, bool adjoin_=true)
Definition: STL.h:2823
void mapImages(InputIterator first_, InputIterator last_, const Image &mapImage_, bool dither_=false, bool measureError_=false)
Definition: STL.h:2411
Definition: STL.h:787
void readImages(Container *sequence_, const std::string &imageSpec_, ReadOptions &options)
Definition: STL.h:2735
Definition: STL.h:1625
Definition: STL.h:372
Definition: Color.h:36
MagickPPExport const char * frameGeometryDefault
Definition: Image.cpp:35
Definition: Drawable.h:226
Definition: Exception.h:154
Magick::throwExceptionExplicit
MagickPPExport void throwExceptionExplicit(const MagickCore::ExceptionType severity_, const char *reason_, const char *description_=(char *) NULL)
Definition: Exception.cpp:808
Definition: STL.h:1609
Definition: STL.h:1784
Definition: STL.h:1074
Definition: Geometry.h:37
Definition: STL.h:857
Definition: STL.h:1637
Definition: STL.h:1390
Definition: STL.h:253
Definition: STL.h:389
Definition: STL.h:1772
#define ThrowPPException(quiet)
Definition: Include.h:1580
Definition: STL.h:948
Definition: STL.h:1525
void fxImages(Image *fxImage_, InputIterator first_, InputIterator last_, const std::string expression)
Definition: STL.h:2391
Definition: STL.h:776
Magick::backgroundTextureImage
Definition: STL.h:1286
Definition: STL.h:426
Definition: STL.h:711
Definition: STL.h:1416
void ping(const bool flag_)
Definition: STL.cpp:835
Definition: STL.h:1561
Definition: STL.h:1001
Definition: CoderInfo.h:26
void isValid(const bool isValid_)
Definition: Image.cpp:1076
Definition: STL.h:1404
Definition: STL.h:960
Definition: STL.h:805
void deconstructImages(Container *deconstructedImages_, InputIterator first_, InputIterator last_)
Definition: STL.h:2278
Definition: STL.h:618
Definition: CoderInfo.h:27
Definition: STL.h:1721
Definition: STL.h:987
Definition: STL.h:336
Definition: STL.h:1298
Definition: STL.h:920
const void * data(void) const
Definition: Blob.cpp:105
Definition: STL.h:166
bool isWritable(void) const
Definition: CoderInfo.cpp:127
void channelMaskImages(InputIterator first_, InputIterator last_, Container *container_, const ChannelType channel_)
Definition: STL.h:1854
Definition: Drawable.h:120
Definition: STL.h:1489
void morphImages(Container *morphedImages_, InputIterator first_, InputIterator last_, size_t frames_)
Definition: STL.h:2538
void artifactNames(Container *names_, const Image *image_)
Definition: STL.h:2008
Definition: STL.h:1220
Definition: STL.h:1796
Definition: STL.h:746
Definition: STL.h:141
Definition: STL.h:696
class MagickPPExport Image
Definition: Drawable.h:722
Magick::adaptiveThresholdImage
Definition: STL.h:65
Magick::ReadOptions::imageInfo
MagickCore::ImageInfo * imageInfo(void)
Definition: STL.cpp:871
Magick::animationIterationsImage
Definition: STL.h:1262
Definition: STL.h:449
Definition: Blob.h:17
Definition: STL.h:239
Definition: STL.h:572
Definition: STL.h:1059
size_t length(void) const
Definition: Blob.cpp:110
Definition: STL.h:817
void displayImages(InputIterator first_, InputIterator last_)
Definition: STL.h:2304
void label(const std::string &label_)
Definition: Montage.cpp:103
Definition: STL.h:723
Magick::inverseFourierTransformImage
Definition: STL.h:631
Definition: STL.h:1017
#define GetPPException
Definition: Include.h:1561
MatchType
Definition: CoderInfo.h:25
Definition: STL.h:1098
Definition: STL.h:972
Definition: CoderInfo.h:21
Magick::optimizePlusImageLayers
void optimizePlusImageLayers(Container *optimizedImages_, InputIterator first_, InputIterator last_)
Definition: STL.h:2616
Definition: STL.h:1749
Definition: Image.h:55
Definition: STL.h:350
Definition: STL.h:1649
Definition: STL.h:265
Definition: STL.h:1274
void optimizeTransparency(InputIterator first_, InputIterator last_)
Definition: STL.h:2645
Definition: STL.h:1183
void profileNames(Container *names_, const Image *image_)
Definition: STL.h:2688
Definition: STL.h:312
Magick::Montage::updateMontageInfo
virtual void updateMontageInfo(MagickCore::MontageInfo &montageInfo_) const
Definition: Montage.cpp:183
Definition: STL.h:1171
Definition: STL.h:606
Definition: STL.h:1033
Definition: STL.h:763
Definition: CoderInfo.h:28
Definition: STL.h:1697
void quantizeImages(InputIterator first_, InputIterator last_, bool measureError_=false)
Definition: STL.h:2707
Definition: STL.h:1428