Changeset 1181:72873be9485d
- Timestamp:
- 03/15/09 19:50:36 (3 years ago)
- Branch:
- default
- Location:
- trunk
- Files:
-
- 1 added
- 7 edited
-
Makefile.in (modified) (1 diff)
-
include/libdodo/graphicsDraw.h (modified) (1 diff)
-
include/libdodo/graphicsImage.h (modified) (5 diffs)
-
src/graphicsDraw.cc (modified) (12 diffs)
-
src/graphicsImage.cc (modified) (20 diffs)
-
src/graphicsImage.inline (added)
-
src/graphicsTransform.cc (modified) (9 diffs)
-
tests/image_test/test.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile.in
r1178 r1181 15 15 CPPFLAGS:=-I./include @CPPFLAGS@ 16 16 LDFLAGS:=-L./ @LDFLAGS@ 17 CFLAGS:=@CFLAGS@ 17 CFLAGS:=@CFLAGS@ @DEFS@ 18 18 19 19 ########################################################### -
trunk/include/libdodo/graphicsDraw.h
r1179 r1181 35 35 #ifdef IMAGEMAGICK_EXT 36 36 #include <libdodo/types.h> 37 #include <libdodo/graphicsColor.h> 37 38 38 39 namespace dodo -
trunk/include/libdodo/graphicsImage.h
r1180 r1181 69 69 public: 70 70 71 /**72 * constructor73 */74 __xexecImageCollectedData();75 76 71 #ifndef GRAPHICS_WO_XEXEC 77 72 /** … … 82 77 __xexecImageCollectedData(xexec *executor, 83 78 short execObject); 79 #else 80 /** 81 * constructor 82 */ 83 __xexecImageCollectedData(); 84 84 #endif 85 85 … … 89 89 ~__xexecImageCollectedData(); 90 90 91 __image cHandle *handle; ///< ImageMagic handle91 __imageHandle *handle; ///< ImageMagic handle 92 92 }; 93 93 … … 332 332 protected: 333 333 334 ExceptionInfoexInfo; ///< exception info handler334 void *exInfo; ///< exception info handler 335 335 336 336 __xexecImageCollectedData collectedData; ///< data collected for xexec … … 339 339 340 340 static const char *mappingStArr[IMAGE_MAPPINGSTATEMENTS]; ///< image mapping statements 341 static const StorageTypepixelSizeStArr[IMAGE_PIXELSIZESTATEMENTS]; ///< pixel type statements342 static const ImageTypetypeStArr[IMAGE_TYPESTATEMENTS]; ///< color space statements341 static const int pixelSizeStArr[IMAGE_PIXELSIZESTATEMENTS]; ///< pixel type statements 342 static const int typeStArr[IMAGE_TYPESTATEMENTS]; ///< color space statements 343 343 static const char *encoderStArr[IMAGE_ENCODERSTATEMENTS]; ///< image encoder 344 static const CompressionType compressionStArr[IMAGE_COMPRESSIONSTATEMENTS]; ///< image compression 345 }; 346 347 /** 348 * @class __image_init__ 349 * @brief initializes image evironment 350 */ 351 class __image_init__ 352 { 353 public: 354 355 /** 356 * contructor 357 */ 358 __image_init__(); 359 360 /** 361 * destructor 362 */ 363 ~__image_init__(); 364 365 private: 366 367 /** 368 * ImageMagic error handler 369 * @param et defines error category 370 * @param reason defines the reason of the error 371 * @param description defines description to the reason 372 */ 373 static void imErrorHandler(const ExceptionType et, 374 const char *reason, 375 const char *description); 376 377 /** 378 * ImageMagic warning handler 379 * @param et defines warning category 380 * @param reason defines the reason of the warning 381 * @param description defines description to the reason 382 */ 383 static void imWarningHandler(const ExceptionType et, 384 const char *reason, 385 const char *description); 386 }; 387 388 extern __image_init__ __image_init_object__; 344 static const int compressionStArr[IMAGE_COMPRESSIONSTATEMENTS]; ///< image compression 345 }; 389 346 }; 390 347 }; -
trunk/src/graphicsDraw.cc
r1179 r1181 38 38 #include <math.h> 39 39 40 #include "graphicsImage.inline" 41 40 42 #include <libdodo/graphicsDraw.h> 41 43 #include <libdodo/types.h> … … 92 94 unsigned short borderWidth) 93 95 { 94 if (im == NULL || im->collectedData. imHandle == NULL)96 if (im == NULL || im->collectedData.handle->imHandle == NULL) 95 97 { 96 98 throw exception::basic(exception::ERRMODULE_GRAPHICSDRAW, DRAWEX_PRIMITIVE, exception::ERRNO_IMAGEMAGICK, DRAWEX_EMPTYIMAGE, GRAPHICSDRAWEX_EMPTYIMAGE_STR, __LINE__, __FILE__); … … 100 102 DrawInfo *di = AcquireDrawInfo(); 101 103 #else 102 DrawInfo *di = CloneDrawInfo(im->collectedData. imInfo, NULL);104 DrawInfo *di = CloneDrawInfo(im->collectedData.handle->imInfo, NULL); 103 105 #endif 104 106 … … 117 119 di->fill.opacity = fillColor.opacity; 118 120 119 if (DrawImage(im->collectedData. imHandle, di) == MagickFalse)121 if (DrawImage(im->collectedData.handle->imHandle, di) == MagickFalse) 120 122 { 121 123 di->primitive = NULL; … … 194 196 double angle) 195 197 { 196 if (im == NULL || im->collectedData. imHandle == NULL)198 if (im == NULL || im->collectedData.handle->imHandle == NULL) 197 199 { 198 200 throw exception::basic(exception::ERRMODULE_GRAPHICSDRAW, DRAWEX_TEXT, exception::ERRNO_IMAGEMAGICK, DRAWEX_EMPTYIMAGE, GRAPHICSDRAWEX_EMPTYIMAGE_STR, __LINE__, __FILE__); … … 206 208 DrawInfo *di = AcquireDrawInfo(); 207 209 #else 208 DrawInfo *di = CloneDrawInfo(im->collectedData. imInfo, NULL);210 DrawInfo *di = CloneDrawInfo(im->collectedData.handle->imInfo, NULL); 209 211 #endif 210 212 … … 250 252 di->fill.opacity = fillColor.opacity; 251 253 252 if (DrawImage(im->collectedData. imHandle, di) == MagickFalse)254 if (DrawImage(im->collectedData.handle->imHandle, di) == MagickFalse) 253 255 { 254 256 di->primitive = NULL; … … 271 273 double angle) 272 274 { 273 if (im == NULL || im->collectedData. imHandle == NULL)275 if (im == NULL || im->collectedData.handle->imHandle == NULL) 274 276 { 275 277 throw exception::basic(exception::ERRMODULE_GRAPHICSDRAW, DRAWEX_IMAGE, exception::ERRNO_IMAGEMAGICK, DRAWEX_EMPTYIMAGE, GRAPHICSDRAWEX_EMPTYIMAGE_STR, __LINE__, __FILE__); … … 303 305 current.ty = _current.rx * affine.tx + _current.sy * affine.ty + _current.ty; 304 306 305 if (DrawAffineImage(im->collectedData. imHandle, a_im.collectedData.imHandle, ¤t) == MagickFalse)307 if (DrawAffineImage(im->collectedData.handle->imHandle, a_im.collectedData.handle->imHandle, ¤t) == MagickFalse) 306 308 { 307 309 throw exception::basic(exception::ERRMODULE_GRAPHICSDRAW, DRAWEX_IMAGE, exception::ERRNO_IMAGEMAGICK, DRAWEX_CANNOTDRAWPRIMITIVE, GRAPHICSDRAWEX_CANNOTDRAWPRIMITIVE_STR, __LINE__, __FILE__); … … 316 318 unsigned short pointWidth) 317 319 { 318 if (im == NULL || im->collectedData. imHandle == NULL)320 if (im == NULL || im->collectedData.handle->imHandle == NULL) 319 321 { 320 322 throw exception::basic(exception::ERRMODULE_GRAPHICSDRAW, DRAWEX_POINT, exception::ERRNO_IMAGEMAGICK, DRAWEX_EMPTYIMAGE, GRAPHICSDRAWEX_EMPTYIMAGE_STR, __LINE__, __FILE__); … … 335 337 DrawInfo *di = AcquireDrawInfo(); 336 338 #else 337 DrawInfo *di = CloneDrawInfo(im->collectedData. imInfo, NULL);339 DrawInfo *di = CloneDrawInfo(im->collectedData.handle->imInfo, NULL); 338 340 #endif 339 341 … … 345 347 di->fill.opacity = pointColor.opacity; 346 348 347 if (DrawImage(im->collectedData. imHandle, di) == MagickFalse)349 if (DrawImage(im->collectedData.handle->imHandle, di) == MagickFalse) 348 350 { 349 351 di->primitive = NULL; -
trunk/src/graphicsImage.cc
r1179 r1181 39 39 #include <math.h> 40 40 41 #include "graphicsImage.inline" 42 41 43 #include <libdodo/graphicsImage.h> 42 44 #include <libdodo/types.h> … … 49 51 namespace graphics 50 52 { 53 /** 54 * @class __image_init__ 55 * @brief initializes image evironment 56 */ 57 class __image_init__ 58 { 59 public: 60 61 /** 62 * contructor 63 */ 64 __image_init__(); 65 66 /** 67 * destructor 68 */ 69 ~__image_init__(); 70 71 private: 72 73 /** 74 * ImageMagic error handler 75 * @param et defines error category 76 * @param reason defines the reason of the error 77 * @param description defines description to the reason 78 */ 79 static void imErrorHandler(const ExceptionType et, 80 const char *reason, 81 const char *description); 82 83 /** 84 * ImageMagic warning handler 85 * @param et defines warning category 86 * @param reason defines the reason of the warning 87 * @param description defines description to the reason 88 */ 89 static void imWarningHandler(const ExceptionType et, 90 const char *reason, 91 const char *description); 92 }; 93 51 94 __image_init__ __image_init_object__; 52 53 struct __imageHandle54 {55 ImageInfo *imInfo; ///< image info handler56 Image *imHandle; ///< image handler57 };58 95 }; 59 96 }; 97 60 98 61 99 //------------------------------------------------------------------- … … 69 107 { 70 108 } 71 #endif 72 73 //------------------------------------------------------------------- 74 109 #else 75 110 __xexecImageCollectedData::__xexecImageCollectedData() : handle(new __imageHandle) 76 111 { 77 112 } 113 #endif 78 114 79 115 //------------------------------------------------------------------- … … 145 181 //------------------------------------------------------------------- 146 182 147 const ImageTypeimage::typeStArr[] =183 const int image::typeStArr[] = 148 184 { 149 185 TrueColorMatteType, … … 153 189 //------------------------------------------------------------------- 154 190 155 const StorageTypeimage::pixelSizeStArr[] =191 const int image::pixelSizeStArr[] = 156 192 { 157 193 CharPixel, … … 177 213 //------------------------------------------------------------------- 178 214 179 const CompressionTypeimage::compressionStArr[] =215 const int image::compressionStArr[] = 180 216 { 181 217 NoCompression, … … 200 236 //------------------------------------------------------------------- 201 237 202 image::image() 203 #ifndef GRAPHICS_WO_XEXEC 204 : collectedData(this, XEXEC_OBJECT_GRAPHICSIMAGE) 238 image::image() : exInfo(new ExceptionInfo) 239 #ifndef GRAPHICS_WO_XEXEC 240 , 241 collectedData(this, XEXEC_OBJECT_GRAPHICSIMAGE) 205 242 #endif 206 243 { … … 224 261 225 262 DestroyImageInfo(collectedData.handle->imInfo); 226 DestroyExceptionInfo(&exInfo); 263 DestroyExceptionInfo((ExceptionInfo *)exInfo); 264 265 delete (ExceptionInfo *)exInfo; 227 266 } 228 267 … … 244 283 } 245 284 246 GetExceptionInfo( &exInfo);285 GetExceptionInfo((ExceptionInfo *)exInfo); 247 286 GetImageInfo(collectedData.handle->imInfo); 248 287 … … 254 293 } 255 294 256 collectedData.handle->imHandle = ReadImage(collectedData.handle->imInfo, &exInfo);257 if (collectedData.handle->imHandle == NULL) 258 { 259 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_READ, exception::ERRNO_IMAGEMAGICK, exInfo.error_number, exInfo.reason, __LINE__, __FILE__, exInfo.description);295 collectedData.handle->imHandle = ReadImage(collectedData.handle->imInfo, (ExceptionInfo *)exInfo); 296 if (collectedData.handle->imHandle == NULL) 297 { 298 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_READ, exception::ERRNO_IMAGEMAGICK, ((ExceptionInfo *)exInfo)->error_number, ((ExceptionInfo *)exInfo)->reason, __LINE__, __FILE__, ((ExceptionInfo *)exInfo)->description); 260 299 } 261 300 … … 280 319 #endif 281 320 282 GetExceptionInfo( &exInfo);321 GetExceptionInfo((ExceptionInfo *)exInfo); 283 322 GetImageInfo(collectedData.handle->imInfo); 284 323 … … 288 327 } 289 328 290 collectedData.handle->imHandle = BlobToImage(collectedData.handle->imInfo, data.data(), data.size(), &exInfo);291 if (collectedData.handle->imHandle == NULL) 292 { 293 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_READ, exception::ERRNO_IMAGEMAGICK, exInfo.error_number, exInfo.reason, __LINE__, __FILE__, exInfo.description);329 collectedData.handle->imHandle = BlobToImage(collectedData.handle->imInfo, data.data(), data.size(), (ExceptionInfo *)exInfo); 330 if (collectedData.handle->imHandle == NULL) 331 { 332 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_READ, exception::ERRNO_IMAGEMAGICK, ((ExceptionInfo *)exInfo)->error_number, ((ExceptionInfo *)exInfo)->reason, __LINE__, __FILE__, ((ExceptionInfo *)exInfo)->description); 294 333 } 295 334 … … 319 358 } 320 359 321 GetExceptionInfo( &exInfo);360 GetExceptionInfo((ExceptionInfo *)exInfo); 322 361 GetImageInfo(collectedData.handle->imInfo); 323 362 … … 327 366 } 328 367 329 collectedData.handle->imHandle = ConstituteImage(info.width, info.height, mappingStArr[info.mapping], pixelSizeStArr[info.pixelSize], info.data, &exInfo);330 if (collectedData.handle->imHandle == NULL) 331 { 332 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_READ, exception::ERRNO_IMAGEMAGICK, exInfo.error_number, exInfo.reason, __LINE__, __FILE__, exInfo.description);368 collectedData.handle->imHandle = ConstituteImage(info.width, info.height, mappingStArr[info.mapping], (StorageType)pixelSizeStArr[info.pixelSize], info.data, (ExceptionInfo *)exInfo); 369 if (collectedData.handle->imHandle == NULL) 370 { 371 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_READ, exception::ERRNO_IMAGEMAGICK, ((ExceptionInfo *)exInfo)->error_number, ((ExceptionInfo *)exInfo)->reason, __LINE__, __FILE__, ((ExceptionInfo *)exInfo)->description); 333 372 } 334 373 … … 356 395 #endif 357 396 358 GetExceptionInfo( &exInfo);397 GetExceptionInfo((ExceptionInfo *)exInfo); 359 398 GetImageInfo(collectedData.handle->imInfo); 360 399 … … 380 419 if (collectedData.handle->imHandle == NULL) 381 420 { 382 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_CREATE, exception::ERRNO_IMAGEMAGICK, exInfo.error_number, exInfo.reason, __LINE__, __FILE__, exInfo.description);421 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_CREATE, exception::ERRNO_IMAGEMAGICK, ((ExceptionInfo *)exInfo)->error_number, ((ExceptionInfo *)exInfo)->reason, __LINE__, __FILE__, ((ExceptionInfo *)exInfo)->description); 383 422 } 384 423 … … 408 447 } 409 448 410 if (SetImageType(collectedData.handle->imHandle, typeStArr[type]) == MagickFalse)449 if (SetImageType(collectedData.handle->imHandle, (ImageType)typeStArr[type]) == MagickFalse) 411 450 { 412 451 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_SETTYPE, exception::ERRNO_IMAGEMAGICK, IMAGEEX_CANNOTSETTYPE, GRAPHICSIMAGEEX_CANNOTSETTYPE_STR, __LINE__, __FILE__); … … 508 547 strncpy(collectedData.handle->imHandle->filename, str.c_str(), size); 509 548 510 GetExceptionInfo( &exInfo);549 GetExceptionInfo((ExceptionInfo *)exInfo); 511 550 512 551 if (WriteImage(collectedData.handle->imInfo, collectedData.handle->imHandle) == MagickFalse) 513 552 { 514 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_WRITE, exception::ERRNO_IMAGEMAGICK, collectedData.handle->imHandle->exception.error_number, exInfo.reason, __LINE__, __FILE__, exInfo.description);553 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_WRITE, exception::ERRNO_IMAGEMAGICK, collectedData.handle->imHandle->exception.error_number, ((ExceptionInfo *)exInfo)->reason, __LINE__, __FILE__, ((ExceptionInfo *)exInfo)->description); 515 554 } 516 555 … … 535 574 } 536 575 537 GetExceptionInfo( &exInfo);576 GetExceptionInfo((ExceptionInfo *)exInfo); 538 577 539 578 unsigned long size = 0; 540 unsigned char *imData = ImageToBlob(collectedData.handle->imInfo, collectedData.handle->imHandle, (size_t *)&size, &exInfo);579 unsigned char *imData = ImageToBlob(collectedData.handle->imInfo, collectedData.handle->imHandle, (size_t *)&size, (ExceptionInfo *)exInfo); 541 580 if (imData == NULL) 542 581 { 543 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_WRITE, exception::ERRNO_IMAGEMAGICK, exInfo.error_number, exInfo.reason, __LINE__, __FILE__, exInfo.description);582 throw exception::basic(exception::ERRMODULE_GRAPHICSIMAGE, IMAGEEX_WRITE, exception::ERRNO_IMAGEMAGICK, ((ExceptionInfo *)exInfo)->error_number, ((ExceptionInfo *)exInfo)->reason, __LINE__, __FILE__, ((ExceptionInfo *)exInfo)->description); 544 583 } 545 584 … … 561 600 } 562 601 563 collectedData.handle->imInfo->compression = compressionStArr[type];602 collectedData.handle->imInfo->compression = (CompressionType)compressionStArr[type]; 564 603 } 565 604 -
trunk/src/graphicsTransform.cc
r1180 r1181 38 38 39 39 #include <math.h> 40 41 #include "graphicsImage.inline" 40 42 41 43 #include <libdodo/graphicsTransform.h> … … 81 83 unsigned long height) 82 84 { 83 if (im == NULL || im->collectedData. imHandle == NULL)85 if (im == NULL || im->collectedData.handle->imHandle == NULL) 84 86 { 85 87 throw exception::basic(exception::ERRMODULE_GRAPHICSTRANSFORM, TRANSFORMEX_SCALE, exception::ERRNO_IMAGEMAGICK, TRANSFORMEX_EMPTYIMAGE, GRAPHICSTRANSFORMEX_EMPTYIMAGE_STR, __LINE__, __FILE__); … … 88 90 GetExceptionInfo(&(im->exInfo)); 89 91 90 Image *image = ScaleImage(im->collectedData. imHandle, width, height, &(im->exInfo));92 Image *image = ScaleImage(im->collectedData.handle->imHandle, width, height, &(im->exInfo)); 91 93 92 94 if (image == NULL) … … 95 97 } 96 98 97 DestroyImage(im->collectedData. imHandle);99 DestroyImage(im->collectedData.handle->imHandle); 98 100 99 im->collectedData. imHandle = image;101 im->collectedData.handle->imHandle = image; 100 102 } 101 103 … … 105 107 transform::scale(unsigned long size) 106 108 { 107 if (im == NULL || im->collectedData. imHandle == NULL)109 if (im == NULL || im->collectedData.handle->imHandle == NULL) 108 110 { 109 111 throw exception::basic(exception::ERRMODULE_GRAPHICSTRANSFORM, TRANSFORMEX_SCALE, exception::ERRNO_IMAGEMAGICK, TRANSFORMEX_EMPTYIMAGE, GRAPHICSTRANSFORMEX_EMPTYIMAGE_STR, __LINE__, __FILE__); 110 112 } 111 113 112 float mult = (float)size / (float)((im->collectedData. imHandle->columns > im->collectedData.imHandle->rows) ? im->collectedData.imHandle->columns : im->collectedData.imHandle->rows);114 float mult = (float)size / (float)((im->collectedData.handle->imHandle->columns > im->collectedData.handle->imHandle->rows) ? im->collectedData.handle->imHandle->columns : im->collectedData.handle->imHandle->rows); 113 115 114 116 GetExceptionInfo(&(im->exInfo)); 115 117 116 Image *image = ScaleImage(im->collectedData. imHandle, (unsigned long)floor(im->collectedData.imHandle->columns * mult), (unsigned long)floor(im->collectedData.imHandle->rows * mult), &(im->exInfo));118 Image *image = ScaleImage(im->collectedData.handle->imHandle, (unsigned long)floor(im->collectedData.handle->imHandle->columns * mult), (unsigned long)floor(im->collectedData.handle->imHandle->rows * mult), &(im->exInfo)); 117 119 118 120 if (image == NULL) … … 121 123 } 122 124 123 DestroyImage(im->collectedData. imHandle);125 DestroyImage(im->collectedData.handle->imHandle); 124 126 125 im->collectedData. imHandle = image;127 im->collectedData.handle->imHandle = image; 126 128 } 127 129 … … 131 133 transform::rotate(double angle) 132 134 { 133 if (im == NULL || im->collectedData. imHandle == NULL)135 if (im == NULL || im->collectedData.handle->imHandle == NULL) 134 136 { 135 137 throw exception::basic(exception::ERRMODULE_GRAPHICSTRANSFORM, TRANSFORMEX_ROTATE, exception::ERRNO_IMAGEMAGICK, TRANSFORMEX_EMPTYIMAGE, GRAPHICSTRANSFORMEX_EMPTYIMAGE_STR, __LINE__, __FILE__); … … 138 140 GetExceptionInfo(&(im->exInfo)); 139 141 140 Image *image = RotateImage(im->collectedData. imHandle, angle, &(im->exInfo));142 Image *image = RotateImage(im->collectedData.handle->imHandle, angle, &(im->exInfo)); 141 143 142 144 if (image == NULL) … … 145 147 } 146 148 147 DestroyImage(im->collectedData. imHandle);149 DestroyImage(im->collectedData.handle->imHandle); 148 150 149 im->collectedData. imHandle = image;151 im->collectedData.handle->imHandle = image; 150 152 } 151 153 -
trunk/tests/image_test/test.cc
r1115 r1181 11 11 #include <libdodo/ioFile.h> 12 12 13 #include <math.h> 13 14 #include <iostream> 14 15
Note: See TracChangeset
for help on using the changeset viewer.
