Magick++: button.cpp Source File

Magick++ 7.0.10

button.cpp
Go to the documentation of this file.
1 //
2 // Magick++ demo to generate a simple text button
3 //
4 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2003
5 //
6
7 #include <Magick++.h>
8 #include <string>
9 #include <iostream>
10
11 using namespace std;
12
13 using namespace Magick;
14
15 int main( int /*argc*/, char ** argv)
16 {
17
18 // Initialize ImageMagick install location for Windows
19 InitializeMagick(*argv);
20
21 try {
22
23 string srcdir("");
24 if(getenv("SRCDIR") != 0)
25 srcdir = getenv("SRCDIR");
26
27 //
28 // Options
29 //
30
31 string backGround = "xc:#CCCCCC"; // A solid color
32
33 // Color to use for decorative border
34 Color border = "#D4DCF3";
35
36 // Button size
37 string buttonSize = "120x20";
38
39 // Button background texture
40 string buttonTexture = "granite:";
41
42 // Button text
43 string text = "Button Text";
44
45 // Button text color
46 string textColor = "red";
47
48 // Font point size
49 int fontPointSize = 16;
50
51 //
52 // Magick++ operations
53 //
54
55 Image button;
56
57 // Set button size
58 button.size( buttonSize );
59
60 // Read background image
61 button.read( backGround );
62
63 // Set background to buttonTexture
64 Image backgroundTexture( buttonTexture );
65 button.texture( backgroundTexture );
66
67 #if MAGICKCORE_FREETYPE_DELEGATE
68 // Add some text
69 button.fillColor( textColor );
70 button.fontPointsize( fontPointSize );
71 if (getenv("MAGICK_FONT") != 0)
72 button.font(string(getenv("MAGICK_FONT")));
73 button.annotate( text, CenterGravity );
74 #endif
75
76 // Add a decorative frame
77 button.borderColor( border );
78 button.frame( "6x6+3+3" );
79
80 button.depth( 8 );
81
82 // Quantize to desired colors
83 // button.quantizeTreeDepth(8);
84 button.quantizeDither(false);
85 button.quantizeColors(64);
86 button.quantize();
87
88 // Save to file
89 cout << "Writing to \"button_out.miff\" ..." << endl;
90 button.compressType( RLECompression );
91 button.write("button_out.miff");
92
93 // Display on screen
94 // button.display();
95
96 }
97 catch( exception &error_ )
98 {
99 cout << "Caught exception: " << error_.what() << endl;
100 return 1;
101 }
102
103 return 0;
104 }
Magick::Image::annotate
void annotate(const std::string &text_, const Geometry &location_)
Definition: Image.cpp:1845
std
STL namespace.
Magick::Image::write
void write(Blob *blob_)
Definition: Image.cpp:4880
Magick++.h
Magick::Image::quantize
void quantize(const bool measureError_=false)
Definition: Image.cpp:3978
Magick::Image::read
void read(const Blob &blob_)
Definition: Image.cpp:4022
Magick::Image::frame
void frame(const Geometry &geometry_=frameGeometryDefault)
Definition: Image.cpp:3146
Magick::Image::borderColor
void borderColor(const Color &color_)
Definition: Image.cpp:427
Magick::Image::font
void font(const std::string &font_)
Definition: Image.cpp:850
Magick::Image::fontPointsize
void fontPointsize(const double pointSize_)
Definition: Image.cpp:872
Magick::Image::texture
void texture(const Image &texture_)
Definition: Image.cpp:4626
Magick::Image::fillColor
void fillColor(const Color &fillColor_)
Definition: Image.cpp:784
Magick::Image::size
void size(const Geometry &geometry_)
Definition: Image.cpp:1366
Magick::Color
Definition: Color.h:34
Magick::Image::quantizeColors
void quantizeColors(const size_t colors_)
Definition: Image.cpp:1258
Magick
Definition: Blob.h:15
main
int main(int, char **argv)
Definition: button.cpp:15
Magick::InitializeMagick
MagickPPExport void InitializeMagick(const char *path_)
Definition: Functions.cpp:43
Magick::Image::quantizeDither
void quantizeDither(const bool ditherFlag_)
Definition: Image.cpp:1281
Magick::Image::depth
void depth(const size_t depth_)
Definition: Image.cpp:691
Magick::Image
Definition: Image.h:53
Magick::Image::compressType
void compressType(const CompressionType compressType_)
Definition: Image.cpp:628