| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | #include <Magick++.h> |
|---|
| 11 | #include <string> |
|---|
| 12 | #include <iostream> |
|---|
| 13 | |
|---|
| 14 | using namespace std; |
|---|
| 15 | |
|---|
| 16 | using namespace Magick; |
|---|
| 17 | |
|---|
| 18 | int main( int , char ** argv) |
|---|
| 19 | { |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | InitializeMagick(*argv); |
|---|
| 23 | |
|---|
| 24 | try { |
|---|
| 25 | |
|---|
| 26 | string srcdir(""); |
|---|
| 27 | if(getenv("SRCDIR") != 0) |
|---|
| 28 | srcdir = getenv("SRCDIR"); |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | Image image( "300x300", "white" ); |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | std::list<Coordinate> poly_coord; |
|---|
| 40 | poly_coord.push_back( Coordinate(30,30) ); |
|---|
| 41 | poly_coord.push_back( Coordinate(100,10) ); |
|---|
| 42 | poly_coord.push_back( Coordinate(190,290) ); |
|---|
| 43 | poly_coord.push_back( Coordinate(30,290) ); |
|---|
| 44 | |
|---|
| 45 | Image texture( srcdir + "tile.miff" ); |
|---|
| 46 | image.penTexture( texture ); |
|---|
| 47 | image.draw( DrawablePolygon( poly_coord ) ); |
|---|
| 48 | texture.isValid( false ); |
|---|
| 49 | image.penTexture( texture ); |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | image.strokeColor( "black" ); |
|---|
| 55 | image.fillColor( "red" ); |
|---|
| 56 | image.strokeWidth( 5 ); |
|---|
| 57 | image.draw( DrawableEllipse( 100,100, 50,75, 0,360 ) ); |
|---|
| 58 | image.fillColor( Color() ); |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | image.strokeColor( "black" ); |
|---|
| 64 | image.strokeWidth( 5 ); |
|---|
| 65 | list<Drawable> drawlist; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | poly_coord.clear(); |
|---|
| 69 | poly_coord.push_back( Coordinate(30,30) ); |
|---|
| 70 | poly_coord.push_back( Coordinate(100,10) ); |
|---|
| 71 | poly_coord.push_back( Coordinate(190,290) ); |
|---|
| 72 | poly_coord.push_back( Coordinate(30,290) ); |
|---|
| 73 | drawlist.push_back( DrawablePolygon( poly_coord ) ); |
|---|
| 74 | image.draw( drawlist ); |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | image.colorFuzz( 0.8*QuantumRange ); |
|---|
| 80 | image.floodFillColor( "+132+62", "blue" ); |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | image.strokeColor(Color()); |
|---|
| 86 | image.fillColor( "red" ); |
|---|
| 87 | image.fontPointsize( 18 ); |
|---|
| 88 | image.annotate( "Hello world!", "+150+20" ); |
|---|
| 89 | |
|---|
| 90 | image.fillColor( "blue" ); |
|---|
| 91 | image.fontPointsize( 14 ); |
|---|
| 92 | image.annotate( "Goodbye cruel world!", "+150+38" ); |
|---|
| 93 | |
|---|
| 94 | image.fillColor( "black" ); |
|---|
| 95 | image.fontPointsize( 14 ); |
|---|
| 96 | image.annotate( "I'm climbing the wall!", "+280+120", |
|---|
| 97 | NorthWestGravity, 90.0 ); |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | cout << "Writing image \"shapes_out.miff\" ..." << endl; |
|---|
| 104 | image.depth( 8 ); |
|---|
| 105 | image.compressType( RLECompression ); |
|---|
| 106 | image.write( "shapes_out.miff" ); |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | } |
|---|
| 112 | catch( exception &error_ ) |
|---|
| 113 | { |
|---|
| 114 | cout << "Caught exception: " << error_.what() << endl; |
|---|
| 115 | return 1; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | return 0; |
|---|
| 119 | } |
|---|