Home | History | Annotate | Download | only in Magick++
      1 // This may look like C code, but it is really -*- C++ -*-
      2 //
      3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
      4 // Copyright Dirk Lemstra 2014-2016
      5 //
      6 // Definition of Options
      7 //
      8 // Options which may be applied to an image. These options are the
      9 // equivalent of options supplied to ImageMagick utilities.
     10 //
     11 // This is an internal implementation class and is not part of the
     12 // Magick++ API
     13 //
     14 
     15 #if !defined(Magick_Options_header)
     16 #define Magick_Options_header
     17 
     18 #include "Magick++/Include.h"
     19 #include <string>
     20 #include "Magick++/Color.h"
     21 #include "Magick++/Geometry.h"
     22 #include "Magick++/Drawable.h"
     23 
     24 namespace Magick
     25 {
     26   class Image;
     27 
     28   class Options
     29   {
     30   public:
     31 
     32     // Default constructor
     33     Options(void);
     34 
     35     // Copy constructor
     36     Options(const Options& options_);
     37 
     38     // Destructor
     39     ~Options();
     40 
     41     // Join images into a single multi-image file
     42     void adjoin(const bool flag_);
     43     bool adjoin(void) const;
     44 
     45     // Transparent color
     46     void alphaColor(const Color &alphaColor_);
     47     Color alphaColor(void) const;
     48 
     49     // Image background color
     50     void backgroundColor(const Color &color_);
     51     Color backgroundColor(void) const;
     52 
     53     // Name of texture image to tile onto the image background
     54     void backgroundTexture(const std::string &backgroundTexture_);
     55     std::string backgroundTexture(void) const;
     56 
     57     // Image border color
     58     void borderColor(const Color &color_);
     59     Color borderColor(void) const;
     60 
     61     // Text bounding-box base color (default none)
     62     void boxColor(const Color &boxColor_);
     63     Color boxColor(void) const;
     64 
     65     // Colors within this distance are considered equal
     66     void colorFuzz(const double fuzz_);
     67     double colorFuzz(void) const;
     68 
     69     // Image colorspace scheme
     70     void colorspaceType(const ColorspaceType colorspace_);
     71     ColorspaceType colorspaceType(void) const;
     72 
     73     // Compression type ( NoCompression, BZipCompression,
     74     // FaxCompression, JPEGCompression, LZWCompression,
     75     // RLECompression, or ZipCompression )
     76     void compressType(const CompressionType compressType_);
     77     CompressionType compressType(void) const;
     78 
     79     // Enable printing of debug messages from ImageMagick
     80     void debug(const bool flag_);
     81     bool debug(void) const;
     82 
     83     // Vertical and horizontal resolution in pixels of the image
     84     void density(const Point &density_);
     85     Point density(void) const;
     86 
     87     // Image depth (8 or 16)
     88     void depth(const size_t depth_);
     89     size_t depth(void) const;
     90 
     91     // Endianness (little like Intel or big like SPARC) for image
     92     // formats which support endian-specific options.
     93     void endian(const EndianType endian_);
     94     EndianType endian(void) const;
     95 
     96     // Image filename to read or write
     97     void file(FILE *file_);
     98     FILE *file(void) const;
     99 
    100     // Image filename to read or write
    101     void fileName(const std::string &fileName_);
    102     std::string fileName(void) const;
    103 
    104     // Color to use when filling drawn objects
    105     void fillColor(const Color &fillColor_);
    106     Color fillColor(void) const;
    107 
    108     // Fill pattern
    109     void fillPattern(const MagickCore::Image *fillPattern_);
    110     const MagickCore::Image *fillPattern(void) const;
    111 
    112     // Rule to use when filling drawn objects
    113     void fillRule(const FillRule &fillRule_);
    114     FillRule fillRule(void) const;
    115 
    116     // Font name
    117     void font(const std::string &font_);
    118     std::string font(void) const;
    119 
    120     // Font name
    121     void fontFamily(const std::string &family_);
    122     std::string fontFamily(void) const;
    123 
    124     // Font point size
    125     void fontPointsize(const double pointSize_);
    126     double fontPointsize(void) const;
    127 
    128     // Font style
    129     void fontStyle(const StyleType style_);
    130     StyleType fontStyle(void) const;
    131 
    132     // Font weight
    133     void fontWeight(const size_t weight_);
    134     size_t fontWeight(void) const;
    135 
    136     std::string format(void) const;
    137 
    138     // Image interlace scheme
    139     void interlaceType(const InterlaceType interlace_);
    140     InterlaceType interlaceType(void) const;
    141 
    142    // Image format to write or read
    143     void magick(const std::string &magick_);
    144     std::string magick(void) const;
    145 
    146    // Write as a monochrome image
    147     void monochrome(const bool monochromeFlag_);
    148     bool monochrome(void) const;
    149 
    150     // Preferred size and location of an image canvas.
    151     void page(const Geometry &pageSize_);
    152     Geometry page(void) const;
    153 
    154     // Desired image quality factor
    155     void quality(const size_t quality_);
    156     size_t quality(void) const;
    157 
    158     // Maximum number of colors to quantize to
    159     void quantizeColors(const size_t colors_);
    160     size_t quantizeColors(void) const;
    161 
    162     // Colorspace to quantize in.
    163     void quantizeColorSpace(const ColorspaceType colorSpace_);
    164     ColorspaceType quantizeColorSpace(void) const;
    165 
    166     // Dither image during quantization.
    167     void quantizeDither(const bool ditherFlag_);
    168     bool quantizeDither(void) const;
    169 
    170     // Dither method
    171     void quantizeDitherMethod(const DitherMethod ditherMethod_);
    172     DitherMethod quantizeDitherMethod(void) const;
    173 
    174     // Quantization tree-depth
    175     void quantizeTreeDepth(const size_t treeDepth_);
    176     size_t quantizeTreeDepth(void) const;
    177 
    178     // Suppress all warning messages. Error messages are still reported.
    179     void quiet(const bool quiet_);
    180     bool quiet(void) const;
    181 
    182     // Units of resolution to interpret density
    183     void resolutionUnits(const ResolutionType resolutionUnits_);
    184     ResolutionType resolutionUnits(void) const;
    185 
    186     // Image sampling factor
    187     void samplingFactor(const std::string &samplingFactor_);
    188     std::string samplingFactor(void) const;
    189 
    190     // Image size (required for raw formats)
    191     void size(const Geometry &geometry_);
    192     Geometry size(void) const;
    193 
    194     // enabled/disable stroke anti-aliasing
    195     void strokeAntiAlias(const bool flag_);
    196     bool strokeAntiAlias(void) const ;
    197 
    198     // Color to use when drawing object outlines
    199     void strokeColor(const Color &strokeColor_);
    200     Color strokeColor(void) const;
    201 
    202     // Control the pattern of dashes and gaps used to stroke
    203     // paths. The strokeDashArray represents a list of numbers that
    204     // specify the lengths of alternating dashes and gaps in user
    205     // units. If an odd number of values is provided, then the list of
    206     // values is repeated to yield an even number of values.
    207     void strokeDashArray(const double *strokeDashArray_);
    208     const double *strokeDashArray(void) const;
    209 
    210     // While drawing using strokeDashArray, specify distance into the dash
    211     // pattern to start the dash (default 0).
    212     void strokeDashOffset(const double strokeDashOffset_);
    213     double strokeDashOffset(void) const;
    214 
    215     // Specify the shape to be used at the end of open subpaths when
    216     // they are stroked. Values of LineCap are UndefinedCap, ButtCap,
    217     // RoundCap, and SquareCap.
    218     void strokeLineCap(const LineCap lineCap_);
    219     LineCap strokeLineCap(void) const;
    220 
    221     // Specify the shape to be used at the corners of paths (or other
    222     // vector shapes) when they are stroked. Values of LineJoin are
    223     // UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin.
    224     void strokeLineJoin(const LineJoin lineJoin_);
    225     LineJoin strokeLineJoin(void) const;
    226 
    227     // Specify miter limit. When two line segments meet at a sharp
    228     // angle and miter joins have been specified for 'lineJoin', it is
    229     // possible for the miter to extend far beyond the thickness of
    230     // the line stroking the path. The miterLimit' imposes a limit on
    231     // the ratio of the miter length to the 'stroke_width'. The default
    232     // value of this parameter is 4.
    233     void strokeMiterLimit(const size_t miterLimit_);
    234     size_t strokeMiterLimit(void) const;
    235 
    236     // Pattern image to use for stroked outlines
    237     void strokePattern(const MagickCore::Image *strokePattern_);
    238     const MagickCore::Image *strokePattern(void) const;
    239 
    240    // Stroke width for drawing vector objects (default one)
    241     void strokeWidth(const double strokeWidth_);
    242     double strokeWidth(void) const;
    243 
    244     void subImage(const size_t subImage_);
    245     size_t subImage(void) const;
    246 
    247     // Sub-frame number to return
    248     void subRange(const size_t subRange_);
    249     size_t subRange(void) const;
    250 
    251     // Remove pixel aliasing
    252     void textAntiAlias(const bool flag_);
    253     bool textAntiAlias(void) const;
    254 
    255     // Render text right-to-left or left-to-right.
    256     void textDirection(const DirectionType direction_);
    257     DirectionType textDirection() const;
    258 
    259     // Annotation text encoding (e.g. "UTF-16")
    260     void textEncoding(const std::string &encoding_);
    261     std::string textEncoding(void) const;
    262 
    263     // Text gravity.
    264     void textGravity(const GravityType gravity_);
    265     GravityType textGravity() const;
    266 
    267     // Text inter-line spacing
    268     void textInterlineSpacing(const double spacing_);
    269     double textInterlineSpacing(void) const;
    270 
    271     // Text inter-word spacing
    272     void textInterwordSpacing(const double spacing_);
    273     double textInterwordSpacing(void) const;
    274 
    275     // Text inter-character kerning
    276     void textKerning(const double kerning_);
    277     double textKerning(void) const;
    278 
    279     // Text undercolor box
    280     void textUnderColor(const Color &underColor_);
    281     Color textUnderColor(void) const;
    282 
    283     // Origin of coordinate system to use when annotating with text or drawing
    284     void transformOrigin(const double tx_,const double ty_);
    285 
    286     // Reset transformation parameters to default
    287     void transformReset(void);
    288 
    289     // Rotation to use when annotating with text or drawing
    290     void transformRotation(const double angle_);
    291 
    292     // Scale to use when annotating with text or drawing
    293     void transformScale(const double sx_,const double sy_);
    294 
    295     // Skew to use in X axis when annotating with text or drawing
    296     void transformSkewX(const double skewx_);
    297 
    298     // Skew to use in Y axis when annotating with text or drawing
    299     void transformSkewY(const double skewy_);
    300 
    301     // Image representation type
    302     void type(const ImageType type_);
    303     ImageType type(void) const;
    304 
    305     // Return verbose information about an image, or an operation
    306     void verbose(const bool verboseFlag_);
    307     bool verbose(void) const;
    308 
    309     // X11 display name
    310     void x11Display(const std::string &display_);
    311     std::string x11Display(void) const;
    312 
    313     //
    314     // Internal implementation methods.  Please do not use.
    315     //
    316 
    317     MagickCore::DrawInfo *drawInfo(void);
    318     MagickCore::ImageInfo *imageInfo(void);
    319     MagickCore::QuantizeInfo *quantizeInfo(void);
    320 
    321     // Construct using raw structures
    322     Options(const MagickCore::ImageInfo *imageInfo_,
    323       const MagickCore::QuantizeInfo *quantizeInfo_,
    324       const MagickCore::DrawInfo *drawInfo_);
    325 
    326   private:
    327 
    328     // Assignment not supported
    329     Options& operator=(const Options&);
    330 
    331     void setOption(const char *name,const Color &value_);
    332 
    333     void setOption(const char *name,const double value_);
    334 
    335     MagickCore::ImageInfo    *_imageInfo;
    336     MagickCore::QuantizeInfo *_quantizeInfo;
    337     MagickCore::DrawInfo     *_drawInfo;
    338     bool                     _quiet;
    339   };
    340 } // namespace Magick
    341 
    342 #endif // Magick_Options_header
    343