📄 stl.h
字号:
// This may look like C code, but it is really -*- C++ -*-//// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003//// Definition and implementation of template functions for using// Magick::Image with STL containers.//#ifndef Magick_STL_header#define Magick_STL_header#include "Magick++/Include.h"#include <algorithm>#include <functional>#include <iterator>#include <map>#include <utility>#include "Magick++/CoderInfo.h"#include "Magick++/Drawable.h"#include "Magick++/Exception.h"#include "Magick++/Montage.h"namespace Magick{ // // STL function object declarations/definitions // // Function objects provide the means to invoke an operation on one // or more image objects in an STL-compatable container. The // arguments to the function object constructor(s) are compatable // with the arguments to the equivalent Image class method and // provide the means to supply these options when the function // object is invoked. // For example, to read a GIF animation, set the color red to // transparent for all frames, and write back out: // // list<image> images; // readImages( &images, "animation.gif" ); // for_each( images.begin(), images.end(), transparentImage( "red" ) ); // writeImages( images.begin(), images.end(), "animation.gif" ); // Local adaptive threshold image // http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm // Width x height define the size of the pixel neighborhood // offset = constant to subtract from pixel neighborhood mean class MagickDLLDecl adaptiveThresholdImage : public std::unary_function<Image&,void> { public: adaptiveThresholdImage( const unsigned int width_, const unsigned int height_, const unsigned int offset_ = 0 ); void operator()( Image &image_ ) const; private: unsigned int _width; unsigned int _height; unsigned int _offset; }; // Add noise to image with specified noise type class MagickDLLDecl addNoiseImage : public std::unary_function<Image&,void> { public: addNoiseImage ( NoiseType noiseType_ ); void operator()( Image &image_ ) const; private: NoiseType _noiseType; }; // Transform image by specified affine (or free transform) matrix. class MagickDLLDecl affineTransformImage : public std::unary_function<Image&,void> { public: affineTransformImage( const DrawableAffine &affine_ ); void operator()( Image &image_ ) const; private: DrawableAffine _affine; }; // Annotate image (draw text on image) class MagickDLLDecl annotateImage : public std::unary_function<Image&,void> { public: // Annotate using specified text, and placement location annotateImage ( const std::string &text_, const Geometry &geometry_ ); // Annotate using specified text, bounding area, and placement // gravity annotateImage ( const std::string &text_, const Geometry &geometry_, const GravityType gravity_ ); // Annotate with text using specified text, bounding area, // placement gravity, and rotation. annotateImage ( const std::string &text_, const Geometry &geometry_, const GravityType gravity_, const double degrees_ ); // Annotate with text (bounding area is entire image) and // placement gravity. annotateImage ( const std::string &text_, const GravityType gravity_ ); void operator()( Image &image_ ) const; private: // Copy constructor and assignment are not supported annotateImage(const annotateImage&); annotateImage& operator=(const annotateImage&); const std::string _text; const Geometry _geometry; const GravityType _gravity; const double _degrees; }; // Blur image with specified blur factor class MagickDLLDecl blurImage : public std::unary_function<Image&,void> { public: blurImage( const double radius_ = 1, const double sigma_ = 0.5 ); void operator()( Image &image_ ) const; private: double _radius; double _sigma; }; // Border image (add border to image) class MagickDLLDecl borderImage : public std::unary_function<Image&,void> { public: borderImage( const Geometry &geometry_ = borderGeometryDefault ); void operator()( Image &image_ ) const; private: Geometry _geometry; }; // Extract channel from image class MagickDLLDecl channelImage : public std::unary_function<Image&,void> { public: channelImage( const ChannelType channel_ ); void operator()( Image &image_ ) const; private: ChannelType _channel; }; // Charcoal effect image (looks like charcoal sketch) class MagickDLLDecl charcoalImage : public std::unary_function<Image&,void> { public: charcoalImage( const double radius_ = 1, const double sigma_ = 0.5 ); void operator()( Image &image_ ) const; private: double _radius; double _sigma; }; // Chop image (remove vertical or horizontal subregion of image) class MagickDLLDecl chopImage : public std::unary_function<Image&,void> { public: chopImage( const Geometry &geometry_ ); void operator()( Image &image_ ) const; private: Geometry _geometry; }; // Colorize image using pen color at specified percent opacity class MagickDLLDecl colorizeImage : public std::unary_function<Image&,void> { public: colorizeImage( const unsigned int opacityRed_, const unsigned int opacityGreen_, const unsigned int opacityBlue_, const Color &penColor_ ); colorizeImage( const unsigned int opacity_, const Color &penColor_ ); void operator()( Image &image_ ) const; private: unsigned int _opacityRed; unsigned int _opacityGreen; unsigned int _opacityBlue; Color _penColor; }; // Convert the image colorspace representation class MagickDLLDecl colorSpaceImage : public std::unary_function<Image&,void> { public: colorSpaceImage( ColorspaceType colorSpace_ ); void operator()( Image &image_ ) const; private: ColorspaceType _colorSpace; }; // Comment image (add comment string to image) class MagickDLLDecl commentImage : public std::unary_function<Image&,void> { public: commentImage( const std::string &comment_ ); void operator()( Image &image_ ) const; private: std::string _comment; }; // Compose an image onto another at specified offset and using // specified algorithm class MagickDLLDecl compositeImage : public std::unary_function<Image&,void> { public: compositeImage( const Image &compositeImage_, int xOffset_, int yOffset_, CompositeOperator compose_ = InCompositeOp ); compositeImage( const Image &compositeImage_, const Geometry &offset_, CompositeOperator compose_ = InCompositeOp ); void operator()( Image &image_ ) const; private: Image _compositeImage; int _xOffset; int _yOffset; CompositeOperator _compose; }; // Contrast image (enhance intensity differences in image) class MagickDLLDecl contrastImage : public std::unary_function<Image&,void> { public: contrastImage( const unsigned int sharpen_ ); void operator()( Image &image_ ) const; private: unsigned int _sharpen; }; // Crop image (subregion of original image) class MagickDLLDecl cropImage : public std::unary_function<Image&,void> { public: cropImage( const Geometry &geometry_ ); void operator()( Image &image_ ) const; private: Geometry _geometry; }; // Cycle image colormap class MagickDLLDecl cycleColormapImage : public std::unary_function<Image&,void> { public: cycleColormapImage( const int amount_ ); void operator()( Image &image_ ) const; private: int _amount; }; // Despeckle image (reduce speckle noise) class MagickDLLDecl despeckleImage : public std::unary_function<Image&,void> { public: despeckleImage( void ); void operator()( Image &image_ ) const; private: }; // Draw on image class MagickDLLDecl drawImage : public std::unary_function<Image&,void> { public: // Draw on image using a single drawable // Store in list to make implementation easier drawImage( const Drawable &drawable_ ); // Draw on image using a drawable list drawImage( const DrawableList &drawable_ ); void operator()( Image &image_ ) const; private: DrawableList _drawableList; }; // Edge image (hilight edges in image) class MagickDLLDecl edgeImage : public std::unary_function<Image&,void> { public: edgeImage( const double radius_ = 0.0 ); void operator()( Image &image_ ) const; private: double _radius; }; // Emboss image (hilight edges with 3D effect) class MagickDLLDecl embossImage : public std::unary_function<Image&,void> { public: embossImage( void ); embossImage( const double radius_, const double sigma_ ); void operator()( Image &image_ ) const; private: double _radius; double _sigma; }; // Enhance image (minimize noise) class MagickDLLDecl enhanceImage : public std::unary_function<Image&,void> { public: enhanceImage( void ); void operator()( Image &image_ ) const; private: }; // Equalize image (histogram equalization) class MagickDLLDecl equalizeImage : public std::unary_function<Image&,void> { public: equalizeImage( void ); void operator()( Image &image_ ) const; private: }; // Color to use when filling drawn objects class MagickDLLDecl fillColorImage : public std::unary_function<Image&,void> { public: fillColorImage( const Color &fillColor_ ); void operator()( Image &image_ ) const; private: Color _fillColor; }; // Flip image (reflect each scanline in the vertical direction) class MagickDLLDecl flipImage : public std::unary_function<Image&,void> { public: flipImage( void ); void operator()( Image &image_ ) const; private: }; // Flood-fill image with color class MagickDLLDecl floodFillColorImage : public std::unary_function<Image&,void> { public: // Flood-fill color across pixels starting at target-pixel and // stopping at pixels matching specified border color. // Uses current fuzz setting when determining color match. floodFillColorImage( const unsigned int x_, const unsigned int y_, const Color &fillColor_ ); floodFillColorImage( const Geometry &point_, const Color &fillColor_ ); // Flood-fill color across pixels starting at target-pixel and // stopping at pixels matching specified border color. // Uses current fuzz setting when determining color match. floodFillColorImage( const unsigned int x_, const unsigned int y_, const Color &fillColor_, const Color &borderColor_ ); floodFillColorImage( const Geometry &point_, const Color &fillColor_, const Color &borderColor_ ); void operator()( Image &image_ ) const; private: unsigned int _x; unsigned int _y; Color _fillColor; Color _borderColor; }; // Flood-fill image with texture class MagickDLLDecl floodFillTextureImage : public std::unary_function<Image&,void> { public: // Flood-fill texture across pixels that match the color of the // target pixel and are neighbors of the target pixel. // Uses current fuzz setting when determining color match. floodFillTextureImage( const unsigned int x_, const unsigned int y_, const Image &texture_ ); floodFillTextureImage( const Geometry &point_, const Image &texture_ ); // Flood-fill texture across pixels starting at target-pixel and // stopping at pixels matching specified border color. // Uses current fuzz setting when determining color match. floodFillTextureImage( const unsigned int x_, const unsigned int y_, const Image &texture_, const Color &borderColor_ ); floodFillTextureImage( const Geometry &point_, const Image &texture_, const Color &borderColor_ ); void operator()( Image &image_ ) const; private: unsigned int _x; unsigned int _y; Image _texture; Color _borderColor; }; // Flop image (reflect each scanline in the horizontal direction) class MagickDLLDecl flopImage : public std::unary_function<Image&,void> { public: flopImage( void ); void operator()( Image &image_ ) const; private: }; // Frame image
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -