2 // Magick++ demo to generate a simple text button
4 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2003
13 using namespace Magick;
15 int main( int /*argc*/, char ** argv)
18 // Initialize ImageMagick install location for Windows
19 InitializeMagick(*argv);
24 if(getenv("SRCDIR") != 0)
25 srcdir = getenv("SRCDIR");
31 string backGround = "xc:#CCCCCC"; // A solid color
33 // Color to use for decorative border
34 Color border = "#D4DCF3";
37 string buttonSize = "120x20";
39 // Button background texture
40 string buttonTexture = "granite:";
43 string text = "Button Text";
46 string textColor = "red";
49 int fontPointSize = 16;
52 // Magick++ operations
58 button.size( buttonSize );
60 // Read background image
61 button.read( backGround );
63 // Set background to buttonTexture
64 Image backgroundTexture( buttonTexture );
65 button.texture( backgroundTexture );
68 button.fillColor( textColor );
69 button.fontPointsize( fontPointSize );
70 button.annotate( text, CenterGravity );
72 // Add a decorative frame
73 button.borderColor( border );
74 button.frame( "6x6+3+3" );
78 // Quantize to desired colors
79 // button.quantizeTreeDepth(8);
80 button.quantizeDither(false);
81 button.quantizeColors(64);
85 cout << "Writing to \"button_out.miff\" ..." << endl;
86 button.compressType( RLECompression );
87 button.write("button_out.miff");
93 catch( exception &error_ )
95 cout << "Caught exception: " << error_.what() << endl;