Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

ImageMagick-6.1.1/Magick++/lib/Drawable.cpp

Go to the documentation of this file.
00001 // This may look like C code, but it is really -*- C++ -*- 00002 // 00003 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003 00004 // 00005 // Implementation of Drawable (Graphic objects) 00006 // 00007 00008 #define MAGICK_IMPLEMENTATION 1 00009 #define MAGICK_DRAWABLE_IMPLEMENTATION 00010 00011 #include "Magick++/Include.h" 00012 #include <math.h> 00013 #include <string> 00014 00015 #include "Magick++/Drawable.h" 00016 #include "Magick++/Image.h" 00017 00018 using namespace std; 00019 00020 MagickDLLDecl int Magick::operator == ( const Magick::Coordinate& left_, 00021 const Magick::Coordinate& right_ ) 00022 { 00023 return ( ( left_.x() == right_.x() ) && ( left_.y() == right_.y() ) ); 00024 } 00025 MagickDLLDecl int Magick::operator != ( const Magick::Coordinate& left_, 00026 const Magick::Coordinate& right_ ) 00027 { 00028 return ( ! (left_ == right_) ); 00029 } 00030 MagickDLLDecl int Magick::operator > ( const Magick::Coordinate& left_, 00031 const Magick::Coordinate& right_ ) 00032 { 00033 return ( !( left_ < right_ ) && ( left_ != right_ ) ); 00034 } 00035 MagickDLLDecl int Magick::operator < ( const Magick::Coordinate& left_, 00036 const Magick::Coordinate& right_ ) 00037 { 00038 // Based on distance from origin 00039 return ( (sqrt(left_.x()*left_.x() + left_.y()*left_.y())) < 00040 (sqrt(right_.x()*right_.x() + right_.y()*right_.y())) ); 00041 } 00042 MagickDLLDecl int Magick::operator >= ( const Magick::Coordinate& left_, 00043 const Magick::Coordinate& right_ ) 00044 { 00045 return ( ( left_ > right_ ) || ( left_ == right_ ) ); 00046 } 00047 MagickDLLDecl int Magick::operator <= ( const Magick::Coordinate& left_, 00048 const Magick::Coordinate& right_ ) 00049 { 00050 return ( ( left_ < right_ ) || ( left_ == right_ ) ); 00051 } 00052 00053 /*virtual*/ 00054 Magick::DrawableBase::~DrawableBase ( void ) 00055 { 00056 } 00057 00058 // Constructor 00059 Magick::Drawable::Drawable ( void ) 00060 : dp(0) 00061 { 00062 } 00063 00064 // Construct from DrawableBase 00065 Magick::Drawable::Drawable ( const Magick::DrawableBase& original_ ) 00066 : dp(original_.copy()) 00067 { 00068 } 00069 00070 // Destructor 00071 Magick::Drawable::~Drawable ( void ) 00072 { 00073 delete dp; 00074 dp = 0; 00075 } 00076 00077 // Copy constructor 00078 Magick::Drawable::Drawable ( const Magick::Drawable& original_ ) 00079 : dp(original_.dp? original_.dp->copy(): 0) 00080 { 00081 } 00082 00083 // Assignment operator 00084 Magick::Drawable& Magick::Drawable::operator= (const Magick::Drawable& original_ ) 00085 { 00086 if (this != &original_) 00087 { 00088 DrawableBase* temp_dp = (original_.dp ? original_.dp->copy() : 0); 00089 delete dp; 00090 dp = temp_dp; 00091 } 00092 return *this; 00093 } 00094 00095 // Operator to invoke contained object 00096 void Magick::Drawable::operator()( MagickLib::DrawContext context_ ) const 00097 { 00098 if(dp) 00099 dp->operator()( context_ ); 00100 } 00101 00102 MagickDLLDecl int Magick::operator == ( const Magick::Drawable& /*left_*/, 00103 const Magick::Drawable& /*right_*/ ) 00104 { 00105 return ( 1 ); 00106 } 00107 MagickDLLDecl int Magick::operator != ( const Magick::Drawable& /*left_*/, 00108 const Magick::Drawable& /*right_*/ ) 00109 { 00110 return ( 0 ); 00111 } 00112 MagickDLLDecl int Magick::operator > ( const Magick::Drawable& /*left_*/, 00113 const Magick::Drawable& /*right_*/ ) 00114 { 00115 return ( 0 ); 00116 } 00117 MagickDLLDecl int Magick::operator < ( const Magick::Drawable& /*left_*/, 00118 const Magick::Drawable& /*right_*/ ) 00119 { 00120 return ( 0 ); 00121 } 00122 MagickDLLDecl int Magick::operator >= ( const Magick::Drawable& left_, 00123 const Magick::Drawable& right_ ) 00124 { 00125 return ( ( left_ > right_ ) || ( left_ == right_ ) ); 00126 } 00127 MagickDLLDecl int Magick::operator <= ( const Magick::Drawable& left_, 00128 const Magick::Drawable& right_ ) 00129 { 00130 return ( ( left_ < right_ ) || ( left_ == right_ ) ); 00131 } 00132 00133 /*virtual*/ 00134 Magick::VPathBase::~VPathBase ( void ) 00135 { 00136 } 00137 00138 // Constructor 00139 Magick::VPath::VPath ( void ) 00140 : dp(0) 00141 { 00142 } 00143 00144 // Construct from VPathBase 00145 Magick::VPath::VPath ( const Magick::VPathBase& original_ ) 00146 : dp(original_.copy()) 00147 { 00148 } 00149 00150 // Destructor 00151 /* virtual */ Magick::VPath::~VPath ( void ) 00152 { 00153 delete dp; 00154 dp = 0; 00155 } 00156 00157 // Copy constructor 00158 Magick::VPath::VPath ( const Magick::VPath& original_ ) 00159 : dp(original_.dp? original_.dp->copy(): 0) 00160 { 00161 } 00162 00163 // Assignment operator 00164 Magick::VPath& Magick::VPath::operator= (const Magick::VPath& original_ ) 00165 { 00166 if (this != &original_) 00167 { 00168 VPathBase* temp_dp = (original_.dp ? original_.dp->copy() : 0); 00169 delete dp; 00170 dp = temp_dp; 00171 } 00172 return *this; 00173 } 00174 00175 // Operator to invoke contained object 00176 void Magick::VPath::operator()( MagickLib::DrawContext context_ ) const 00177 { 00178 if(dp) 00179 dp->operator()( context_ ); 00180 } 00181 00182 MagickDLLDecl int Magick::operator == ( const Magick::VPath& /*left_*/, 00183 const Magick::VPath& /*right_*/ ) 00184 { 00185 return ( 1 ); 00186 } 00187 MagickDLLDecl int Magick::operator != ( const Magick::VPath& /*left_*/, 00188 const Magick::VPath& /*right_*/ ) 00189 { 00190 return ( 0 ); 00191 } 00192 MagickDLLDecl int Magick::operator > ( const Magick::VPath& /*left_*/, 00193 const Magick::VPath& /*right_*/ ) 00194 { 00195 return ( 0 ); 00196 } 00197 MagickDLLDecl int Magick::operator < ( const Magick::VPath& /*left_*/, 00198 const Magick::VPath& /*right_*/ ) 00199 { 00200 return ( 0 ); 00201 } 00202 MagickDLLDecl int Magick::operator >= ( const Magick::VPath& left_, 00203 const Magick::VPath& right_ ) 00204 { 00205 return ( ( left_ > right_ ) || ( left_ == right_ ) ); 00206 } 00207 MagickDLLDecl int Magick::operator <= ( const Magick::VPath& left_, 00208 const Magick::VPath& right_ ) 00209 { 00210 return ( ( left_ < right_ ) || ( left_ == right_ ) ); 00211 } 00212 00213 // 00214 // Drawable Objects 00215 // 00216 00217 // Affine (scaling, rotation, and translation) 00218 Magick::DrawableAffine::DrawableAffine( double sx_, double sy_, 00219 double rx_, double ry_, 00220 double tx_, double ty_ ) 00221 { 00222 _affine.sx = sx_; 00223 _affine.rx = rx_; 00224 _affine.ry = ry_; 00225 _affine.sy = sy_; 00226 _affine.tx = tx_; 00227 _affine.ty = ty_; 00228 } 00229 Magick::DrawableAffine::DrawableAffine( void ) 00230 { 00231 IdentityAffine(&_affine); 00232 } 00233 Magick::DrawableAffine::~DrawableAffine( void ) 00234 { 00235 } 00236 void Magick::DrawableAffine::operator()( MagickLib::DrawContext context_ ) const 00237 { 00238 DrawAffine( context_, &_affine ); 00239 } 00240 Magick::DrawableBase* Magick::DrawableAffine::copy() const 00241 { 00242 return new DrawableAffine(*this); 00243 } 00244 00245 // Arc 00246 Magick::DrawableArc::~DrawableArc( void ) 00247 { 00248 } 00249 void Magick::DrawableArc::operator()( MagickLib::DrawContext context_ ) const 00250 { 00251 DrawArc( context_, _startX, _startY, _endX, _endY, _startDegrees, _endDegrees ); 00252 } 00253 Magick::DrawableBase* Magick::DrawableArc::copy() const 00254 { 00255 return new DrawableArc(*this); 00256 } 00257 00258 // 00259 // Bezier curve 00260 // 00261 // Construct from coordinates (Coordinate list must contain at least three members) 00262 Magick::DrawableBezier::DrawableBezier ( const CoordinateList &coordinates_ ) 00263 : _coordinates(coordinates_) 00264 { 00265 } 00266 // Copy constructor 00267 Magick::DrawableBezier::DrawableBezier( const Magick::DrawableBezier& original_ ) 00268 : DrawableBase (original_), 00269 _coordinates(original_._coordinates) 00270 { 00271 } 00272 // Destructor 00273 Magick::DrawableBezier::~DrawableBezier( void ) 00274 { 00275 } 00276 void Magick::DrawableBezier::operator()( MagickLib::DrawContext context_ ) const 00277 { 00278 size_t num_coords = _coordinates.size(); 00279 PointInfo *coordinates = new PointInfo[num_coords]; 00280 00281 PointInfo *q = coordinates; 00282 CoordinateList::const_iterator p = _coordinates.begin(); 00283 00284 while( p != _coordinates.end() ) 00285 { 00286 q->x = p->x(); 00287 q->y = p->y(); 00288 q++; 00289 p++; 00290 } 00291 00292 DrawBezier( context_, num_coords, coordinates ); 00293 delete [] coordinates; 00294 } 00295 Magick::DrawableBase* Magick::DrawableBezier::copy() const 00296 { 00297 return new DrawableBezier(*this); 00298 } 00299 00300 // 00301 //Clip Path 00302 // 00303 00304 // Pop (terminate) Clip path definition 00305 Magick::DrawablePopClipPath::~DrawablePopClipPath ( void ) 00306 { 00307 } 00308 void Magick::DrawablePopClipPath::operator() ( MagickLib::DrawContext context_ ) const 00309 { 00310 DrawPopClipPath( context_ ); 00311 DrawPopDefs(context_); 00312 } 00313 Magick::DrawableBase* Magick::DrawablePopClipPath::copy() const 00314 { 00315 return new DrawablePopClipPath(*this); 00316 } 00317 00318 // Push clip path definition 00319 Magick::DrawablePushClipPath::DrawablePushClipPath( const std::string &id_) 00320 : _id(id_.c_str()) //multithread safe const char* 00321 { 00322 } 00323 Magick::DrawablePushClipPath::DrawablePushClipPath 00324 ( const Magick::DrawablePushClipPath& original_ ) //multithread safe const char* 00325 : DrawableBase (original_), 00326 _id(original_._id.c_str()) 00327 { 00328 } 00329 Magick::DrawablePushClipPath::~DrawablePushClipPath( void ) 00330 { 00331 } 00332 void Magick::DrawablePushClipPath::operator() 00333 ( MagickLib::DrawContext context_ ) const 00334 { 00335 DrawPushDefs(context_); 00336 DrawPushClipPath( context_, _id.c_str()); 00337 } 00338 Magick::DrawableBase* Magick::DrawablePushClipPath::copy() const 00339 { 00340 return new DrawablePushClipPath(*this); 00341 } 00342 // 00343 // ClipPath 00344 // 00345 Magick::DrawableClipPath::DrawableClipPath( const std::string &id_ ) 00346 :_id(id_.c_str()) 00347 { 00348 } 00349 00350 Magick::DrawableClipPath::DrawableClipPath ( const Magick::DrawableClipPath& original_ ) 00351 : DrawableBase (original_), 00352 _id(original_._id.c_str()) 00353 { 00354 } 00355 Magick::DrawableClipPath::~DrawableClipPath( void ) 00356 { 00357 } 00358 void Magick::DrawableClipPath::operator()( MagickLib::DrawContext context_ ) const 00359 { 00360 (void) DrawSetClipPath( context_, _id.c_str()); 00361 } 00362 Magick::DrawableBase* Magick::DrawableClipPath::copy() const 00363 { 00364 return new DrawableClipPath(*this); 00365 } 00366 00367 // Circle 00368 Magick::DrawableCircle::~DrawableCircle ( void ) 00369 { 00370 } 00371 void Magick::DrawableCircle::operator()( MagickLib::DrawContext context_ ) const 00372 { 00373 DrawCircle( context_, _originX, _originY, _perimX, _perimY ); 00374 } 00375 Magick::DrawableBase* Magick::DrawableCircle::copy() const 00376 { 00377 return new DrawableCircle(*this); 00378 } 00379 00380 // Colorize at point using PaintMethod 00381 Magick::DrawableColor::~DrawableColor( void ) 00382 { 00383 } 00384 void Magick::DrawableColor::operator()( MagickLib::DrawContext context_ ) const 00385 { 00386 DrawColor( context_, _x, _y, _paintMethod ); 00387 } 00388 Magick::DrawableBase* Magick::DrawableColor::copy() const 00389 { 00390 return new DrawableColor(*this); 00391 } 00392 00393 // Draw image at point 00394 Magick::DrawableCompositeImage::DrawableCompositeImage 00395 ( double x_, double y_, 00396 double width_, double height_, 00397 const std::string &filename_, 00398 Magick::CompositeOperator composition_ ) 00399 : _composition(composition_), 00400 _x(x_), 00401 _y(y_), 00402 _width(width_), 00403 _height(height_), 00404 _image(new Image(filename_)) 00405 { 00406 } 00407 Magick::DrawableCompositeImage::DrawableCompositeImage 00408 ( double x_, double y_, 00409 double width_, double height_, 00410 const Magick::Image &image_, 00411 Magick::CompositeOperator composition_ ) 00412 : _composition(composition_), 00413 _x(x_), 00414 _y(y_), 00415 _width(width_), 00416 _height(height_), 00417 _image(new Image(image_)) 00418 { 00419 } 00420 Magick::DrawableCompositeImage::DrawableCompositeImage 00421 ( double x_, double y_, 00422 double width_, double height_, 00423 const std::string &filename_ ) 00424 :_composition(CopyCompositeOp), 00425 _x(x_), 00426 _y(y_), 00427 _width(width_), 00428 _height(height_), 00429 _image(new Image(filename_)) 00430 { 00431 } 00432 Magick::DrawableCompositeImage::DrawableCompositeImage 00433 ( double x_, double y_, 00434 double width_, double height_, 00435 const Magick::Image &image_ ) 00436 :_composition(CopyCompositeOp), 00437 _x(x_), 00438 _y(y_), 00439 _width(width_), 00440 _height(height_), 00441 _image(new Image(image_)) 00442 { 00443 } 00444 Magick::DrawableCompositeImage::DrawableCompositeImage 00445 ( double x_, double y_, 00446 const std::string &filename_ ) 00447 : _composition(CopyCompositeOp), 00448 _x(x_), 00449 _y(y_), 00450 _width(0), 00451 _height(0), 00452 _image(new Image(filename_)) 00453 { 00454 _width=_image->columns(); 00455 _height=_image->rows(); 00456 } 00457 Magick::DrawableCompositeImage::DrawableCompositeImage 00458 ( double x_, double y_, 00459 const Magick::Image &image_ ) 00460 : _composition(CopyCompositeOp), 00461 _x(x_), 00462 _y(y_), 00463 _width(0), 00464 _height(0), 00465 _image(new Image(image_)) 00466 { 00467 _width=_image->columns(); 00468 _height=_image->rows(); 00469 } 00470 // Copy constructor 00471 Magick::DrawableCompositeImage::DrawableCompositeImage 00472 ( const Magick::DrawableCompositeImage& original_ ) 00473 : Magick::DrawableBase(original_), 00474 _composition(original_._composition), 00475 _x(original_._x), 00476 _y(original_._y), 00477 _width(original_._width), 00478 _height(original_._height), 00479 _image(new Image(*original_._image)) 00480 { 00481 } 00482 Magick::DrawableCompositeImage::~DrawableCompositeImage( void ) 00483 { 00484 delete _image; 00485 } 00486 // Assignment operator 00487 Magick::DrawableCompositeImage& Magick::DrawableCompositeImage::operator= 00488 (const Magick::DrawableCompositeImage& original_ ) 00489 { 00490 // If not being set to ourself 00491 if ( this != &original_ ) 00492 { 00493 _composition = original_._composition; 00494 _x = original_._x; 00495 _y = original_._y; 00496 _width = original_._width; 00497 _height = original_._height; 00498 Image* temp_image = new Image(*original_._image); 00499 delete _image; 00500 _image = temp_image; 00501 } 00502 return *this; 00503 } 00504 void Magick::DrawableCompositeImage::filename( const std::string &filename_ ) 00505 { 00506 Image* temp_image = new Image(filename_); 00507 delete _image; 00508 _image = temp_image; 00509 } 00510 std::string Magick::DrawableCompositeImage::filename( void ) const 00511 { 00512 return _image->fileName(); 00513 } 00514 00515 void Magick::DrawableCompositeImage::image( const Magick::Image &image_ ) 00516 { 00517 Image* temp_image = new Image(image_); 00518 delete _image; 00519 _image = temp_image; 00520 } 00521 Magick::Image Magick::DrawableCompositeImage::image( void ) const 00522 { 00523 return *_image; 00524 } 00525 00526 // Specify image format used to output Base64 inlined image data. 00527 void Magick::DrawableCompositeImage::magick( std::string magick_ ) 00528 { 00529 _image->magick( magick_ ); 00530 } 00531 std::string Magick::DrawableCompositeImage::magick( void ) 00532 { 00533 return _image->magick(); 00534 } 00535 00536 void Magick::DrawableCompositeImage::operator() 00537 ( MagickLib::DrawContext context_ ) const 00538 { 00539 MagickWand 00540 *magick_wand; 00541 00542 magick_wand=NewMagickWandFromImage(_image->constImage()); 00543 (void) DrawComposite( context_, _composition, _x, _y, _width, _height, 00544 magick_wand ); 00545 magick_wand=DestroyMagickWand(magick_wand); 00546 } 00547 00548 Magick::DrawableBase* Magick::DrawableCompositeImage::copy() const 00549 { 00550 return new DrawableCompositeImage(*this); 00551 } 00552 00553 // Ellipse 00554 Magick::DrawableEllipse::~DrawableEllipse( void ) 00555 { 00556 } 00557 void Magick::DrawableEllipse::operator() 00558 ( MagickLib::DrawContext context_ ) const 00559 { 00560 DrawEllipse( context_, _originX, _originY, _radiusX, _radiusY, 00561 _arcStart, _arcEnd ); 00562 } 00563 Magick::DrawableBase* Magick::DrawableEllipse::copy() const 00564 { 00565 return new DrawableEllipse(*this); 00566 } 00567 00568 // Specify drawing fill color 00569 Magick::DrawableFillColor::DrawableFillColor( const Magick::Color &color_ ) 00570 : _color(color_) 00571 { 00572 } 00573 Magick::DrawableFillColor::DrawableFillColor 00574 ( const Magick::DrawableFillColor& original_ ) 00575 : DrawableBase (original_), 00576 _color(original_._color) 00577 { 00578 } 00579 Magick::DrawableFillColor::~DrawableFillColor( void ) 00580 { 00581 } 00582 void Magick::DrawableFillColor::operator() 00583 ( MagickLib::DrawContext context_ ) const 00584 { 00585 PixelPacket color = static_cast<PixelPacket>(_color); 00586 PixelWand *pixel_wand=NewPixelWand(); 00587 PixelSetQuantumColor(pixel_wand,&color); 00588 DrawSetFillColor(context_,pixel_wand); 00589 pixel_wand=DestroyPixelWand(pixel_wand); 00590 } 00591 Magick::DrawableBase* Magick::DrawableFillColor::copy() const 00592 { 00593 return new DrawableFillColor(*this); 00594 } 00595 00596 // Specify drawing fill fule 00597 Magick::DrawableFillRule::~DrawableFillRule ( void ) 00598 { 00599 } 00600 void Magick::DrawableFillRule::operator() 00601 ( MagickLib::DrawContext context_ ) const 00602 { 00603 DrawSetFillRule( context_, _fillRule ); 00604 } 00605 Magick::DrawableBase* Magick::DrawableFillRule::copy() const 00606 { 00607 return new DrawableFillRule(*this); 00608 } 00609 00610 // Specify drawing fill opacity 00611 Magick::DrawableFillOpacity::~DrawableFillOpacity ( void ) 00612 { 00613 } 00614 void Magick::DrawableFillOpacity::operator() 00615 ( MagickLib::DrawContext context_ ) const 00616 { 00617 DrawSetFillAlpha( context_, _opacity ); 00618 } 00619 Magick::DrawableBase* Magick::DrawableFillOpacity::copy() const 00620 { 00621 return new DrawableFillOpacity(*this); 00622 } 00623 00624 // Specify text font 00625 Magick::DrawableFont::DrawableFont ( const std::string &font_ ) 00626 : _font(font_), 00627 _family(), 00628 _style(Magick::AnyStyle), 00629 _weight(400), 00630 _stretch(Magick::NormalStretch) 00631 { 00632 } 00633 Magick::DrawableFont::DrawableFont ( const std::string &family_, 00634 Magick::StyleType style_, 00635 const unsigned long weight_, 00636 Magick::StretchType stretch_ ) 00637 : _font(), 00638 _family(family_), 00639 _style(style_), 00640 _weight(weight_), 00641 _stretch(stretch_) 00642 { 00643 } 00644 Magick::DrawableFont::DrawableFont ( const Magick::DrawableFont& original_ ) 00645 : DrawableBase (original_), 00646 _font(original_._font), 00647 _family(original_._family), 00648 _style(original_._style), 00649 _weight(original_._weight), 00650 _stretch(original_._stretch) 00651 { 00652 } 00653 Magick::DrawableFont::~DrawableFont ( void ) 00654 { 00655 } 00656 void Magick::DrawableFont::operator()( MagickLib::DrawContext context_ ) const 00657 { 00658 // font 00659 if(_font.length()) 00660 { 00661 (void) DrawSetFont( context_, _font.c_str() ); 00662 } 00663 00664 if(_family.length()) 00665 { 00666 // font-family 00667 (void) DrawSetFontFamily( context_, _family.c_str() ); 00668 00669 // font-style 00670 DrawSetFontStyle( context_, _style ); 00671 00672 // font-weight 00673 DrawSetFontWeight( context_, _weight ); 00674 00675 // font-stretch 00676 DrawSetFontStretch( context_, _stretch ); 00677 } 00678 } 00679 Magick::DrawableBase* Magick::DrawableFont::copy() const 00680 { 00681 return new DrawableFont(*this); 00682 } 00683 00684 // Specify text positioning gravity 00685 Magick::DrawableGravity::~DrawableGravity ( void ) 00686 { 00687 } 00688 void Magick::DrawableGravity::operator() 00689 ( MagickLib::DrawContext context_ ) const 00690 { 00691 DrawSetGravity( context_, _gravity ); 00692 } 00693 Magick::DrawableBase* Magick::DrawableGravity::copy() const 00694 { 00695 return new DrawableGravity(*this); 00696 } 00697 00698 // Line 00699 Magick::DrawableLine::~DrawableLine ( void ) 00700 { 00701 } 00702 void Magick::DrawableLine::operator()( MagickLib::DrawContext context_ ) const 00703 { 00704 DrawLine( context_, _startX, _startY, _endX, _endY ); 00705 } 00706 Magick::DrawableBase* Magick::DrawableLine::copy() const 00707 { 00708 return new DrawableLine(*this); 00709 } 00710 00711 // Change pixel matte value to transparent using PaintMethod 00712 Magick::DrawableMatte::~DrawableMatte ( void ) 00713 { 00714 } 00715 void Magick::DrawableMatte::operator()( MagickLib::DrawContext context_ ) const 00716 { 00717 DrawMatte( context_, _x, _y, _paintMethod ); 00718 } 00719 Magick::DrawableBase* Magick::DrawableMatte::copy() const 00720 { 00721 return new DrawableMatte(*this); 00722 } 00723 00724 // Drawable Path 00725 Magick::DrawablePath::DrawablePath ( const VPathList &path_ ) 00726 : _path(path_) 00727 { 00728 } 00729 Magick::DrawablePath::DrawablePath ( const Magick::DrawablePath& original_ ) 00730 : DrawableBase (original_), 00731 _path(original_._path) 00732 { 00733 } 00734 Magick::DrawablePath::~DrawablePath ( void ) 00735 { 00736 } 00737 void Magick::DrawablePath::operator()( MagickLib::DrawContext context_ ) const 00738 { 00739 DrawPathStart( context_ ); 00740 00741 for( VPathList::const_iterator p = _path.begin(); 00742 p != _path.end(); p++ ) 00743 p->operator()( context_ ); // FIXME, how to quit loop on error? 00744 00745 DrawPathFinish( context_ ); 00746 } 00747 Magick::DrawableBase* Magick::DrawablePath::copy() const 00748 { 00749 return new DrawablePath(*this); 00750 } 00751 00752 // Point 00753 Magick::DrawablePoint::~DrawablePoint ( void ) 00754 { 00755 } 00756 void Magick::DrawablePoint::operator()( MagickLib::DrawContext context_ ) const 00757 { 00758 DrawPoint( context_, _x, _y ); 00759 } 00760 Magick::DrawableBase* Magick::DrawablePoint::copy() const 00761 { 00762 return new DrawablePoint(*this); 00763 } 00764 00765 // Text pointsize 00766 Magick::DrawablePointSize::~DrawablePointSize ( void ) 00767 { 00768 } 00769 void Magick::DrawablePointSize::operator() 00770 ( MagickLib::DrawContext context_ ) const 00771 { 00772 DrawSetFontSize( context_, _pointSize ); 00773 } 00774 Magick::DrawableBase* Magick::DrawablePointSize::copy() const 00775 { 00776 return new DrawablePointSize(*this); 00777 } 00778 00779 // Polygon (Coordinate list must contain at least three members) 00780 Magick::DrawablePolygon::DrawablePolygon ( const CoordinateList &coordinates_ ) 00781 : _coordinates(coordinates_) 00782 { 00783 } 00784 Magick::DrawablePolygon::DrawablePolygon 00785 ( const Magick::DrawablePolygon& original_ ) 00786 : DrawableBase (original_), 00787 _coordinates(original_._coordinates) 00788 { 00789 } 00790 Magick::DrawablePolygon::~DrawablePolygon ( void ) 00791 { 00792 } 00793 void Magick::DrawablePolygon::operator() 00794 ( MagickLib::DrawContext context_ ) const 00795 { 00796 size_t num_coords = _coordinates.size(); 00797 PointInfo *coordinates = new PointInfo[num_coords]; 00798 00799 PointInfo *q = coordinates; 00800 CoordinateList::const_iterator p = _coordinates.begin(); 00801 00802 while( p != _coordinates.end() ) 00803 { 00804 q->x = p->x(); 00805 q->y = p->y(); 00806 q++; 00807 p++; 00808 } 00809 00810 DrawPolygon( context_, num_coords, coordinates ); 00811 delete [] coordinates; 00812 } 00813 Magick::DrawableBase* Magick::DrawablePolygon::copy() const 00814 { 00815 return new DrawablePolygon(*this); 00816 } 00817 00818 // Polyline (Coordinate list must contain at least three members) 00819 Magick::DrawablePolyline::DrawablePolyline 00820 ( const CoordinateList &coordinates_ ) 00821 : _coordinates(coordinates_) 00822 { 00823 } 00824 Magick::DrawablePolyline::DrawablePolyline 00825 ( const Magick::DrawablePolyline& original_ ) 00826 : DrawableBase (original_), 00827 _coordinates(original_._coordinates) 00828 { 00829 } 00830 Magick::DrawablePolyline::~DrawablePolyline ( void ) 00831 { 00832 } 00833 void Magick::DrawablePolyline::operator() 00834 ( MagickLib::DrawContext context_ ) const 00835 { 00836 size_t num_coords = _coordinates.size(); 00837 PointInfo *coordinates = new PointInfo[num_coords]; 00838 00839 PointInfo *q = coordinates; 00840 CoordinateList::const_iterator p = _coordinates.begin(); 00841 00842 while( p != _coordinates.end() ) 00843 { 00844 q->x = p->x(); 00845 q->y = p->y(); 00846 q++; 00847 p++; 00848 } 00849 00850 DrawPolyline( context_, num_coords, coordinates ); 00851 delete [] coordinates; 00852 } 00853 Magick::DrawableBase* Magick::DrawablePolyline::copy() const 00854 { 00855 return new DrawablePolyline(*this); 00856 } 00857 00858 // Pop Graphic Context 00859 Magick::DrawablePopGraphicContext::~DrawablePopGraphicContext ( void ) 00860 { 00861 } 00862 void Magick::DrawablePopGraphicContext::operator() 00863 ( MagickLib::DrawContext context_ ) const 00864 { 00865 DrawPopGraphicContext( context_ ); 00866 } 00867 Magick::DrawableBase* Magick::DrawablePopGraphicContext::copy() const 00868 { 00869 return new DrawablePopGraphicContext(*this); 00870 } 00871 00872 // Push Graphic Context 00873 Magick::DrawablePushGraphicContext::~DrawablePushGraphicContext ( void ) 00874 { 00875 } 00876 void Magick::DrawablePushGraphicContext::operator() 00877 ( MagickLib::DrawContext context_ ) const 00878 { 00879 DrawPushGraphicContext( context_ ); 00880 } 00881 Magick::DrawableBase* Magick::DrawablePushGraphicContext::copy() const 00882 { 00883 return new DrawablePushGraphicContext(*this); 00884 } 00885 00886 // Pop (terminate) Pattern definition 00887 Magick::DrawablePopPattern::~DrawablePopPattern ( void ) 00888 { 00889 } 00890 void Magick::DrawablePopPattern::operator() 00891 ( MagickLib::DrawContext context_ ) const 00892 { 00893 (void) DrawPopPattern( context_ ); 00894 } 00895 Magick::DrawableBase* Magick::DrawablePopPattern::copy() const 00896 { 00897 return new DrawablePopPattern(*this); 00898 } 00899 00900 // Push Pattern definition 00901 Magick::DrawablePushPattern::DrawablePushPattern 00902 ( const std::string &id_, long x_, long y_, 00903 long width_, long height_ ) 00904 : _id(id_), 00905 _x(x_), 00906 _y(y_), 00907 _width(width_), 00908 _height(height_) 00909 { 00910 } 00911 Magick::DrawablePushPattern::DrawablePushPattern 00912 ( const Magick::DrawablePushPattern& original_ ) 00913 : DrawableBase (original_), 00914 _id(original_._id), 00915 _x(original_._x), 00916 _y(original_._y), 00917 _width(original_._width), 00918 _height(original_._height) 00919 { 00920 } 00921 Magick::DrawablePushPattern::~DrawablePushPattern ( void ) 00922 { 00923 } 00924 void Magick::DrawablePushPattern::operator() 00925 ( MagickLib::DrawContext context_ ) const 00926 { 00927 (void) DrawPushPattern( context_, _id.c_str(), _x, _y, _width, _height ); 00928 } 00929 Magick::DrawableBase* Magick::DrawablePushPattern::copy() const 00930 { 00931 return new DrawablePushPattern(*this); 00932 } 00933 00934 // Rectangle 00935 Magick::DrawableRectangle::~DrawableRectangle ( void ) 00936 { 00937 } 00938 void Magick::DrawableRectangle::operator() 00939 ( MagickLib::DrawContext context_ ) const 00940 { 00941 DrawRectangle( context_, _upperLeftX, _upperLeftY, 00942 _lowerRightX, _lowerRightY ); 00943 } 00944 Magick::DrawableBase* Magick::DrawableRectangle::copy() const 00945 { 00946 return new DrawableRectangle(*this); 00947 } 00948 00949 // Apply Rotation 00950 Magick::DrawableRotation::~DrawableRotation ( void ) 00951 { 00952 } 00953 void Magick::DrawableRotation::operator() 00954 ( MagickLib::DrawContext context_ ) const 00955 { 00956 DrawRotate( context_, _angle ); 00957 } 00958 Magick::DrawableBase* Magick::DrawableRotation::copy() const 00959 { 00960 return new DrawableRotation(*this); 00961 } 00962 00963 // Round Rectangle 00964 Magick::DrawableRoundRectangle::~DrawableRoundRectangle ( void ) 00965 { 00966 } 00967 void Magick::DrawableRoundRectangle::operator() 00968 ( MagickLib::DrawContext context_ ) const 00969 { 00970 DrawRoundRectangle( context_, _centerX,_centerY, _width,_hight, 00971 _cornerWidth, _cornerHeight); 00972 } 00973 Magick::DrawableBase* Magick::DrawableRoundRectangle::copy() const 00974 { 00975 return new DrawableRoundRectangle(*this); 00976 } 00977 00978 // Apply Scaling 00979 Magick::DrawableScaling::~DrawableScaling ( void ) 00980 { 00981 } 00982 void Magick::DrawableScaling::operator() 00983 ( MagickLib::DrawContext context_ ) const 00984 { 00985 DrawScale( context_, _x, _y ); 00986 } 00987 Magick::DrawableBase* Magick::DrawableScaling::copy() const 00988 { 00989 return new DrawableScaling(*this); 00990 } 00991 00992 // Apply Skew in the X direction 00993 Magick::DrawableSkewX::~DrawableSkewX ( void ) 00994 { 00995 } 00996 void Magick::DrawableSkewX::operator() 00997 ( MagickLib::DrawContext context_ ) const 00998 { 00999 DrawSkewX( context_, _angle ); 01000 } 01001 Magick::DrawableBase* Magick::DrawableSkewX::copy() const 01002 { 01003 return new DrawableSkewX(*this); 01004 } 01005 01006 // Apply Skew in the Y direction 01007 Magick::DrawableSkewY::~DrawableSkewY ( void ) 01008 { 01009 } 01010 void Magick::DrawableSkewY::operator()( MagickLib::DrawContext context_ ) const 01011 { 01012 DrawSkewY( context_, _angle ); 01013 } 01014 Magick::DrawableBase* Magick::DrawableSkewY::copy() const 01015 { 01016 return new DrawableSkewY(*this); 01017 } 01018 01019 // Stroke dasharray 01020 Magick::DrawableDashArray::DrawableDashArray( const double* dasharray_ ) 01021 : _size(0), 01022 _dasharray(0) 01023 { 01024 dasharray( dasharray_ ); 01025 } 01026 // Deprecated, do not use for new code, and migrate existing code to 01027 // using double* 01028 Magick::DrawableDashArray::DrawableDashArray( const unsigned int* dasharray_ ) 01029 : _size(0), 01030 _dasharray(0) 01031 { 01032 dasharray( dasharray_ ); 01033 } 01034 Magick::DrawableDashArray::DrawableDashArray 01035 (const Magick::DrawableDashArray& original_) 01036 : DrawableBase (original_), 01037 _size(0), 01038 _dasharray(0) 01039 { 01040 dasharray( original_._dasharray ); 01041 } 01042 Magick::DrawableDashArray::~DrawableDashArray( void ) 01043 { 01044 delete _dasharray; 01045 _size = 0; 01046 _dasharray = 0; 01047 } 01048 Magick::DrawableDashArray& Magick::DrawableDashArray::operator= 01049 (const Magick::DrawableDashArray &original_) 01050 { 01051 if( this != &original_ ) 01052 { 01053 dasharray( original_._dasharray ); 01054 } 01055 return *this; 01056 } 01057 void Magick::DrawableDashArray::operator() 01058 ( MagickLib::DrawContext context_ ) const 01059 { 01060 (void) DrawSetStrokeDashArray( context_, _size, _dasharray ); 01061 } 01062 Magick::DrawableBase* Magick::DrawableDashArray::copy() const 01063 { 01064 return new DrawableDashArray(*this); 01065 } 01066 void Magick::DrawableDashArray::dasharray ( const double* dasharray_ ) 01067 { 01068 _dasharray=(double *) RelinquishMagickMemory(_dasharray); 01069 01070 if(dasharray_) 01071 { 01072 // Count elements in dash array 01073 unsigned int n = 0; 01074 { 01075 const double *p = dasharray_; 01076 while(*p++ != 0) 01077 n++; 01078 } 01079 _size = n; 01080 01081 // Allocate elements 01082 _dasharray=static_cast<double*>(AcquireMagickMemory((n+1)*sizeof(double))); 01083 // Copy elements 01084 { 01085 double *q = _dasharray; 01086 const double *p = dasharray_; 01087 while( *p ) 01088 *q++=*p++; 01089 *q=0; 01090 } 01091 } 01092 } 01093 // This method is deprecated. Don't use for new code, and migrate existing 01094 // code to the const double* version. 01095 void Magick::DrawableDashArray::dasharray( const unsigned int* dasharray_ ) 01096 { 01097 _dasharray=(double *) RelinquishMagickMemory(_dasharray); 01098 01099 if(dasharray_) 01100 { 01101 // Count elements in dash array 01102 unsigned int n = 0; 01103 { 01104 const unsigned int *p = dasharray_; 01105 while(*p++ != 0) 01106 n++; 01107 } 01108 _size = n; 01109 01110 // Allocate elements 01111 _dasharray=static_cast<double*>(AcquireMagickMemory((n+1)*sizeof(double))); 01112 // Copy elements 01113 { 01114 double *q = _dasharray; 01115 const unsigned int *p = dasharray_; 01116 while( *p ) 01117 *q++=static_cast<double>(*p++); 01118 *q=0; 01119 } 01120 } 01121 } 01122 01123 // Stroke dashoffset 01124 Magick::DrawableDashOffset::~DrawableDashOffset ( void ) 01125 { 01126 } 01127 void Magick::DrawableDashOffset::operator() 01128 ( MagickLib::DrawContext context_ ) const 01129 { 01130 DrawSetStrokeDashOffset( context_, _offset ); 01131 } 01132 Magick::DrawableBase* Magick::DrawableDashOffset::copy() const 01133 { 01134 return new DrawableDashOffset(*this); 01135 } 01136 01137 // Stroke linecap 01138 Magick::DrawableStrokeLineCap::~DrawableStrokeLineCap ( void ) 01139 { 01140 } 01141 void Magick::DrawableStrokeLineCap::operator() 01142 ( MagickLib::DrawContext context_ ) const 01143 { 01144 DrawSetStrokeLineCap( context_, _linecap ); 01145 } 01146 Magick::DrawableBase* Magick::DrawableStrokeLineCap::copy() const 01147 { 01148 return new DrawableStrokeLineCap(*this); 01149 } 01150 01151 // Stroke linejoin 01152 Magick::DrawableStrokeLineJoin::~DrawableStrokeLineJoin ( void ) 01153 { 01154 } 01155 void Magick::DrawableStrokeLineJoin::operator() 01156 ( MagickLib::DrawContext context_ ) const 01157 { 01158 DrawSetStrokeLineJoin( context_, _linejoin ); 01159 } 01160 Magick::DrawableBase* Magick::DrawableStrokeLineJoin::copy() const 01161 { 01162 return new DrawableStrokeLineJoin(*this); 01163 } 01164 01165 // Stroke miterlimit 01166 Magick::DrawableMiterLimit::~DrawableMiterLimit ( void ) 01167 { 01168 } 01169 void Magick::DrawableMiterLimit::operator() 01170 ( MagickLib::DrawContext context_ ) const 01171 { 01172 DrawSetStrokeMiterLimit( context_, _miterlimit ); 01173 } 01174 Magick::DrawableBase* Magick::DrawableMiterLimit::copy() const 01175 { 01176 return new DrawableMiterLimit(*this); 01177 } 01178 01179 // Stroke antialias 01180 Magick::DrawableStrokeAntialias::~DrawableStrokeAntialias ( void ) 01181 { 01182 } 01183 void Magick::DrawableStrokeAntialias::operator() 01184 ( MagickLib::DrawContext context_ ) const 01185 { 01186 DrawSetStrokeAntialias( context_, static_cast<MagickBooleanType> 01187 (_flag ? MagickTrue : MagickFalse) ); 01188 } 01189 Magick::DrawableBase* Magick::DrawableStrokeAntialias::copy() const 01190 { 01191 return new DrawableStrokeAntialias(*this); 01192 } 01193 01194 // Stroke color 01195 Magick::DrawableStrokeColor::DrawableStrokeColor 01196 ( const Magick::Color &color_ ) 01197 : _color(color_) 01198 { 01199 } 01200 Magick::DrawableStrokeColor::DrawableStrokeColor 01201 ( const Magick::DrawableStrokeColor& original_ ) 01202 : DrawableBase (original_), 01203 _color(original_._color) 01204 { 01205 } 01206 Magick::DrawableStrokeColor::~DrawableStrokeColor ( void ) 01207 { 01208 } 01209 void Magick::DrawableStrokeColor::operator() 01210 ( MagickLib::DrawContext context_ ) const 01211 { 01212 PixelPacket color = static_cast<PixelPacket>(_color); 01213 PixelWand *pixel_wand=NewPixelWand(); 01214 PixelSetQuantumColor(pixel_wand,&color); 01215 DrawSetStrokeColor(context_,pixel_wand); 01216 pixel_wand=DestroyPixelWand(pixel_wand); 01217 } 01218 Magick::DrawableBase* Magick::DrawableStrokeColor::copy() const 01219 { 01220 return new DrawableStrokeColor(*this); 01221 } 01222 01223 // Stroke opacity 01224 Magick::DrawableStrokeOpacity::~DrawableStrokeOpacity ( void ) 01225 { 01226 } 01227 void Magick::DrawableStrokeOpacity::operator() 01228 ( MagickLib::DrawContext context_ ) const 01229 { 01230 DrawSetStrokeAlpha( context_, _opacity ); 01231 } 01232 Magick::DrawableBase* Magick::DrawableStrokeOpacity::copy() const 01233 { 01234 return new DrawableStrokeOpacity(*this); 01235 } 01236 01237 // Stroke width 01238 Magick::DrawableStrokeWidth::~DrawableStrokeWidth ( void ) 01239 { 01240 } 01241 void Magick::DrawableStrokeWidth::operator() 01242 ( MagickLib::DrawContext context_ ) const 01243 { 01244 DrawSetStrokeWidth( context_, _width ); 01245 } 01246 Magick::DrawableBase* Magick::DrawableStrokeWidth::copy() const 01247 { 01248 return new DrawableStrokeWidth(*this); 01249 } 01250 01251 // Draw text at point 01252 Magick::DrawableText::DrawableText ( const double x_, const double y_, 01253 const std::string &text_ ) 01254 : _x(x_), 01255 _y(y_), 01256 _text(text_), 01257 _encoding() 01258 { 01259 } 01260 Magick::DrawableText::DrawableText ( const double x_, const double y_, 01261 const std::string &text_, const std::string &encoding_) 01262 : _x(x_), 01263 _y(y_), 01264 _text(text_), 01265 _encoding(encoding_) 01266 { 01267 } 01268 Magick::DrawableText::DrawableText( const Magick::DrawableText& original_ ) 01269 : DrawableBase (original_), 01270 _x(original_._x), 01271 _y(original_._y), 01272 _text(original_._text), 01273 _encoding(original_._encoding) 01274 { 01275 } 01276 Magick::DrawableText::~DrawableText ( void ) 01277 { 01278 } 01279 void Magick::DrawableText::operator() 01280 ( MagickLib::DrawContext context_ ) const 01281 { 01282 DrawSetTextEncoding( context_, _encoding.c_str() ); 01283 DrawAnnotation( context_, _x, _y, 01284 reinterpret_cast<const unsigned char*>(_text.c_str()) ); 01285 } 01286 Magick::DrawableBase* Magick::DrawableText::copy() const 01287 { 01288 return new DrawableText(*this); 01289 } 01290 01291 // Text antialias 01292 Magick::DrawableTextAntialias::DrawableTextAntialias ( bool flag_ ) 01293 : _flag(flag_) 01294 { 01295 } 01296 Magick::DrawableTextAntialias::DrawableTextAntialias( const Magick::DrawableTextAntialias &original_ ) 01297 : DrawableBase (original_), 01298 _flag(original_._flag) 01299 { 01300 } 01301 Magick::DrawableTextAntialias::~DrawableTextAntialias ( void ) 01302 { 01303 } 01304 void Magick::DrawableTextAntialias::operator() 01305 ( MagickLib::DrawContext context_ ) const 01306 { 01307 DrawSetTextAntialias( context_, static_cast<MagickBooleanType> 01308 (_flag ? MagickTrue : MagickFalse) ); 01309 } 01310 Magick::DrawableBase* Magick::DrawableTextAntialias::copy() const 01311 { 01312 return new DrawableTextAntialias(*this); 01313 } 01314 01315 // Decoration (text decoration) 01316 Magick::DrawableTextDecoration::DrawableTextDecoration 01317 ( Magick::DecorationType decoration_ ) 01318 : _decoration(decoration_) 01319 { 01320 } 01321 Magick::DrawableTextDecoration::DrawableTextDecoration