PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/branches/ImageMagick-6.5.5/utilities/montage.c

https://github.com/trevor/ImageMagick
C | 139 lines | 74 code | 8 blank | 57 comment | 20 complexity | b9512b157f15d60a6626950740fc6cf7 MD5 | raw file
  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % %
  4. % %
  5. % %
  6. % M M OOO N N TTTTT AAA GGGG EEEEE %
  7. % MM MM O O NN N T A A G E %
  8. % M M M O O N N N T AAAAA G GG EEE %
  9. % M M O O N NN T A A G G E %
  10. % M M OOO N N T A A GGGG EEEEE %
  11. % %
  12. % %
  13. % Montage Magick Image File Format Image via X11. %
  14. % %
  15. % Software Design %
  16. % John Cristy %
  17. % July 1992 %
  18. % %
  19. % %
  20. % Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
  21. % dedicated to making software imaging solutions freely available. %
  22. % %
  23. % You may not use this file except in compliance with the License. You may %
  24. % obtain a copy of the License at %
  25. % %
  26. % http://www.imagemagick.org/script/license.php %
  27. % %
  28. % Unless required by applicable law or agreed to in writing, software %
  29. % distributed under the License is distributed on an "AS IS" BASIS, %
  30. % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
  31. % See the License for the specific language governing permissions and %
  32. % limitations under the License. %
  33. % %
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. %
  36. % Montage creates a composite by combining several separate images. The
  37. % images are tiled on the composite image with the name of the image
  38. % optionally appearing just below the individual tile.
  39. %
  40. %
  41. */
  42. /*
  43. Include declarations.
  44. */
  45. #include <stdio.h>
  46. #include <stdlib.h>
  47. #include <string.h>
  48. #include <math.h>
  49. #include <time.h>
  50. #include "wand/MagickWand.h"
  51. #if defined(__WINDOWS__)
  52. #include <windows.h>
  53. #endif
  54. /*
  55. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  56. % %
  57. % %
  58. % %
  59. % M a i n %
  60. % %
  61. % %
  62. % %
  63. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  64. %
  65. %
  66. */
  67. int main(int argc,char **argv)
  68. {
  69. char
  70. *option;
  71. double
  72. elapsed_time,
  73. user_time;
  74. ExceptionInfo
  75. *exception;
  76. ImageInfo
  77. *image_info;
  78. MagickBooleanType
  79. regard_warnings,
  80. status;
  81. register long
  82. i;
  83. TimerInfo
  84. timer;
  85. unsigned long
  86. iterations;
  87. MagickCoreGenesis(*argv,MagickTrue);
  88. exception=AcquireExceptionInfo();
  89. iterations=1;
  90. status=MagickFalse;
  91. regard_warnings=MagickFalse;
  92. for (i=1; i < (long) (argc-1); i++)
  93. {
  94. option=argv[i];
  95. if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
  96. continue;
  97. if (LocaleCompare("bench",option+1) == 0)
  98. iterations=(unsigned long) atol(argv[++i]);
  99. if (LocaleCompare("debug",option+1) == 0)
  100. (void) SetLogEventMask(argv[++i]);
  101. if (LocaleCompare("regard-warnings",option+1) == 0)
  102. regard_warnings=MagickTrue;
  103. }
  104. GetTimerInfo(&timer);
  105. for (i=0; i < (long) iterations; i++)
  106. {
  107. image_info=AcquireImageInfo();
  108. status=MontageImageCommand(image_info,argc,argv,(char **) NULL,exception);
  109. if (exception->severity != UndefinedException)
  110. {
  111. if ((exception->severity > ErrorException) ||
  112. (regard_warnings != MagickFalse))
  113. status=MagickTrue;
  114. CatchException(exception);
  115. }
  116. image_info=DestroyImageInfo(image_info);
  117. }
  118. if (iterations > 1)
  119. {
  120. elapsed_time=GetElapsedTime(&timer);
  121. user_time=GetUserTime(&timer);
  122. (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld\n",
  123. iterations,1.0*iterations/elapsed_time,user_time,(long)
  124. (elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0)));
  125. }
  126. exception=DestroyExceptionInfo(exception);
  127. MagickCoreTerminus();
  128. return(status == MagickFalse ? 0 : 1);
  129. }