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