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