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/Options.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 Options 00006 // 00007 // A wrapper around DrawInfo, ImageInfo, and QuantizeInfo 00008 // 00009 00010 #define MAGICK_IMPLEMENTATION 1 00011 00012 #include "Magick++/Include.h" 00013 #include <string> 00014 #include <string.h> 00015 #include <stdlib.h> 00016 #include <math.h> 00017 #include "Magick++/Options.h" 00018 #include "Magick++/Functions.h" 00019 #include "Magick++/Exception.h" 00020 00021 // Constructor 00022 Magick::Options::Options( void ) 00023 : _imageInfo(static_cast<ImageInfo*>(AcquireMagickMemory(sizeof(ImageInfo)))), 00024 _quantizeInfo(static_cast<QuantizeInfo*>(AcquireMagickMemory(sizeof(QuantizeInfo)))), 00025 _drawInfo(static_cast<DrawInfo*>(AcquireMagickMemory( sizeof(DrawInfo)))) 00026 { 00027 // Initialize image info with defaults 00028 GetImageInfo( _imageInfo ); 00029 00030 // Initialize quantization info 00031 GetQuantizeInfo( _quantizeInfo ); 00032 00033 // Initialize drawing info 00034 GetDrawInfo( _imageInfo, _drawInfo ); 00035 } 00036 00037 // Copy constructor 00038 Magick::Options::Options( const Magick::Options& options_ ) 00039 : _imageInfo(CloneImageInfo( options_._imageInfo )), 00040 _quantizeInfo(CloneQuantizeInfo(options_._quantizeInfo)), 00041 _drawInfo(CloneDrawInfo(_imageInfo, options_._drawInfo)) 00042 { 00043 } 00044 00045 // Construct using raw structures 00046 Magick::Options::Options( const MagickLib::ImageInfo* imageInfo_, 00047 const MagickLib::QuantizeInfo* quantizeInfo_, 00048 const MagickLib::DrawInfo* drawInfo_ ) 00049 : _imageInfo(0), 00050 _quantizeInfo(0), 00051 _drawInfo(0) 00052 { 00053 _imageInfo = CloneImageInfo(imageInfo_); 00054 _quantizeInfo = CloneQuantizeInfo(quantizeInfo_); 00055 _drawInfo = CloneDrawInfo(imageInfo_,drawInfo_); 00056 } 00057 00058 // Destructor 00059 Magick::Options::~Options() 00060 { 00061 // Destroy image info 00062 _imageInfo =DestroyImageInfo( _imageInfo ); 00063 _imageInfo=0; 00064 00065 // Destroy quantization info 00066 _quantizeInfo =DestroyQuantizeInfo( _quantizeInfo ); 00067 _quantizeInfo=0; 00068 00069 // Destroy drawing info 00070 _drawInfo =DestroyDrawInfo( _drawInfo ); 00071 _drawInfo=0; 00072 } 00073 00074 /* 00075 * Methods for setting image attributes 00076 * 00077 */ 00078 00079 // Anti-alias Postscript and TrueType fonts (default true) 00080 void Magick::Options::antiAlias( bool flag_ ) 00081 { 00082 _drawInfo->text_antialias = static_cast<MagickBooleanType> 00083 (flag_ ? MagickTrue : MagickFalse); 00084 } 00085 bool Magick::Options::antiAlias( void ) const 00086 { 00087 return static_cast<bool>(_drawInfo->text_antialias); 00088 } 00089 00090 void Magick::Options::adjoin ( bool flag_ ) 00091 { 00092 _imageInfo->adjoin = static_cast<MagickBooleanType> 00093 (flag_ ? MagickTrue : MagickFalse); 00094 } 00095 bool Magick::Options::adjoin ( void ) const 00096 { 00097 return static_cast<bool>(_imageInfo->adjoin); 00098 } 00099 00100 void Magick::Options::backgroundColor ( const Magick::Color &color_ ) 00101 { 00102 _imageInfo->background_color = color_; 00103 } 00104 Magick::Color Magick::Options::backgroundColor ( void ) const 00105 { 00106 return Magick::Color( _imageInfo->background_color ); 00107 } 00108 00109 void Magick::Options::backgroundTexture ( const std::string &backgroundTexture_ ) 00110 { 00111 if ( backgroundTexture_.length() == 0 ) 00112 _imageInfo->texture=(char *) RelinquishMagickMemory(_imageInfo->texture); 00113 else 00114 Magick::CloneString( &_imageInfo->texture, backgroundTexture_ ); 00115 } 00116 std::string Magick::Options::backgroundTexture ( void ) const 00117 { 00118 if ( _imageInfo->texture ) 00119 return std::string( _imageInfo->texture ); 00120 else 00121 return std::string(); 00122 } 00123 00124 void Magick::Options::borderColor ( const Color &color_ ) 00125 { 00126 _imageInfo->border_color = color_; 00127 _drawInfo->border_color = color_; 00128 } 00129 Magick::Color Magick::Options::borderColor ( void ) const 00130 { 00131 return Magick::Color( _imageInfo->border_color ); 00132 } 00133 00134 // Text bounding-box base color 00135 void Magick::Options::boxColor ( const Magick::Color &boxColor_ ) 00136 { 00137 _drawInfo->undercolor = boxColor_; 00138 } 00139 Magick::Color Magick::Options::boxColor ( void ) const 00140 { 00141 return Magick::Color( _drawInfo->undercolor ); 00142 } 00143 00144 void Magick::Options::compressType ( CompressionType compressType_ ) 00145 { 00146 _imageInfo->compression = compressType_; 00147 } 00148 Magick::CompressionType Magick::Options::compressType ( void ) const 00149 { 00150 return static_cast<Magick::CompressionType>(_imageInfo->compression); 00151 } 00152 00153 void Magick::Options::colorFuzz ( double fuzz_ ) 00154 { 00155 _imageInfo->fuzz = fuzz_; 00156 } 00157 double Magick::Options::colorFuzz ( void ) const 00158 { 00159 return _imageInfo->fuzz; 00160 } 00161 00162 // Enable printing of debug messages from ImageMagick 00163 void Magick::Options::debug ( bool flag_ ) 00164 { 00165 if(flag_) 00166 { 00167 SetLogEventMask("All"); 00168 } 00169 else 00170 { 00171 SetLogEventMask("None"); 00172 } 00173 } 00174 bool Magick::Options::debug ( void ) const 00175 { 00176 if( IsEventLogging() ) 00177 { 00178 return true; 00179 } 00180 return false; 00181 } 00182 00183 void Magick::Options::density ( const Magick::Geometry &density_ ) 00184 { 00185 if ( !density_.isValid() ) 00186 _imageInfo->density=(char *) RelinquishMagickMemory(_imageInfo->density); 00187 else 00188 Magick::CloneString( &_imageInfo->density, density_ ); 00189 } 00190 Magick::Geometry Magick::Options::density ( void ) const 00191 { 00192 if ( _imageInfo->density ) 00193 return Geometry( _imageInfo->density ); 00194 00195 return Geometry(); 00196 } 00197 00198 void Magick::Options::depth ( unsigned int depth_ ) 00199 { 00200 _imageInfo->depth = depth_; 00201 } 00202 unsigned int Magick::Options::depth ( void ) const 00203 { 00204 return _imageInfo->depth; 00205 } 00206 00207 // Endianness (little like Intel or big like SPARC) for image 00208 // formats which support endian-specific options. 00209 void Magick::Options::endian ( Magick::EndianType endian_ ) 00210 { 00211 _imageInfo->endian = endian_; 00212 } 00213 Magick::EndianType Magick::Options::endian ( void ) const 00214 { 00215 return _imageInfo->endian; 00216 } 00217 00218 void Magick::Options::fileName ( const std::string &fileName_ ) 00219 { 00220 fileName_.copy( _imageInfo->filename, MaxTextExtent-1 ); 00221 _imageInfo->filename[ fileName_.length() ] = 0; 00222 } 00223 std::string Magick::Options::fileName ( void ) const 00224 { 00225 return std::string( _imageInfo->filename ); 00226 } 00227 00228 // Color to use when drawing inside an object 00229 void Magick::Options::fillColor ( const Magick::Color &fillColor_ ) 00230 { 00231 _drawInfo->fill = fillColor_; 00232 } 00233 Magick::Color Magick::Options::fillColor ( void ) const 00234 { 00235 return _drawInfo->fill; 00236 } 00237 00238 // Pattern image to use when filling objects 00239 void Magick::Options::fillPattern ( const MagickLib::Image *fillPattern_ ) 00240 { 00241 if ( _drawInfo->fill_pattern ) 00242 { 00243 DestroyImageList( _drawInfo->fill_pattern ); 00244 _drawInfo->fill_pattern = 0; 00245 } 00246 00247 if ( fillPattern_ ) 00248 { 00249 ExceptionInfo exceptionInfo; 00250 GetExceptionInfo( &exceptionInfo ); 00251 _drawInfo->fill_pattern = 00252 CloneImage( const_cast<MagickLib::Image*>(fillPattern_), 00253 0, 00254 0, 00255 static_cast<MagickBooleanType>(MagickTrue), 00256 &exceptionInfo ); 00257 throwException( exceptionInfo ); 00258 } 00259 } 00260 const MagickLib::Image* Magick::Options::fillPattern ( void ) const 00261 { 00262 return _drawInfo->fill_pattern; 00263 } 00264 00265 // Rule to use when filling drawn objects 00266 void Magick::Options::fillRule ( const Magick::FillRule &fillRule_ ) 00267 { 00268 _drawInfo->fill_rule = fillRule_; 00269 } 00270 Magick::FillRule Magick::Options::fillRule ( void ) const 00271 { 00272 return _drawInfo->fill_rule; 00273 } 00274 00275 void Magick::Options::font ( const std::string &font_ ) 00276 { 00277 if ( font_.length() == 0 ) 00278 { 00279 _imageInfo->font=(char *) RelinquishMagickMemory(_imageInfo->font); 00280 _drawInfo->font=(char *) RelinquishMagickMemory(_drawInfo->font); 00281 } 00282 else 00283 { 00284 Magick::CloneString( &_imageInfo->font, font_ ); 00285 Magick::CloneString( &_drawInfo->font, font_ ); 00286 } 00287 } 00288 std::string Magick::Options::font ( void ) const 00289 { 00290 if ( _imageInfo->font ) 00291 return std::string( _imageInfo->font ); 00292 00293 return std::string(); 00294 } 00295 00296 void Magick::Options::fontPointsize ( double pointSize_ ) 00297 { 00298 _imageInfo->pointsize = pointSize_; 00299 _drawInfo->pointsize = pointSize_; 00300 } 00301 double Magick::Options::fontPointsize ( void ) const 00302 { 00303 return _imageInfo->pointsize; 00304 } 00305 00306 std::string Magick::Options::format ( void ) const 00307 { 00308 ExceptionInfo exception; 00309 00310 const MagickInfo * magick_info = 0; 00311 GetExceptionInfo(&exception); 00312 if ( *_imageInfo->magick != '\0' ) 00313 magick_info = GetMagickInfo( _imageInfo->magick , &exception); 00314 00315 if (( magick_info != 0 ) && 00316 ( *magick_info->description != '\0' )) 00317 return std::string( magick_info->description ); 00318 00319 return std::string(); 00320 } 00321 00322 void Magick::Options::interlaceType ( Magick::InterlaceType interlace_ ) 00323 { 00324 _imageInfo->interlace = interlace_; 00325 } 00326 Magick::InterlaceType Magick::Options::interlaceType ( void ) const 00327 { 00328 return static_cast<Magick::InterlaceType>(_imageInfo->interlace); 00329 } 00330 00331 void Magick::Options::magick ( const std::string &magick_ ) 00332 { 00333 ExceptionInfo exception; 00334 00335 FormatString( _imageInfo->filename, "%.1024s:", magick_.c_str() ); 00336 GetExceptionInfo(&exception); 00337 SetImageInfo( _imageInfo, MagickTrue, &exception); 00338 if ( *_imageInfo->magick == '\0' ) 00339 throwExceptionExplicit( OptionWarning, 00340 "Unrecognized image format", 00341 magick_.c_str() ); 00342 } 00343 std::string Magick::Options::magick ( void ) const 00344 { 00345 if ( _imageInfo->magick && *_imageInfo->magick ) 00346 return std::string( _imageInfo->magick ); 00347 00348 return std::string(); 00349 } 00350 00351 void Magick::Options::matteColor ( const Magick::Color &matteColor_ ) 00352 { 00353 _imageInfo->matte_color = matteColor_; 00354 } 00355 Magick::Color Magick::Options::matteColor ( void ) const 00356 { 00357 return Magick::Color( _imageInfo->matte_color ); 00358 } 00359 00360 void Magick::Options::monochrome ( bool monochromeFlag_ ) 00361 { 00362 _imageInfo->monochrome = (MagickBooleanType) monochromeFlag_; 00363 } 00364 bool Magick::Options::monochrome ( void ) const 00365 { 00366 return static_cast<bool>(_imageInfo->monochrome); 00367 } 00368 00369 void Magick::Options::page ( const Magick::Geometry &pageSize_ ) 00370 { 00371 if ( !pageSize_.isValid() ) 00372 _imageInfo->page=(char *) RelinquishMagickMemory(_imageInfo->page); 00373 else 00374 Magick::CloneString( &_imageInfo->page, pageSize_ ); 00375 } 00376 Magick::Geometry Magick::Options::page ( void ) const 00377 { 00378 if ( _imageInfo->page ) 00379 return Geometry( _imageInfo->page ); 00380 00381 return Geometry(); 00382 } 00383 00384 void Magick::Options::quality ( unsigned int quality_ ) 00385 { 00386 _imageInfo->quality = quality_; 00387 } 00388 unsigned int Magick::Options::quality ( void ) const 00389 { 00390 return _imageInfo->quality; 00391 } 00392 00393 void Magick::Options::quantizeColors ( unsigned int colors_ ) 00394 { 00395 _quantizeInfo->number_colors = colors_; 00396 } 00397 unsigned int Magick::Options::quantizeColors ( void ) const 00398 { 00399 return _quantizeInfo->number_colors; 00400 } 00401 00402 void Magick::Options::quantizeColorSpace ( Magick::ColorspaceType colorSpace_ ) 00403 { 00404 _quantizeInfo->colorspace = colorSpace_; 00405 } 00406 Magick::ColorspaceType Magick::Options::quantizeColorSpace ( void ) const 00407 { 00408 return static_cast<Magick::ColorspaceType>(_quantizeInfo->colorspace); 00409 } 00410 00411 void Magick::Options::quantizeDither ( bool ditherFlag_ ) 00412 { 00413 _imageInfo->dither = (MagickBooleanType) ditherFlag_; 00414 _quantizeInfo->dither = (MagickBooleanType) ditherFlag_; 00415 } 00416 bool Magick::Options::quantizeDither ( void ) const 00417 { 00418 return static_cast<bool>(_imageInfo->dither); 00419 } 00420 00421 void Magick::Options::quantizeTreeDepth ( unsigned int treeDepth_ ) 00422 { 00423 _quantizeInfo->tree_depth = treeDepth_; 00424 } 00425 unsigned int Magick::Options::quantizeTreeDepth ( void ) const 00426 { 00427 return _quantizeInfo->tree_depth; 00428 } 00429 00430 void Magick::Options::resolutionUnits ( Magick::ResolutionType resolutionUnits_ ) 00431 { 00432 _imageInfo->units = resolutionUnits_; 00433 } 00434 Magick::ResolutionType Magick::Options::resolutionUnits ( void ) const 00435 { 00436 return static_cast<Magick::ResolutionType>(_imageInfo->units); 00437 } 00438 00439 void Magick::Options::size ( const Geometry &geometry_ ) 00440 { 00441 _imageInfo->size=(char *) RelinquishMagickMemory(_imageInfo->size); 00442 00443 if ( geometry_.isValid() ) 00444 Magick::CloneString( &_imageInfo->size, geometry_ ); 00445 } 00446 Magick::Geometry Magick::Options::size ( void ) const 00447 { 00448 if ( _imageInfo->size ) 00449 return Geometry( _imageInfo->size ); 00450 00451 return Geometry(); 00452 } 00453 00454 void Magick::Options::strokeAntiAlias( bool flag_ ) 00455 { 00456 flag_ ? _drawInfo->stroke_antialias=MagickTrue : _drawInfo->stroke_antialias=MagickFalse; 00457 } 00458 bool Magick::Options::strokeAntiAlias( void ) const 00459 { 00460 return (_drawInfo->stroke_antialias != 0 ? true : false); 00461 } 00462 00463 // Color to use when drawing object outlines 00464 void Magick::Options::strokeColor ( const Magick::Color &strokeColor_ ) 00465 { 00466 _drawInfo->stroke = strokeColor_; 00467 } 00468 Magick::Color Magick::Options::strokeColor ( void ) const 00469 { 00470 return _drawInfo->stroke; 00471 } 00472 00473 void Magick::Options::strokeDashArray ( const double* strokeDashArray_ ) 00474 { 00475 _drawInfo->dash_pattern=(double *) 00476 RelinquishMagickMemory(_drawInfo->dash_pattern); 00477 00478 if(strokeDashArray_) 00479 { 00480 // Count elements in dash array 00481 unsigned int x; 00482 for (x=0; strokeDashArray_[x]; x++); 00483 // Allocate elements 00484 _drawInfo->dash_pattern = 00485 static_cast<double*>(AcquireMagickMemory((x+1)*sizeof(double))); 00486 // Copy elements 00487 memcpy(_drawInfo->dash_pattern,strokeDashArray_, 00488 (x+1)*sizeof(double)); 00489 } 00490 } 00491 const double* Magick::Options::strokeDashArray ( void ) const 00492 { 00493 return _drawInfo->dash_pattern; 00494 } 00495 00496 void Magick::Options::strokeDashOffset ( double strokeDashOffset_ ) 00497 { 00498 _drawInfo->dash_offset = strokeDashOffset_; 00499 } 00500 double Magick::Options::strokeDashOffset ( void ) const 00501 { 00502 return _drawInfo->dash_offset; 00503 } 00504 00505 // Specify the shape to be used at the end of open subpaths when they 00506 // are stroked. Values of LineCap are ButtCap, RoundCap, and 00507 // SquareCap. 00508 void Magick::Options::strokeLineCap ( Magick::LineCap lineCap_ ) 00509 { 00510 _drawInfo->linecap = lineCap_; 00511 } 00512 Magick::LineCap Magick::Options::strokeLineCap ( void ) const 00513 { 00514 return _drawInfo->linecap; 00515 } 00516 00517 // Specify the shape to be used at the corners of paths (or other 00518 // vector shapes) when they are stroked. 00519 void Magick::Options::strokeLineJoin ( Magick::LineJoin lineJoin_ ) 00520 { 00521 _drawInfo->linejoin = lineJoin_; 00522 } 00523 Magick::LineJoin Magick::Options::strokeLineJoin ( void ) const 00524 { 00525 return _drawInfo->linejoin; 00526 } 00527 00528 // miterLimit for drawing lines, circles, ellipses, etc. 00529 void Magick::Options::strokeMiterLimit ( unsigned int miterLimit_ ) 00530 { 00531 _drawInfo->miterlimit = miterLimit_; 00532 } 00533 unsigned int Magick::Options::strokeMiterLimit ( void ) const 00534 { 00535 return _drawInfo->miterlimit; 00536 } 00537 00538 // Pattern image to use for stroked outlines 00539 void Magick::Options::strokePattern ( const MagickLib::Image *strokePattern_ ) 00540 { 00541 if ( _drawInfo->stroke_pattern ) 00542 { 00543 DestroyImageList( _drawInfo->stroke_pattern ); 00544 _drawInfo->stroke_pattern = 0; 00545 } 00546 00547 if ( strokePattern_ ) 00548 { 00549 ExceptionInfo exceptionInfo; 00550 GetExceptionInfo( &exceptionInfo ); 00551 _drawInfo->stroke_pattern = 00552 CloneImage( const_cast<MagickLib::Image*>(strokePattern_), 00553 0, 00554 0, 00555 MagickTrue, 00556 &exceptionInfo ); 00557 throwException( exceptionInfo ); 00558 } 00559 } 00560 const MagickLib::Image* Magick::Options::strokePattern ( void ) const 00561 { 00562 return _drawInfo->stroke_pattern; 00563 } 00564 00565 // Stroke width for drawing lines, circles, ellipses, etc. 00566 void Magick::Options::strokeWidth ( double strokeWidth_ ) 00567 { 00568 _drawInfo->stroke_width = strokeWidth_; 00569 } 00570 double Magick::Options::strokeWidth ( void ) const 00571 { 00572 return _drawInfo->stroke_width; 00573 } 00574 00575 void Magick::Options::subImage ( unsigned int subImage_ ) 00576 { 00577 _imageInfo->subimage = subImage_; 00578 } 00579 unsigned int Magick::Options::subImage ( void ) const 00580 { 00581 return _imageInfo->subimage; 00582 } 00583 00584 void Magick::Options::subRange ( unsigned int subRange_ ) 00585 { 00586 _imageInfo->subrange = subRange_; 00587 } 00588 unsigned int Magick::Options::subRange ( void ) const 00589 { 00590 return _imageInfo->subrange; 00591 } 00592 00593 // Annotation text encoding (e.g. "UTF-16") 00594 void Magick::Options::textEncoding ( const std::string &encoding_ ) 00595 { 00596 CloneString(&_drawInfo->encoding, encoding_.c_str()); 00597 } 00598 std::string Magick::Options::textEncoding ( void ) const 00599 { 00600 if ( _drawInfo->encoding && *_drawInfo->encoding ) 00601 return std::string( _drawInfo->encoding ); 00602 00603 return std::string(); 00604 } 00605 00606 void Magick::Options::tileName ( const std::string &tileName_ ) 00607 { 00608 if ( tileName_.length() == 0 ) 00609 _imageInfo->tile=(char *) RelinquishMagickMemory(_imageInfo->tile); 00610 else 00611 Magick::CloneString( &_imageInfo->tile, tileName_ ); 00612 } 00613 std::string Magick::Options::tileName ( void ) const 00614 { 00615 if ( _imageInfo->tile ) 00616 return std::string( _imageInfo->tile ); 00617 return std::string(); 00618 } 00619 00620 // Image representation type 00621 void Magick::Options::type ( const Magick::ImageType type_ ) 00622 { 00623 _imageInfo->type = type_; 00624 } 00625 Magick::ImageType Magick::Options::type ( void ) const 00626 { 00627 return _imageInfo->type; 00628 } 00629 00630 // Origin of coordinate system to use when annotating with text or drawing 00631 void Magick::Options::transformOrigin ( double tx_, double ty_ ) 00632 { 00633 AffineMatrix current = _drawInfo->affine; 00634 AffineMatrix affine; 00635 affine.sx=1.0; 00636 affine.rx=0.0; 00637 affine.ry=0.0; 00638 affine.sy=1.0; 00639 affine.tx=0.0; 00640 affine.ty=0.0; 00641 00642 affine.tx = tx_; 00643 affine.ty = ty_; 00644 00645 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx; 00646 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx; 00647 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy; 00648 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy; 00649 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; 00650 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; 00651 } 00652 00653 // Reset transformation parameters to default 00654 void Magick::Options::transformReset ( void ) 00655 { 00656 _drawInfo->affine.sx=1.0; 00657 _drawInfo->affine.rx=0.0; 00658 _drawInfo->affine.ry=0.0; 00659 _drawInfo->affine.sy=1.0; 00660 _drawInfo->affine.tx=0.0; 00661 _drawInfo->affine.ty=0.0; 00662 } 00663 00664 // Rotation to use when annotating with text or drawing 00665 void Magick::Options::transformRotation ( double angle_ ) 00666 { 00667 AffineMatrix current = _drawInfo->affine; 00668 AffineMatrix affine; 00669 affine.sx=1.0; 00670 affine.rx=0.0; 00671 affine.ry=0.0; 00672 affine.sy=1.0; 00673 affine.tx=0.0; 00674 affine.ty=0.0; 00675 00676 affine.sx=cos(DegreesToRadians(fmod(angle_,360.0))); 00677 affine.rx=(-sin(DegreesToRadians(fmod(angle_,360.0)))); 00678 affine.ry=sin(DegreesToRadians(fmod(angle_,360.0))); 00679 affine.sy=cos(DegreesToRadians(fmod(angle_,360.0))); 00680 00681 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx; 00682 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx; 00683 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy; 00684 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy; 00685 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; 00686 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; 00687 } 00688 00689 // Scale to use when annotating with text or drawing 00690 void Magick::Options::transformScale ( double sx_, double sy_ ) 00691 { 00692 AffineMatrix current = _drawInfo->affine; 00693 AffineMatrix affine; 00694 affine.sx=1.0; 00695 affine.rx=0.0; 00696 affine.ry=0.0; 00697 affine.sy=1.0; 00698 affine.tx=0.0; 00699 affine.ty=0.0; 00700 00701 affine.sx = sx_; 00702 affine.sy = sy_; 00703 00704 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx; 00705 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx; 00706 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy; 00707 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy; 00708 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; 00709 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; 00710 } 00711 00712 // Skew to use in X axis when annotating with text or drawing 00713 void Magick::Options::transformSkewX ( double skewx_ ) 00714 { 00715 AffineMatrix current = _drawInfo->affine; 00716 AffineMatrix affine; 00717 affine.sx=1.0; 00718 affine.rx=0.0; 00719 affine.ry=0.0; 00720 affine.sy=1.0; 00721 affine.tx=0.0; 00722 affine.ty=0.0; 00723 00724 affine.sx=1.0; 00725 affine.ry=tan(DegreesToRadians(fmod(skewx_,360.0))); 00726 affine.sy=1.0; 00727 00728 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx; 00729 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx; 00730 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy; 00731 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy; 00732 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; 00733 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; 00734 } 00735 00736 // Skew to use in Y axis when annotating with text or drawing 00737 void Magick::Options::transformSkewY ( double skewy_ ) 00738 { 00739 AffineMatrix current = _drawInfo->affine; 00740 AffineMatrix affine; 00741 affine.sx=1.0; 00742 affine.rx=0.0; 00743 affine.ry=0.0; 00744 affine.sy=1.0; 00745 affine.tx=0.0; 00746 affine.ty=0.0; 00747 00748 affine.sx=1.0; 00749 affine.rx=tan(DegreesToRadians(fmod(skewy_,360.0))); 00750 affine.sy=1.0; 00751 00752 _drawInfo->affine.sx=current.sx*affine.sx+current.ry*affine.rx; 00753 _drawInfo->affine.rx=current.rx*affine.sx+current.sy*affine.rx; 00754 _drawInfo->affine.ry=current.sx*affine.ry+current.ry*affine.sy; 00755 _drawInfo->affine.sy=current.rx*affine.ry+current.sy*affine.sy; 00756 _drawInfo->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx; 00757 _drawInfo->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty; 00758 } 00759 00760 void Magick::Options::verbose ( bool verboseFlag_ ) 00761 { 00762 _imageInfo->verbose = (MagickBooleanType) verboseFlag_; 00763 } 00764 bool Magick::Options::verbose ( void ) const 00765 { 00766 return static_cast<bool>(_imageInfo->verbose); 00767 } 00768 00769 void Magick::Options::view ( const std::string &view_ ) 00770 { 00771 if ( view_.length() == 0 ) 00772 _imageInfo->view=(char *) RelinquishMagickMemory(_imageInfo->view); 00773 else 00774 Magick::CloneString( &_imageInfo->view, view_ ); 00775 } 00776 std::string Magick::Options::view ( void ) const 00777 { 00778 if ( _imageInfo->view ) 00779 return std::string( _imageInfo->view ); 00780 00781 return std::string(); 00782 } 00783 00784 void Magick::Options::x11Display ( const std::string &display_ ) 00785 { 00786 if ( display_.length() == 0 ) 00787 _imageInfo->server_name=(char *) RelinquishMagickMemory(_imageInfo->server_name); 00788 else 00789 Magick::CloneString( &_imageInfo->server_name, display_ ); 00790 } 00791 std::string Magick::Options::x11Display ( void ) const 00792 { 00793 if ( _imageInfo->server_name ) 00794 return std::string( _imageInfo->server_name ); 00795 00796 return std::string(); 00797 } 00798 00799 // 00800 // Internal implementation methods. Please do not use. 00801 // 00802 00803 MagickLib::DrawInfo * Magick::Options::drawInfo( void ) 00804 { 00805 return _drawInfo; 00806 } 00807 00808 MagickLib::ImageInfo * Magick::Options::imageInfo( void ) 00809 { 00810 return _imageInfo; 00811 } 00812 00813 MagickLib::QuantizeInfo * Magick::Options::quantizeInfo( void ) 00814 { 00815 return _quantizeInfo; 00816 }

Generated on Mon Oct 25 13:41:13 2004 for ImageMagick by doxygen 1.3.7
ImageMagick Copyright © 2004, ImageMagick Studio LLC