button.cpp
Go to the documentation of this file.
//
// Magick++ demo to generate a simple text button
//
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2003
//
// Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
// dedicated to making software imaging solutions freely available.
//
#include <Magick++.h>
#include <string>
#include <iostream>
using namespace std;
using namespace Magick;
int main( int /*argc*/, char ** argv)
{
// Initialize ImageMagick install location for Windows
InitializeMagick(*argv);
try {
string srcdir("");
if(getenv("SRCDIR") != 0)
srcdir = getenv("SRCDIR");
//
// Options
//
string backGround = "xc:#CCCCCC"; // A solid color
// Color to use for decorative border
Color border = "#D4DCF3";
// Button size
string buttonSize = "120x20";
// Button background texture
string buttonTexture = "granite:";
// Button text
string text = "Button Text";
// Button text color
string textColor = "red";
// Font point size
int fontPointSize = 16;
//
// Magick++ operations
//
Image button;
// Set button size
button.size( buttonSize );
// Read background image
button.read( backGround );
// Set background to buttonTexture
Image backgroundTexture( buttonTexture );
button.texture( backgroundTexture );
#if MAGICKCORE_FREETYPE_DELEGATE
// Add some text
button.fillColor( textColor );
button.fontPointsize( fontPointSize );
if (getenv("MAGICK_FONT") != 0)
button.font(string(getenv("MAGICK_FONT")));
button.annotate( text, CenterGravity );
#endif
// Add a decorative frame
button.borderColor( border );
button.frame( "6x6+3+3" );
button.depth( 8 );
// Quantize to desired colors
// button.quantizeTreeDepth(8);
button.quantizeDither(false);
button.quantizeColors(64);
button.quantize();
// Save to file
cout << "Writing to \"button_out.miff\" ..." << endl;
button.compressType( RLECompression );
button.write("button_out.miff");
// Display on screen
// button.display();
}
catch( exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}
Magick::Image::annotate
void annotate(const std::string &text_, const Geometry &location_)
Definition: Image.cpp:1858
std
STL namespace.
Magick::Image::write
void write(Blob *blob_)
Definition: Image.cpp:4896
Magick++.h
Magick::Image::quantize
void quantize(const bool measureError_=false)
Definition: Image.cpp:3994
Magick::Image::read
void read(const Blob &blob_)
Definition: Image.cpp:4038
Magick::Image::frame
void frame(const Geometry &geometry_=frameGeometryDefault)
Definition: Image.cpp:3162
Magick::Image::borderColor
void borderColor(const Color &color_)
Definition: Image.cpp:429
Magick::Image::font
void font(const std::string &font_)
Definition: Image.cpp:852
Magick::Image::fontPointsize
void fontPointsize(const double pointSize_)
Definition: Image.cpp:874
Magick::Image::texture
void texture(const Image &texture_)
Definition: Image.cpp:4642
Magick::Image::fillColor
void fillColor(const Color &fillColor_)
Definition: Image.cpp:786
Magick::Image::size
void size(const Geometry &geometry_)
Definition: Image.cpp:1379
Magick::Color
Definition: Color.h:36
Magick::Image::quantizeColors
void quantizeColors(const size_t colors_)
Definition: Image.cpp:1260
Magick
Definition: Blob.h:17
main
int main(int, char **argv)
Definition: button.cpp:18
Magick::InitializeMagick
MagickPPExport void InitializeMagick(const char *path_)
Definition: Functions.cpp:45
Magick::Image::quantizeDither
void quantizeDither(const bool ditherFlag_)
Definition: Image.cpp:1283
Magick::Image::depth
void depth(const size_t depth_)
Definition: Image.cpp:693
Magick::Image
Definition: Image.h:55
Magick::Image::compressType
void compressType(const CompressionType compressType_)
Definition: Image.cpp:630