| 1 |
// This may look like C code, but it is really -*- C++ -*- |
| 2 |
// |
| 3 |
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003 |
| 4 |
// |
| 5 |
// Tests for setting/getting Magick::Image attributes |
| 6 |
// |
| 7 |
|
| 8 |
#include <Magick++.h> |
| 9 |
#include <string> |
| 10 |
#include <iostream> |
| 11 |
|
| 12 |
using namespace std; |
| 13 |
|
| 14 |
using namespace Magick; |
| 15 |
|
| 16 |
int main( int /*argc*/, char ** argv) |
| 17 |
{ |
| 18 |
|
| 19 |
// Initialize ImageMagick install location for Windows |
| 20 |
MagickPlusPlusGenesis genesis(*argv); |
| 21 |
|
| 22 |
int failures=0; |
| 23 |
|
| 24 |
try { |
| 25 |
|
| 26 |
size_t columns = 640; |
| 27 |
size_t rows = 480; |
| 28 |
Geometry geometry(columns,rows); |
| 29 |
Color canvasColor( "red" ); |
| 30 |
Image image( geometry, canvasColor); |
| 31 |
|
| 32 |
// |
| 33 |
// antiAlias |
| 34 |
// |
| 35 |
|
| 36 |
// Test default value |
| 37 |
if ( image.textAntiAlias() != true ) |
| 38 |
{ |
| 39 |
++failures; |
| 40 |
cout << "Line: " << __LINE__ << ", textAntiAlias default not true" << endl; |
| 41 |
} |
| 42 |
|
| 43 |
// Test setting false |
| 44 |
image.textAntiAlias( false ); |
| 45 |
if ( image.textAntiAlias() != false ) |
| 46 |
{ |
| 47 |
++failures; |
| 48 |
cout << "Line: " << __LINE__ << ", textAntiAlias not false" << endl; |
| 49 |
} |
| 50 |
|
| 51 |
// Test setting true |
| 52 |
image.textAntiAlias( true ); |
| 53 |
if ( image.textAntiAlias() != true ) |
| 54 |
{ |
| 55 |
++failures; |
| 56 |
cout << "Line: " << __LINE__ << ", textAntiAlias not true" << endl; |
| 57 |
} |
| 58 |
|
| 59 |
// |
| 60 |
// adjoin |
| 61 |
// |
| 62 |
|
| 63 |
// Test default value |
| 64 |
if ( image.adjoin() != true ) |
| 65 |
{ |
| 66 |
++failures; |
| 67 |
cout << "Line: " << __LINE__ |
| 68 |
<< ", adjoin default not 'true' as expected" << endl; |
| 69 |
} |
| 70 |
|
| 71 |
// Test setting false |
| 72 |
image.adjoin( false ); |
| 73 |
if ( image.adjoin() != false ) |
| 74 |
{ |
| 75 |
++failures; |
| 76 |
cout << "Line: " << __LINE__ << ", adjoin failed set to 'false'" << endl; |
| 77 |
} |
| 78 |
|
| 79 |
// Test setting true |
| 80 |
image.adjoin( true ); |
| 81 |
if ( image.adjoin() != true ) |
| 82 |
{ |
| 83 |
++failures; |
| 84 |
cout << "Line: " << __LINE__ << ", adjoin failed set to 'true'" << endl; |
| 85 |
} |
| 86 |
|
| 87 |
// |
| 88 |
// animationDelay |
| 89 |
// |
| 90 |
|
| 91 |
// Test default value |
| 92 |
if ( image.animationDelay() != 0 ) |
| 93 |
{ |
| 94 |
++failures; |
| 95 |
cout << "Line: " << __LINE__ << ", animationDelay default (" |
| 96 |
<< image.animationDelay() |
| 97 |
<< ") not 0 as expected" << endl; |
| 98 |
} |
| 99 |
|
| 100 |
// Test setting to 0 |
| 101 |
image.animationDelay( 0 ); |
| 102 |
if ( image.animationDelay() != 0 ) |
| 103 |
{ |
| 104 |
++failures; |
| 105 |
cout << "Line: " << __LINE__ |
| 106 |
<< ", failed to set animationDelay to 0" << endl; |
| 107 |
} |
| 108 |
|
| 109 |
// Test setting to 100 |
| 110 |
image.animationDelay( 100 ); |
| 111 |
if ( image.animationDelay() != 100 ) |
| 112 |
{ |
| 113 |
++failures; |
| 114 |
cout << "Line: " << __LINE__ |
| 115 |
<< ", failed to set animationDelay to 100" << endl; |
| 116 |
} |
| 117 |
image.animationDelay(0); |
| 118 |
|
| 119 |
// |
| 120 |
// animationIterations |
| 121 |
// |
| 122 |
|
| 123 |
// Test default value |
| 124 |
if ( image.animationIterations() != 0 ) |
| 125 |
{ |
| 126 |
++failures; |
| 127 |
cout << "Line: " << __LINE__ |
| 128 |
<< ", animationIterations default (" |
| 129 |
<< image.animationIterations() |
| 130 |
<< ") not 0 as expected" << endl; |
| 131 |
} |
| 132 |
|
| 133 |
// Test setting to 0 |
| 134 |
image.animationIterations( 0 ); |
| 135 |
if ( image.animationIterations() != 0 ) |
| 136 |
{ |
| 137 |
++failures; |
| 138 |
cout << "Line: " << __LINE__ |
| 139 |
<< ", failed to set animationIterations to 0" << endl; |
| 140 |
} |
| 141 |
|
| 142 |
// Test setting to 100 |
| 143 |
image.animationIterations( 100 ); |
| 144 |
if ( image.animationIterations() != 100 ) |
| 145 |
{ |
| 146 |
++failures; |
| 147 |
cout << "Line: " << __LINE__ |
| 148 |
<< ", failed to set animationIterations to 100" << endl; |
| 149 |
} |
| 150 |
image.animationIterations( 0 ); |
| 151 |
|
| 152 |
// |
| 153 |
// backgroundColor |
| 154 |
// |
| 155 |
|
| 156 |
// Test default value. |
| 157 |
if ( string(image.backgroundColor()) != string(ColorRGB("white")) ) |
| 158 |
{ |
| 159 |
++failures; |
| 160 |
cout << "Line: " << __LINE__ << ", backgroundColor default (" |
| 161 |
<< string(image.backgroundColor()) |
| 162 |
<< ") is incorrect" << endl; |
| 163 |
} |
| 164 |
|
| 165 |
// Test setting to blue |
| 166 |
image.backgroundColor("blue"); |
| 167 |
if ( !image.backgroundColor().isValid() ) |
| 168 |
{ |
| 169 |
++failures; |
| 170 |
cout << "Line: " << __LINE__ << ", backgroundColor (" |
| 171 |
<< string(image.backgroundColor()) |
| 172 |
<< ") failed set to 'blue'" << endl; |
| 173 |
} |
| 174 |
else |
| 175 |
if ( string(image.backgroundColor()) != "#0000FF" && |
| 176 |
string(image.backgroundColor()) != "#00000000FFFF" && |
| 177 |
string(image.backgroundColor()) != "#0000000000000000FFFFFFFF" && |
| 178 |
string(image.backgroundColor()) != "#00000000000000000000000000000000FFFFFFFFFFFFFFFF" ) |
| 179 |
{ |
| 180 |
++failures; |
| 181 |
cout << "Line: " << __LINE__ << ", backgroundColor (" |
| 182 |
<< string(image.backgroundColor()) << ") is incorrect" |
| 183 |
<< endl; |
| 184 |
} |
| 185 |
|
| 186 |
// Test setting using hex color |
| 187 |
image.backgroundColor("#00AAFF"); |
| 188 |
if ( !image.backgroundColor().isValid() ) |
| 189 |
{ |
| 190 |
++failures; |
| 191 |
cout << "Line: " << __LINE__ << ", backgroundColor (" |
| 192 |
<< string(image.backgroundColor()) |
| 193 |
<< ") is incorrectly invalid" << endl; |
| 194 |
} |
| 195 |
else |
| 196 |
if ( string(image.backgroundColor()) != "#00AAFF" && |
| 197 |
string(image.backgroundColor()) != "#0000AAAAFFFF" && |
| 198 |
string(image.backgroundColor()) != "#00000000AAAAAAAAFFFFFFFF" && |
| 199 |
string(image.backgroundColor()) != "#0000000000000000AAAAAAAAAAAAAAAAFFFFFFFFFFFFFFFF" ) |
| 200 |
{ |
| 201 |
++failures; |
| 202 |
cout << "Line: " << __LINE__ |
| 203 |
<< ", backgroundColor (" |
| 204 |
<< string(image.backgroundColor()) |
| 205 |
<< ") is incorrect" |
| 206 |
<< endl; |
| 207 |
} |
| 208 |
|
| 209 |
// |
| 210 |
// backgroundTexture |
| 211 |
// |
| 212 |
|
| 213 |
// Test default value |
| 214 |
if ( image.backgroundTexture() != "" ) |
| 215 |
{ |
| 216 |
++failures; |
| 217 |
cout << "Line: " << __LINE__ << ", backgroundTexture default (" |
| 218 |
<< image.backgroundTexture() |
| 219 |
<< ") is incorrect" << endl; |
| 220 |
} |
| 221 |
|
| 222 |
// Test setting/getting value |
| 223 |
image.backgroundTexture("afile.jpg"); |
| 224 |
if ( image.backgroundTexture() != "afile.jpg" ) |
| 225 |
{ |
| 226 |
++failures; |
| 227 |
cout << "Line: " << __LINE__ << ", backgroundTexture (" |
| 228 |
<< image.backgroundTexture() |
| 229 |
<< ") is incorrect" << endl; |
| 230 |
} |
| 231 |
|
| 232 |
// Test setting back to default |
| 233 |
image.backgroundTexture(""); |
| 234 |
if ( image.backgroundTexture() != "" ) |
| 235 |
{ |
| 236 |
++failures; |
| 237 |
cout << "Line: " << __LINE__ |
| 238 |
<< ", backgroundTexture (" |
| 239 |
<< image.backgroundTexture() |
| 240 |
<< ") failed to set to \"\"" << endl; |
| 241 |
} |
| 242 |
|
| 243 |
// |
| 244 |
// baseColumns |
| 245 |
// |
| 246 |
if ( image.baseColumns() != columns ) |
| 247 |
{ |
| 248 |
++failures; |
| 249 |
cout << "Line: " << __LINE__ |
| 250 |
<< ", baseColumns (" |
| 251 |
<< image.baseColumns() |
| 252 |
<< ") is not equal to " |
| 253 |
<< columns |
| 254 |
<< " as expected" |
| 255 |
<< endl; |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
// |
| 260 |
// baseFilename |
| 261 |
// |
| 262 |
// Base filename is color for xc images |
| 263 |
if ( image.baseFilename() != "xc:#FF0000" && |
| 264 |
image.baseFilename() != "xc:#FFFF00000000" && |
| 265 |
image.baseFilename() != "xc:#FFFFFFFF0000000000000000" && |
| 266 |
image.baseFilename() != "xc:#FFFFFFFFFFFFFFFF00000000000000000000000000000000") |
| 267 |
{ |
| 268 |
++failures; |
| 269 |
cout << "Line: " << __LINE__ |
| 270 |
<< ", baseFilename (" |
| 271 |
<< image.baseFilename() |
| 272 |
<< ") is incorrect" |
| 273 |
<< endl; |
| 274 |
} |
| 275 |
|
| 276 |
// |
| 277 |
// baseRows |
| 278 |
// |
| 279 |
if ( image.baseRows() != rows ) |
| 280 |
{ |
| 281 |
++failures; |
| 282 |
cout << "Line: " << __LINE__ |
| 283 |
<< ", baseRows (" |
| 284 |
<< image.baseRows() |
| 285 |
<< ") != rows (" |
| 286 |
<< rows |
| 287 |
<< ")" |
| 288 |
<< endl; |
| 289 |
} |
| 290 |
|
| 291 |
// |
| 292 |
// borderColor |
| 293 |
// |
| 294 |
if ( image.borderColor() != ColorRGB("#dfdfdf") ) |
| 295 |
{ |
| 296 |
++failures; |
| 297 |
cout << "Line: " << __LINE__ |
| 298 |
<< ", borderColor default (" |
| 299 |
<< string(image.borderColor()) |
| 300 |
<< ") is incorrect" << endl; |
| 301 |
} |
| 302 |
|
| 303 |
image.borderColor("#FF0000"); |
| 304 |
if ( image.borderColor() != Color("#FF0000") ) |
| 305 |
{ |
| 306 |
++failures; |
| 307 |
cout << "Line: " << __LINE__ |
| 308 |
<< ", failed to set borderColor (" |
| 309 |
<< string(image.borderColor()) |
| 310 |
<< ")" << endl; |
| 311 |
} |
| 312 |
|
| 313 |
image.borderColor("black"); |
| 314 |
if ( image.borderColor() != Color("#000000") ) |
| 315 |
{ |
| 316 |
++failures; |
| 317 |
cout << "Line: " << __LINE__ |
| 318 |
<< ", failed to set borderColor (" |
| 319 |
<< string(image.borderColor()) |
| 320 |
<< ")" |
| 321 |
<< endl; |
| 322 |
} |
| 323 |
|
| 324 |
// |
| 325 |
// boxColor |
| 326 |
// |
| 327 |
image.boxColor("#FF0000"); |
| 328 |
if ( image.boxColor() != Color("#FF0000") ) |
| 329 |
{ |
| 330 |
++failures; |
| 331 |
cout << "Line: " << __LINE__ |
| 332 |
<< ", failed to set boxColor (" |
| 333 |
<< string(image.boxColor()) |
| 334 |
<< ")" |
| 335 |
<< endl; |
| 336 |
} |
| 337 |
|
| 338 |
image.boxColor("black"); |
| 339 |
if ( image.boxColor() != Color("#000000") ) |
| 340 |
{ |
| 341 |
++failures; |
| 342 |
cout << "Line: " << __LINE__ |
| 343 |
<< ", failed to set boxColor (" |
| 344 |
<< string(image.boxColor()) |
| 345 |
<< ") to #000000" |
| 346 |
<< endl; |
| 347 |
} |
| 348 |
|
| 349 |
// |
| 350 |
// chromaBluePrimary |
| 351 |
// |
| 352 |
{ |
| 353 |
// Test default setting |
| 354 |
double x, y, z; |
| 355 |
image.chromaBluePrimary(&x, &y, &z); |
| 356 |
if ( x == 0.0f || y == 0.0f ) |
| 357 |
{ |
| 358 |
++failures; |
| 359 |
cout << "Line: " << __LINE__ |
| 360 |
<< ", chromaBluePrimary x/y defaults are zero" |
| 361 |
<< endl; |
| 362 |
} |
| 363 |
|
| 364 |
// Test set/get |
| 365 |
image.chromaBluePrimary(50, 100, 150 ); |
| 366 |
image.chromaBluePrimary(&x, &y, &z); |
| 367 |
if ( x != 50 || y != 100 || z != 150 ) |
| 368 |
{ |
| 369 |
++failures; |
| 370 |
cout << "Line: " << __LINE__ |
| 371 |
<< ", chromaBluePrimary x/y failed set/get" << endl; |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
// |
| 376 |
// chromaGreenPrimary |
| 377 |
// |
| 378 |
{ |
| 379 |
// Test default setting |
| 380 |
double x, y, z; |
| 381 |
image.chromaGreenPrimary(&x, &y, &z); |
| 382 |
if ( x == 0.0f || y == 0.0f ) |
| 383 |
{ |
| 384 |
++failures; |
| 385 |
cout << "Line: " << __LINE__ |
| 386 |
<< ", chromaGreenPrimary x/y defaults are zero" << endl; |
| 387 |
} |
| 388 |
|
| 389 |
// Test set/get |
| 390 |
image.chromaGreenPrimary(50, 100, 150); |
| 391 |
image.chromaGreenPrimary(&x, &y, &z); |
| 392 |
if (x != 50 || y != 100 || z != 150) |
| 393 |
{ |
| 394 |
++failures; |
| 395 |
cout << "Line: " << __LINE__ |
| 396 |
<< ", chromaGreenPrimary x/y failed set/get" << endl; |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
// |
| 401 |
// chromaRedPrimary |
| 402 |
// |
| 403 |
{ |
| 404 |
// Test default setting |
| 405 |
double x, y, z; |
| 406 |
image.chromaRedPrimary(&x, &y, &z); |
| 407 |
if ( x == 0.0f || y == 0.0f ) |
| 408 |
{ |
| 409 |
++failures; |
| 410 |
cout << "Line: " << __LINE__ |
| 411 |
<< ", chromaRedPrimary x/y defaults are zero" << endl; |
| 412 |
} |
| 413 |
|
| 414 |
// Test set/get |
| 415 |
image.chromaRedPrimary(50, 100, 150); |
| 416 |
image.chromaRedPrimary(&x, &y, &z); |
| 417 |
if (x != 50 || y != 100 || z != 150) |
| 418 |
{ |
| 419 |
++failures; |
| 420 |
cout << "Line: " << __LINE__ |
| 421 |
<< ", chromaRedPrimary x/y failed set/get" << endl; |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
// |
| 426 |
// chromaWhitePoint |
| 427 |
// |
| 428 |
{ |
| 429 |
// Test default setting |
| 430 |
double x, y, z; |
| 431 |
image.chromaWhitePoint(&x, &y, &z); |
| 432 |
if ( x == 0.0f || y == 0.0f ) |
| 433 |
{ |
| 434 |
++failures; |
| 435 |
cout << "Line: " << __LINE__ |
| 436 |
<< ", chromaWhitePoint x/y defaults are zero" << endl; |
| 437 |
} |
| 438 |
|
| 439 |
// Test set/get |
| 440 |
image.chromaWhitePoint(50, 100, 150); |
| 441 |
image.chromaWhitePoint(&x, &y, &z); |
| 442 |
if (x != 50 || y != 100 || z != 150) |
| 443 |
{ |
| 444 |
++failures; |
| 445 |
cout << "Line: " << __LINE__ |
| 446 |
<< ", chromaWhitePoint x/y failed set/get" << endl; |
| 447 |
} |
| 448 |
} |
| 449 |
|
| 450 |
// |
| 451 |
// classType |
| 452 |
// |
| 453 |
if ( image.classType() != DirectClass ) |
| 454 |
{ |
| 455 |
++failures; |
| 456 |
cout << "Line: " << __LINE__ << ", classType is not DirectClass" << endl; |
| 457 |
} |
| 458 |
|
| 459 |
// |
| 460 |
// colorFuzz |
| 461 |
// |
| 462 |
|
| 463 |
// Test default |
| 464 |
if ( image.colorFuzz() != 0 ) |
| 465 |
{ |
| 466 |
++failures; |
| 467 |
cout << "Line: " << __LINE__ << ", colorFuzz default is non-zero" << endl; |
| 468 |
} |
| 469 |
|
| 470 |
// Test set/get |
| 471 |
image.colorFuzz( 2 ); |
| 472 |
if ( image.colorFuzz() != 2 ) |
| 473 |
{ |
| 474 |
++failures; |
| 475 |
cout << "Line: " << __LINE__ << ", colorFuzz failed to set/get" << endl; |
| 476 |
} |
| 477 |
image.colorFuzz( 0 ); |
| 478 |
|
| 479 |
// |
| 480 |
// columns |
| 481 |
// |
| 482 |
if ( image.columns() != columns ) |
| 483 |
{ |
| 484 |
++failures; |
| 485 |
cout << "Line: " << __LINE__ |
| 486 |
<< ", columns is not equal to canvas image columns" << endl; |
| 487 |
} |
| 488 |
|
| 489 |
// |
| 490 |
// comment |
| 491 |
// |
| 492 |
// Test default |
| 493 |
if ( image.comment().length() != 0 ) |
| 494 |
{ |
| 495 |
++failures; |
| 496 |
cout << "Line: " << __LINE__ |
| 497 |
<< ", comment default non-zero length" << endl; |
| 498 |
} |
| 499 |
|
| 500 |
// Test set/get |
| 501 |
{ |
| 502 |
std::string comment("This is a comment."); |
| 503 |
image.comment( comment ); |
| 504 |
if ( image.comment() != comment ) |
| 505 |
{ |
| 506 |
++failures; |
| 507 |
cout << "Line: " << __LINE__ << ", comment set/get failed" << endl; |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
// Test resetting comment |
| 512 |
image.comment( string() ); |
| 513 |
if ( image.comment().length() != 0 ) |
| 514 |
{ |
| 515 |
++failures; |
| 516 |
cout << "Line: " << __LINE__ << ", comment failed to reset" << endl; |
| 517 |
} |
| 518 |
|
| 519 |
// |
| 520 |
// compressType |
| 521 |
// |
| 522 |
// Test default |
| 523 |
if ( image.compressType() != UndefinedCompression ) |
| 524 |
{ |
| 525 |
++failures; |
| 526 |
cout << "Line: " << __LINE__ |
| 527 |
<< ", compressType default is incorrect" << endl; |
| 528 |
} |
| 529 |
|
| 530 |
// Test set/get |
| 531 |
image.compressType(RLECompression); |
| 532 |
if ( image.compressType() != RLECompression ) |
| 533 |
{ |
| 534 |
++failures; |
| 535 |
cout << "Line: " << __LINE__ << ", compressType set/get failed" << endl; |
| 536 |
} |
| 537 |
image.compressType(UndefinedCompression); |
| 538 |
|
| 539 |
// |
| 540 |
// density |
| 541 |
// |
| 542 |
{ |
| 543 |
// Test defaults |
| 544 |
if ( image.density() != Point(72) ) |
| 545 |
{ |
| 546 |
++failures; |
| 547 |
cout << "Line: " << __LINE__ |
| 548 |
<< ", density default is not 72x72 as expected" << endl; |
| 549 |
} |
| 550 |
|
| 551 |
// Test set/get |
| 552 |
Point density(150,75); |
| 553 |
image.density(density); |
| 554 |
if ( image.density() != density ) |
| 555 |
{ |
| 556 |
++failures; |
| 557 |
cout << "Line: " << __LINE__ << ", density set/get failed" << endl; |
| 558 |
} |
| 559 |
|
| 560 |
|
| 561 |
if ( image.xResolution() != 150 || |
| 562 |
image.yResolution() != 75 ) |
| 563 |
{ |
| 564 |
++failures; |
| 565 |
cout << "Line: " << __LINE__ << ", density set/get failed" << endl; |
| 566 |
} |
| 567 |
|
| 568 |
image.density("72x72"); |
| 569 |
|
| 570 |
} |
| 571 |
|
| 572 |
// |
| 573 |
// Format specific defines |
| 574 |
// |
| 575 |
if (image.defineSet("foo","bar")) |
| 576 |
{ |
| 577 |
++failures; |
| 578 |
cout << "Line: " << __LINE__ |
| 579 |
<< ", define for foo:bar incorrectly reports set." |
| 580 |
<< endl; |
| 581 |
} |
| 582 |
|
| 583 |
image.defineSet("foo","bar",true); |
| 584 |
if (!image.defineSet("foo","bar")) |
| 585 |
{ |
| 586 |
++failures; |
| 587 |
cout << "Line: " << __LINE__ |
| 588 |
<< ", define for foo:bar incorrectly reports not set." |
| 589 |
<< endl; |
| 590 |
} |
| 591 |
|
| 592 |
image.defineSet("foo","bar",false); |
| 593 |
if (image.defineSet("foo","bar")) |
| 594 |
{ |
| 595 |
++failures; |
| 596 |
cout << "Line: " << __LINE__ |
| 597 |
<< ", define for foo:bar incorrectly reports set." |
| 598 |
<< endl; |
| 599 |
} |
| 600 |
|
| 601 |
image.defineValue("foo","bar","value"); |
| 602 |
std::string value = image.defineValue("foo","bar"); |
| 603 |
if (image.defineValue("foo","bar") != "value") |
| 604 |
{ |
| 605 |
++failures; |
| 606 |
cout << "Line: " << __LINE__ |
| 607 |
<< ", define for foo:bar incorrectly reports value \"" |
| 608 |
<< value << "\"" |
| 609 |
<< endl; |
| 610 |
} |
| 611 |
|
| 612 |
image.defineSet("foo","bar",false); |
| 613 |
if (image.defineSet("foo","bar")) |
| 614 |
{ |
| 615 |
++failures; |
| 616 |
cout << "Line: " << __LINE__ |
| 617 |
<< ", define for foo:bar incorrectly reports set." |
| 618 |
<< endl; |
| 619 |
} |
| 620 |
|
| 621 |
// |
| 622 |
// depth |
| 623 |
// |
| 624 |
if ( image.depth() != MAGICKCORE_QUANTUM_DEPTH ) |
| 625 |
{ |
| 626 |
++failures; |
| 627 |
cout << "Line: " << __LINE__ |
| 628 |
<< ", depth (" |
| 629 |
<< image.depth() |
| 630 |
<< ") is not equal to " << MAGICKCORE_QUANTUM_DEPTH << endl; |
| 631 |
} |
| 632 |
|
| 633 |
// |
| 634 |
// Directory |
| 635 |
// |
| 636 |
{ |
| 637 |
// Since this is not a montage image, simply verify error report |
| 638 |
bool caughtException = false; |
| 639 |
cout << "Testing throwing and catching exceptions. A program crash or a message" << endl |
| 640 |
<< "that the exception was not caught indicates a test failure. A properly" << endl |
| 641 |
<< "formatted exception message indicates success:" << endl; |
| 642 |
try |
| 643 |
{ |
| 644 |
//image.directory(); |
| 645 |
Magick::Image bad_image("foo"); |
| 646 |
} |
| 647 |
catch ( Exception &exception_) |
| 648 |
{ |
| 649 |
cout << "Caught exception, good!:" << endl |
| 650 |
<< " \"" << exception_.what() << "\"" << endl; |
| 651 |
caughtException = true; |
| 652 |
} |
| 653 |
if ( caughtException != true ) |
| 654 |
{ |
| 655 |
++failures; |
| 656 |
cout << "failed to catch exception!" << endl; |
| 657 |
} |
| 658 |
} |
| 659 |
|
| 660 |
// |
| 661 |
// fileName |
| 662 |
// |
| 663 |
// Test default |
| 664 |
if ( image.fileName() != string("xc:") + string(canvasColor) ) |
| 665 |
{ |
| 666 |
++failures; |
| 667 |
cout << "Line: " |
| 668 |
<< __LINE__ |
| 669 |
<< ", fileName (" |
| 670 |
<< image.fileName() |
| 671 |
<< ") is not canvas color (" |
| 672 |
<< string(canvasColor) |
| 673 |
<<") as expected" << endl; |
| 674 |
} |
| 675 |
|
| 676 |
// Set/get value |
| 677 |
image.fileName("filename.jpg"); |
| 678 |
if ( image.fileName() != "filename.jpg" ) |
| 679 |
{ |
| 680 |
++failures; |
| 681 |
cout << "Line: " |
| 682 |
<< __LINE__ |
| 683 |
<< ", fileName (" |
| 684 |
<< image.fileName() |
| 685 |
<< ") failed to set/get" << endl; |
| 686 |
} |
| 687 |
image.fileName(canvasColor); |
| 688 |
|
| 689 |
// |
| 690 |
// fileSize |
| 691 |
// |
| 692 |
// Test default |
| 693 |
if ( image.fileSize() != 0 ) |
| 694 |
{ |
| 695 |
++failures; |
| 696 |
cout << "Line: " << __LINE__ << ", fileSize (" |
| 697 |
<< static_cast<ssize_t>(image.fileSize()) |
| 698 |
<< ") is not zero as expected" << endl; |
| 699 |
} |
| 700 |
|
| 701 |
// |
| 702 |
// filterType |
| 703 |
// |
| 704 |
// Test default |
| 705 |
if ( image.filterType() != UndefinedFilter ) |
| 706 |
{ |
| 707 |
++failures; |
| 708 |
cout << "Line: " << __LINE__ |
| 709 |
<< ", filterType default (" |
| 710 |
<< (int)image.filterType() |
| 711 |
<< ") is incorrect" << endl; |
| 712 |
} |
| 713 |
|
| 714 |
// Test set/get |
| 715 |
image.filterType( TriangleFilter ); |
| 716 |
if ( image.filterType() != TriangleFilter ) |
| 717 |
{ |
| 718 |
++failures; |
| 719 |
cout << "Line: " << __LINE__ << ", filterType set/get failed" |
| 720 |
<< endl; |
| 721 |
} |
| 722 |
|
| 723 |
// |
| 724 |
// font |
| 725 |
// |
| 726 |
|
| 727 |
// Test set/get |
| 728 |
image.font("helvetica"); |
| 729 |
if ( image.font() != "helvetica" ) |
| 730 |
{ |
| 731 |
++failures; |
| 732 |
cout << "Line: " << __LINE__ << ", font set/get failed" << endl; |
| 733 |
} |
| 734 |
// Test set to null font |
| 735 |
image.font( string() ); |
| 736 |
if ( image.font().length() != 0 ) |
| 737 |
{ |
| 738 |
++failures; |
| 739 |
cout << "Line: " << __LINE__ << ", font failed to unset" << endl; |
| 740 |
} |
| 741 |
|
| 742 |
// |
| 743 |
// fontPointsize |
| 744 |
// |
| 745 |
// Test default |
| 746 |
if ( image.fontPointsize() != 0 ) |
| 747 |
{ |
| 748 |
++failures; |
| 749 |
cout << "Line: " << __LINE__ |
| 750 |
<< ", fontPointsize (" |
| 751 |
<< image.fontPointsize() |
| 752 |
<< ") is not default of 0 as expected" |
| 753 |
<< endl; |
| 754 |
} |
| 755 |
|
| 756 |
// Test set/get |
| 757 |
image.fontPointsize(10); |
| 758 |
if ( image.fontPointsize() != 10 ) |
| 759 |
{ |
| 760 |
++failures; |
| 761 |
cout << "Line: " << __LINE__ |
| 762 |
<< ", fontPointsize set/get failed" << endl; |
| 763 |
} |
| 764 |
image.fontPointsize(12); |
| 765 |
|
| 766 |
// |
| 767 |
// format |
| 768 |
// |
| 769 |
if ( image.format() != "Constant image uniform color" ) |
| 770 |
{ |
| 771 |
++failures; |
| 772 |
cout << "Line: " << __LINE__ |
| 773 |
<< ", format (" << image.format() << ") is not expected value" << endl; |
| 774 |
} |
| 775 |
|
| 776 |
// |
| 777 |
// gamma |
| 778 |
// |
| 779 |
if ( image.gamma() == 1.0f) |
| 780 |
{ |
| 781 |
++failures; |
| 782 |
cout << "Line: " << __LINE__ |
| 783 |
<< ", gamma correction is unity as expected" << endl; |
| 784 |
} |
| 785 |
|
| 786 |
// |
| 787 |
// geometry |
| 788 |
// |
| 789 |
{ |
| 790 |
bool caughtException = false; |
| 791 |
try |
| 792 |
{ |
| 793 |
image.geometry(); |
| 794 |
} |
| 795 |
catch ( Exception& ) |
| 796 |
{ |
| 797 |
caughtException = true; |
| 798 |
} |
| 799 |
if ( caughtException != true ) |
| 800 |
{ |
| 801 |
++failures; |
| 802 |
cout << "Line: " << __LINE__ |
| 803 |
<< ", geometry failed to report missing image geometry"; |
| 804 |
} |
| 805 |
} |
| 806 |
|
| 807 |
// |
| 808 |
// gifDisposeMethod |
| 809 |
// |
| 810 |
// Test default |
| 811 |
if ( image.gifDisposeMethod() != 0 ) |
| 812 |
{ |
| 813 |
++failures; |
| 814 |
cout << "Line: " << __LINE__ |
| 815 |
<< ", gifDisposeMethod default is not zero as expected" << endl; |
| 816 |
} |
| 817 |
|
| 818 |
// Test set/get |
| 819 |
image.gifDisposeMethod(BackgroundDispose); |
| 820 |
if ( image.gifDisposeMethod() != BackgroundDispose ) |
| 821 |
{ |
| 822 |
++failures; |
| 823 |
cout << "Line: " << __LINE__ |
| 824 |
<< ", gifDisposeMethod set/get failed" << endl; |
| 825 |
} |
| 826 |
image.gifDisposeMethod(UndefinedDispose); |
| 827 |
|
| 828 |
// |
| 829 |
// interlaceType |
| 830 |
// |
| 831 |
// Test default |
| 832 |
if ( image.interlaceType() != NoInterlace ) |
| 833 |
{ |
| 834 |
++failures; |
| 835 |
cout << "Line: " << __LINE__ |
| 836 |
<< ", interlaceType default is not NoInterlace as expected" << endl; |
| 837 |
} |
| 838 |
|
| 839 |
// Test set/get |
| 840 |
image.interlaceType( PlaneInterlace ); |
| 841 |
if ( image.interlaceType() != PlaneInterlace ) |
| 842 |
{ |
| 843 |
++failures; |
| 844 |
cout << "Line: " << __LINE__ << ", interlaceType set/get failed" << endl; |
| 845 |
} |
| 846 |
image.interlaceType(NoInterlace); |
| 847 |
|
| 848 |
// |
| 849 |
// label |
| 850 |
// |
| 851 |
// Test default |
| 852 |
if ( image.label().length() != 0 ) |
| 853 |
{ |
| 854 |
++failures; |
| 855 |
cout << "Line: " << __LINE__ |
| 856 |
<< ", label default is not empty string as expected" << endl; |
| 857 |
} |
| 858 |
|
| 859 |
// Test set/get |
| 860 |
image.label("How now brown cow?"); |
| 861 |
if ( image.label() != "How now brown cow?" ) |
| 862 |
{ |
| 863 |
++failures; |
| 864 |
cout << "Line: " << __LINE__ << ", label set/get failed" << endl; |
| 865 |
} |
| 866 |
// Test set to default |
| 867 |
image.label( string() ); |
| 868 |
if ( image.label().length() != 0 ) |
| 869 |
{ |
| 870 |
++failures; |
| 871 |
cout << "Line: " << __LINE__ << ", label failed to unset" << endl; |
| 872 |
} |
| 873 |
|
| 874 |
// |
| 875 |
// strokeWidth |
| 876 |
// |
| 877 |
// Test default |
| 878 |
if ( image.strokeWidth() != 1 ) |
| 879 |
{ |
| 880 |
++failures; |
| 881 |
cout << "Line: " << __LINE__ |
| 882 |
<< ", strokeWidth default is not 1 as expected" << endl; |
| 883 |
} |
| 884 |
|
| 885 |
// Test set/get |
| 886 |
image.strokeWidth(2); |
| 887 |
if ( image.strokeWidth() != 2 ) |
| 888 |
{ |
| 889 |
++failures; |
| 890 |
cout << "Line: " << __LINE__ << ", strokeWidth set/get failed" << endl; |
| 891 |
} |
| 892 |
image.strokeWidth(1); |
| 893 |
|
| 894 |
// |
| 895 |
// magick |
| 896 |
// |
| 897 |
// Test canvas default |
| 898 |
if ( image.magick() != "XC" ) |
| 899 |
{ |
| 900 |
++failures; |
| 901 |
cout << "Line: " << __LINE__ |
| 902 |
<< ", magick canvas default is not XC as expected" << endl; |
| 903 |
} |
| 904 |
|
| 905 |
// Test set/get |
| 906 |
image.magick("GIF"); |
| 907 |
if ( image.magick() != "GIF" ) |
| 908 |
{ |
| 909 |
++failures; |
| 910 |
cout << "Line: " << __LINE__ << ", magick set/get failed" << endl; |
| 911 |
} |
| 912 |
|
| 913 |
image.magick("XC"); |
| 914 |
|
| 915 |
// |
| 916 |
// alpha |
| 917 |
// |
| 918 |
// Test default |
| 919 |
if ( image.alpha() != false ) |
| 920 |
{ |
| 921 |
++failures; |
| 922 |
cout << "Line: " << __LINE__ |
| 923 |
<< ", alpha default is not false as expected" << endl; |
| 924 |
} |
| 925 |
|
| 926 |
// Test set/get |
| 927 |
image.alpha(true); |
| 928 |
if ( image.alpha() != true ) |
| 929 |
{ |
| 930 |
++failures; |
| 931 |
cout << "Line: " << __LINE__ << ", alpha set/get failed" << endl; |
| 932 |
} |
| 933 |
image.alpha(false); |
| 934 |
|
| 935 |
// |
| 936 |
// matteColor |
| 937 |
// |
| 938 |
// Test default |
| 939 |
if ( image.matteColor() != Color("#BDBDBD") ) |
| 940 |
{ |
| 941 |
++failures; |
| 942 |
cout << "Line: " << __LINE__ |
| 943 |
<< ", matteColor default is not #BDBDBD as expected" << endl; |
| 944 |
} |
| 945 |
|
| 946 |
// Test set/get |
| 947 |
image.matteColor(ColorRGB(0.5,0.5,1)); |
| 948 |
if ( image.matteColor() != ColorRGB(0.5,0.5,1) ) |
| 949 |
{ |
| 950 |
++failures; |
| 951 |
cout << "Line: " << __LINE__ << ", matteColor set/get failed" << endl; |
| 952 |
} |
| 953 |
|
| 954 |
// Test unset |
| 955 |
image.matteColor( Color() ); |
| 956 |
|
| 957 |
image.matteColor("#BDBDBD"); |
| 958 |
|
| 959 |
// |
| 960 |
// meanErrorPerPixel |
| 961 |
// |
| 962 |
if ( image.meanErrorPerPixel() != 0 ) |
| 963 |
{ |
| 964 |
++failures; |
| 965 |
cout << "Line: " << __LINE__ |
| 966 |
<< ", meanErrorPerPixel is not zero as expected" << endl; |
| 967 |
} |
| 968 |
|
| 969 |
// |
| 970 |
// montageGeometry |
| 971 |
// |
| 972 |
{ |
| 973 |
bool caughtException = false; |
| 974 |
try |
| 975 |
{ |
| 976 |
image.montageGeometry(); |
| 977 |
} |
| 978 |
catch ( Exception& ) |
| 979 |
{ |
| 980 |
caughtException = true; |
| 981 |
} |
| 982 |
if ( caughtException != true ) |
| 983 |
{ |
| 984 |
++failures; |
| 985 |
cout << "Line: " << __LINE__ |
| 986 |
<< ", montageGeometry failed to report missing montage geometry"; |
| 987 |
} |
| 988 |
} |
| 989 |
|
| 990 |
// |
| 991 |
// monochrome |
| 992 |
// |
| 993 |
// Test default |
| 994 |
if ( image.monochrome() != false ) |
| 995 |
{ |
| 996 |
++failures; |
| 997 |
cout << "Line: " << __LINE__ |
| 998 |
<< ", monochrome is not false as expected" << endl; |
| 999 |
} |
| 1000 |
|
| 1001 |
// Test set/get |
| 1002 |
image.monochrome(true); |
| 1003 |
if ( image.monochrome() != true ) |
| 1004 |
{ |
| 1005 |
++failures; |
| 1006 |
cout << "Line: " << __LINE__ << ", monochrome get/set failed" << endl; |
| 1007 |
} |
| 1008 |
image.monochrome(false); |
| 1009 |
|
| 1010 |
// |
| 1011 |
// normalizedMaxError |
| 1012 |
// |
| 1013 |
if ( image.normalizedMaxError() != 0 ) |
| 1014 |
{ |
| 1015 |
++failures; |
| 1016 |
cout << "Line: " << __LINE__ |
| 1017 |
<< ",normalizedMaxError is not zero as expected" << endl; |
| 1018 |
} |
| 1019 |
|
| 1020 |
// |
| 1021 |
// normalizedMeanError |
| 1022 |
// |
| 1023 |
if ( image.normalizedMeanError() != 0 ) |
| 1024 |
{ |
| 1025 |
++failures; |
| 1026 |
cout << "Line: " << __LINE__ |
| 1027 |
<< ", normalizedMeanError is not zero as expected" << endl; |
| 1028 |
} |
| 1029 |
|
| 1030 |
// |
| 1031 |
// strokeColor |
| 1032 |
// |
| 1033 |
|
| 1034 |
image.strokeColor(ColorRGB(0.5,0.5,1)); |
| 1035 |
if ( image.strokeColor() != ColorRGB(0.5,0.5,1) ) |
| 1036 |
{ |
| 1037 |
++failures; |
| 1038 |
cout << "Line: " << __LINE__ << ", strokeColor (" |
| 1039 |
<< string(image.strokeColor()) |
| 1040 |
<< ") set/get failed" << endl; |
| 1041 |
} |
| 1042 |
|
| 1043 |
|
| 1044 |
// |
| 1045 |
// fillColor |
| 1046 |
// |
| 1047 |
|
| 1048 |
image.fillColor(ColorRGB(0.5,0.5,1)); |
| 1049 |
if ( image.fillColor() != ColorRGB(0.5,0.5,1) ) |
| 1050 |
{ |
| 1051 |
++failures; |
| 1052 |
cout << "Line: " << __LINE__ << ", fillColor (" |
| 1053 |
<< string(image.fillColor()) |
| 1054 |
<< ") set/get failed" << endl; |
| 1055 |
} |
| 1056 |
|
| 1057 |
// |
| 1058 |
// pixelColor |
| 1059 |
// |
| 1060 |
// Test default |
| 1061 |
if ( image.pixelColor(40,60) != string(canvasColor) ) |
| 1062 |
{ |
| 1063 |
++failures; |
| 1064 |
cout << "Line: " << __LINE__ << ", pixelColor default (" |
| 1065 |
<< string(image.pixelColor(40,60)) |
| 1066 |
<< ") is not canvas color (" |
| 1067 |
<< string(canvasColor) |
| 1068 |
<< ") as expected" << endl; |
| 1069 |
} |
| 1070 |
|
| 1071 |
// Test set/get |
| 1072 |
image.pixelColor(40,60, ColorRGB(0.5,1,1)); |
| 1073 |
if ( image.pixelColor(40,60) != ColorRGB(0.5,1,1) ) |
| 1074 |
{ |
| 1075 |
++failures; |
| 1076 |
cout << "Line: " << __LINE__ << ", pixelColor set/get failed" << endl; |
| 1077 |
} |
| 1078 |
|
| 1079 |
// |
| 1080 |
// page |
| 1081 |
// |
| 1082 |
// Test default |
| 1083 |
if ( image.page() != Geometry(640,480,0,0) ) |
| 1084 |
{ |
| 1085 |
++failures; |
| 1086 |
cout << "Line: " << __LINE__ << ", page default " |
| 1087 |
<< "(" << string(image.page()) << ")" |
| 1088 |
<< " is not 640x480 as expected" << endl; |
| 1089 |
} |
| 1090 |
|
| 1091 |
// Test set/get |
| 1092 |
image.page("letter+43+43>"); |
| 1093 |
if ( image.page() != "612x792+43+43" ) |
| 1094 |
{ |
| 1095 |
++failures; |
| 1096 |
cout << "Line: " << __LINE__ |
| 1097 |
<< ", page set/get failed (" << string(image.page()) << ")" << endl; |
| 1098 |
} |
| 1099 |
|
| 1100 |
// |
| 1101 |
// quality |
| 1102 |
// |
| 1103 |
// Test default |
| 1104 |
if ( image.quality() != 0 ) |
| 1105 |
{ |
| 1106 |
++failures; |
| 1107 |
cout << "Line: " << __LINE__ |
| 1108 |
<< ", quality default is not 0 as expected" << endl; |
| 1109 |
} |
| 1110 |
|
| 1111 |
// Test set/get |
| 1112 |
image.quality(65); |
| 1113 |
if ( image.quality() != 65 ) |
| 1114 |
{ |
| 1115 |
++failures; |
| 1116 |
cout << "Line: " << __LINE__ << ", quality set/get failed" << endl; |
| 1117 |
} |
| 1118 |
image.quality(0); |
| 1119 |
|
| 1120 |
// |
| 1121 |
// quantizeColors |
| 1122 |
// |
| 1123 |
// Test default |
| 1124 |
if ( image.quantizeColors() != 256 ) |
| 1125 |
{ |
| 1126 |
++failures; |
| 1127 |
cout << "Line: " << __LINE__ |
| 1128 |
<< ", quantizeColors is not 256 as expected" << endl; |
| 1129 |
} |
| 1130 |
|
| 1131 |
// Test set/get |
| 1132 |
image.quantizeColors(200); |
| 1133 |
if ( image.quantizeColors() != 200 ) |
| 1134 |
{ |
| 1135 |
++failures; |
| 1136 |
cout << "Line: " << __LINE__ << ", quantizeColors set/get failed" << endl; |
| 1137 |
} |
| 1138 |
image.quantizeColors(0); |
| 1139 |
|
| 1140 |
// |
| 1141 |
// quantizeColorSpace |
| 1142 |
// |
| 1143 |
// Test default |
| 1144 |
if ( image.quantizeColorSpace() != UndefinedColorspace ) |
| 1145 |
{ |
| 1146 |
++failures; |
| 1147 |
cout << "Line: " << __LINE__ |
| 1148 |
<< ", quantizeColorSpace is not RGBColorspace as expected" << endl; |
| 1149 |
} |
| 1150 |
|
| 1151 |
// Test set/get |
| 1152 |
image.quantizeColorSpace(YIQColorspace); |
| 1153 |
if ( image.quantizeColorSpace() != YIQColorspace ) |
| 1154 |
{ |
| 1155 |
++failures; |
| 1156 |
cout << "Line: " << __LINE__ |
| 1157 |
<< ", quantizeColorSpace set/get failed" << endl; |
| 1158 |
} |
| 1159 |
image.quantizeColorSpace(RGBColorspace); |
| 1160 |
|
| 1161 |
// |
| 1162 |
// quantizeDither |
| 1163 |
// |
| 1164 |
// Test default |
| 1165 |
if ( image.quantizeDither() == false ) |
| 1166 |
{ |
| 1167 |
++failures; |
| 1168 |
cout << "Line: " << __LINE__ |
| 1169 |
<< ", quantizeDither is not false as expected" << endl; |
| 1170 |
} |
| 1171 |
|
| 1172 |
// Test set/get |
| 1173 |
image.quantizeDither(false); |
| 1174 |
if ( image.quantizeDither() != false ) |
| 1175 |
{ |
| 1176 |
++failures; |
| 1177 |
cout << "Line: " << __LINE__ |
| 1178 |
<< ", quantizeDither get/set failed" << endl; |
| 1179 |
} |
| 1180 |
image.quantizeDither(true); |
| 1181 |
|
| 1182 |
// |
| 1183 |
// quantizeTreeDepth |
| 1184 |
// |
| 1185 |
if ( image.quantizeTreeDepth() != 0 ) |
| 1186 |
{ |
| 1187 |
++failures; |
| 1188 |
cout << "Line: " << __LINE__ << ", quantizeTreeDepth default is " |
| 1189 |
<< image.quantizeTreeDepth() |
| 1190 |
<< " rather than zero as expected" << endl; |
| 1191 |
} |
| 1192 |
|
| 1193 |
image.quantizeTreeDepth(7); |
| 1194 |
if ( image.quantizeTreeDepth() != 7 ) |
| 1195 |
{ |
| 1196 |
++failures; |
| 1197 |
cout << "Line: " << __LINE__ |
| 1198 |
<< ", quantizeTreeDepth set/get failed" << endl; |
| 1199 |
} |
| 1200 |
image.quantizeTreeDepth(8); |
| 1201 |
|
| 1202 |
// |
| 1203 |
// renderingIntent |
| 1204 |
// |
| 1205 |
if ( image.renderingIntent() == UndefinedIntent ) |
| 1206 |
{ |
| 1207 |
++failures; |
| 1208 |
cout << "Line: " << __LINE__ |
| 1209 |
<< ", renderingIntent default is UndefinedIntent as expected" |
| 1210 |
<< endl; |
| 1211 |
} |
| 1212 |
|
| 1213 |
image.renderingIntent(PerceptualIntent); |
| 1214 |
if ( image.renderingIntent() != PerceptualIntent ) |
| 1215 |
{ |
| 1216 |
++failures; |
| 1217 |
cout << "Line: " << __LINE__ |
| 1218 |
<< ", renderingIntent set/get failed" << endl; |
| 1219 |
} |
| 1220 |
image.renderingIntent(UndefinedIntent); |
| 1221 |
|
| 1222 |
// |
| 1223 |
// resolutionUnits |
| 1224 |
// |
| 1225 |
if ( image.resolutionUnits() != UndefinedResolution ) |
| 1226 |
{ |
| 1227 |
++failures; |
| 1228 |
cout << "Line: " << __LINE__ |
| 1229 |
<< ", resolutionUnits default is not UndefinedResolution as expected" |
| 1230 |
<< endl; |
| 1231 |
} |
| 1232 |
|
| 1233 |
image.resolutionUnits(PixelsPerCentimeterResolution); |
| 1234 |
if ( image.resolutionUnits() != PixelsPerCentimeterResolution ) |
| 1235 |
{ |
| 1236 |
++failures; |
| 1237 |
cout << "Line: " << __LINE__ |
| 1238 |
<< ", resolutionUnits set/get failed" << endl; |
| 1239 |
} |
| 1240 |
image.resolutionUnits(UndefinedResolution); |
| 1241 |
|
| 1242 |
// |
| 1243 |
// rows |
| 1244 |
// |
| 1245 |
if ( image.rows() != rows ) |
| 1246 |
{ |
| 1247 |
++failures; |
| 1248 |
cout << "Line: " << __LINE__ |
| 1249 |
<< ", rows is canvas rows as expected" << endl; |
| 1250 |
} |
| 1251 |
|
| 1252 |
// |
| 1253 |
// scene |
| 1254 |
// |
| 1255 |
if ( image.scene() != 0 ) |
| 1256 |
{ |
| 1257 |
++failures; |
| 1258 |
cout << "Line: " << __LINE__ |
| 1259 |
<< ", scene default is not zero as expected" << endl; |
| 1260 |
} |
| 1261 |
|
| 1262 |
image.scene(5); |
| 1263 |
if ( image.scene() != 5 ) |
| 1264 |
{ |
| 1265 |
++failures; |
| 1266 |
cout << "Line: " << __LINE__ |
| 1267 |
<< ", scene set/get failed" << endl; |
| 1268 |
} |
| 1269 |
image.scene(0); |
| 1270 |
|
| 1271 |
// |
| 1272 |
// signature |
| 1273 |
// |
| 1274 |
|
| 1275 |
if ( |
| 1276 |
( image.signature() != "6b08f7559b92760e8945b924f514a2e997753eb4408ddf571dd5222a782b8b48") && |
| 1277 |
( image.signature() != "5e32612a0a3f2f1632d135f8c2df360604b0b84e9f082ddc20efbb0de752a53e") && |
| 1278 |
( image.signature() != "dba5480face4d9eb973a116fe32ef37a7b47211e563900d21f47d6f0904aba22") && |
| 1279 |
( image.signature() != "eccb7a8ac230b0deb76c8dd10ddeeb76a0918cbe6e3469d2d9f223d35c66498b") && |
| 1280 |
( image.signature() != "a0747a8a5a0e6a1ec960ab8994986ba087d518db97db6f17e7bb4da3bbc3c91d") && |
| 1281 |
( image.signature() != "6857675cd7d967e1e3ff094e1b3e5f4bb3fb9ba2557eb6d083d37881db0a2039") |
| 1282 |
) |
| 1283 |
{ |
| 1284 |
++failures; |
| 1285 |
cout << "Line: " << __LINE__ << ", signature (" |
| 1286 |
<< image.signature() |
| 1287 |
<< ") is incorrect" << endl; |
| 1288 |
image.display(); |
| 1289 |
} |
| 1290 |
|
| 1291 |
// |
| 1292 |
// size |
| 1293 |
// |
| 1294 |
if ( image.size() != geometry ) |
| 1295 |
{ |
| 1296 |
++failures; |
| 1297 |
cout << "Line: " << __LINE__ << ", size (" |
| 1298 |
<< string(image.size()) |
| 1299 |
<< ") is not equal to geometry (" |
| 1300 |
<< string(geometry) |
| 1301 |
<< ")" |
| 1302 |
<< endl; |
| 1303 |
} |
| 1304 |
|
| 1305 |
image.size("800x600"); |
| 1306 |
if ( image.size() != Geometry("800x600") ) |
| 1307 |
{ |
| 1308 |
++failures; |
| 1309 |
cout << "Line: " << __LINE__ << ", size set/get failed" << endl; |
| 1310 |
} |
| 1311 |
image.size( geometry ); |
| 1312 |
|
| 1313 |
// |
| 1314 |
// subImage |
| 1315 |
// |
| 1316 |
if ( image.subImage() != 0 ) |
| 1317 |
{ |
| 1318 |
++failures; |
| 1319 |
cout << "Line: " << __LINE__ |
| 1320 |
<< ", subImage default is not zero as expected" << endl; |
| 1321 |
} |
| 1322 |
|
| 1323 |
image.subImage(5); |
| 1324 |
if ( image.subImage() != 5 ) |
| 1325 |
{ |
| 1326 |
++failures; |
| 1327 |
cout << "Line: " << __LINE__ |
| 1328 |
<< ", subImage set/get failed" << endl; |
| 1329 |
} |
| 1330 |
image.subImage(0); |
| 1331 |
|
| 1332 |
// |
| 1333 |
// subRange |
| 1334 |
// |
| 1335 |
if ( image.subRange() != 0 ) |
| 1336 |
{ |
| 1337 |
++failures; |
| 1338 |
cout << "Line: " << __LINE__ |
| 1339 |
<< ", subRange default is not zero as expected" << endl; |
| 1340 |
} |
| 1341 |
|
| 1342 |
image.subRange(5); |
| 1343 |
if ( image.subRange() != 5 ) |
| 1344 |
{ |
| 1345 |
++failures; |
| 1346 |
cout << "Line: " << __LINE__ |
| 1347 |
<< ", subRange set/get failed" << endl; |
| 1348 |
} |
| 1349 |
image.subRange(0); |
| 1350 |
|
| 1351 |
// |
| 1352 |
// totalColors |
| 1353 |
// |
| 1354 |
if ( image.totalColors() != 2 ) |
| 1355 |
{ |
| 1356 |
++failures; |
| 1357 |
cout << "Line: " << __LINE__ << ", totalColors is " << image.totalColors() |
| 1358 |
<< " rather than 2 as expected" << endl; |
| 1359 |
} |
| 1360 |
|
| 1361 |
// |
| 1362 |
// type |
| 1363 |
// |
| 1364 |
image.type(PaletteType); |
| 1365 |
if ( image.type() != PaletteType ) |
| 1366 |
{ |
| 1367 |
++failures; |
| 1368 |
cout << "Line: " << __LINE__ |
| 1369 |
<< ", type is not PaletteType as expected. Reported type " |
| 1370 |
<< (int) image.type() << endl; |
| 1371 |
|
| 1372 |
} |
| 1373 |
|
| 1374 |
// |
| 1375 |
// verbose |
| 1376 |
// |
| 1377 |
if ( image.verbose() != false ) |
| 1378 |
{ |
| 1379 |
++failures; |
| 1380 |
cout << "Line: " << __LINE__ |
| 1381 |
<< ", verbose is not false as expected" << endl; |
| 1382 |
} |
| 1383 |
|
| 1384 |
// |
| 1385 |
// x11Display |
| 1386 |
// |
| 1387 |
if ( image.x11Display().length() != 0 ) |
| 1388 |
{ |
| 1389 |
++failures; |
| 1390 |
cout << "Line: " << __LINE__ |
| 1391 |
<< ", x11Display default is not empty string as expected" << endl; |
| 1392 |
} |
| 1393 |
|
| 1394 |
image.x11Display(":0.0"); |
| 1395 |
if ( image.x11Display() != ":0.0" ) |
| 1396 |
{ |
| 1397 |
++failures; |
| 1398 |
cout << "Line: " << __LINE__ |
| 1399 |
<< ", x11Display set/get failed" << endl; |
| 1400 |
} |
| 1401 |
|
| 1402 |
image.x11Display( string() ); |
| 1403 |
if ( image.x11Display().length() != 0 ) |
| 1404 |
{ |
| 1405 |
++failures; |
| 1406 |
cout << "Line: " << __LINE__ |
| 1407 |
<< ", x11Display failed to unset" << endl; |
| 1408 |
} |
| 1409 |
|
| 1410 |
// |
| 1411 |
// xResolution |
| 1412 |
// |
| 1413 |
if ( image.xResolution() != 72 ) |
| 1414 |
{ |
| 1415 |
++failures; |
| 1416 |
cout << "Line: " << __LINE__ |
| 1417 |
<< ", xResolution default (" << image.xResolution() |
| 1418 |
<< ") is not zero as expected" << endl; |
| 1419 |
} |
| 1420 |
|
| 1421 |
// |
| 1422 |
// yResolution |
| 1423 |
// |
| 1424 |
if ( image.yResolution() != 72 ) |
| 1425 |
{ |
| 1426 |
++failures; |
| 1427 |
cout << "Line: " << __LINE__ |
| 1428 |
<< ", yResolution default (" << image.yResolution() |
| 1429 |
<< ") is not zero as expected" << endl; |
| 1430 |
} |
| 1431 |
} |
| 1432 |
catch( Exception &error_ ) |
| 1433 |
{ |
| 1434 |
cout << "Caught exception: " << error_.what() << endl; |
| 1435 |
return 1; |
| 1436 |
} |
| 1437 |
catch( exception &error_ ) |
| 1438 |
{ |
| 1439 |
cout << "Caught exception: " << error_.what() << endl; |
| 1440 |
return 1; |
| 1441 |
} |
| 1442 |
|
| 1443 |
if ( failures ) |
| 1444 |
{ |
| 1445 |
cout << failures << " failures" << endl; |
| 1446 |
return 1; |
| 1447 |
} |
| 1448 |
|
| 1449 |
return 0; |
| 1450 |
} |