root / ImageMagick / trunk / utilities / composite.c

Revision 12484, 5.3 kB (checked in by cristy, 2 weeks ago)
Line 
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%                                                                             %
4%                                                                             %
5%                                                                             %
6%         CCCC   OOO   M   M  PPPP    OOO   SSSSS  IIIII  TTTTT  EEEEE        %
7%        C      O   O  MM MM  P   P  O   O  SS       I      T    E            %
8%        C      O   O  M.M M  PPPP   O   O   SSS     I      T    EEE          %
9%        C      O   O  M   M  P      O   O     SS    I      T    E            %
10%         CCCC   OOO   M   M  P       OOO   SSSSS  IIIII    T    EEEEE        %
11%                                                                             %
12%                                                                             %
13%                        Digitally composite two images.                      %
14%                                                                             %
15%                              Software Design                                %
16%                                John Cristy                                  %
17%                               January 1993                                  %
18%                                                                             %
19%                                                                             %
20%  Copyright 1999-2008 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%  Program Composite composites images to create new images.
37%
38%
39*/
40
41/*
42  Include declarations.
43*/
44#include <stdio.h>
45#include <stdlib.h>
46#include <string.h>
47#include <math.h>
48#include <time.h>
49#include "wand/MagickWand.h"
50#if defined(__WINDOWS__)
51#include <windows.h>
52#endif
53
54/*
55%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56%                                                                             %
57%                                                                             %
58%                                                                             %
59%  M a i n                                                                    %
60%                                                                             %
61%                                                                             %
62%                                                                             %
63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64%
65%
66*/
67int main(int argc,char **argv)
68{
69  char
70    *option;
71
72  double
73    elapsed_time,
74    user_time;
75
76  ExceptionInfo
77    *exception;
78
79  ImageInfo
80    *image_info;
81
82  MagickBooleanType
83    regard_warnings,
84    status;
85
86  register long
87    i;
88
89  TimerInfo
90    timer;
91
92  unsigned long
93    iterations;
94
95  MagickCoreGenesis(*argv,MagickTrue);
96  exception=AcquireExceptionInfo();
97  iterations=1;
98  status=MagickFalse;
99  regard_warnings=MagickFalse;
100  for (i=1; i < (long) (argc-1); i++)
101  {
102    option=argv[i];
103    if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
104      continue;
105    if (LocaleCompare("bench",option+1) == 0)
106      iterations=(unsigned long) atol(argv[++i]);
107    if (LocaleCompare("debug",option+1) == 0)
108      (void) SetLogEventMask(argv[++i]);
109    if (LocaleCompare("regard-warnings",option+1) == 0)
110      regard_warnings=MagickTrue;
111  }
112  GetTimerInfo(&timer);
113  for (i=0; i < (long) iterations; i++)
114  {
115    image_info=AcquireImageInfo();
116    status=CompositeImageCommand(image_info,argc,argv,(char **) NULL,exception);
117    if (exception->severity != UndefinedException)
118      {
119        if ((exception->severity > ErrorException) ||
120            (regard_warnings != MagickFalse))
121          status=MagickTrue;
122        CatchException(exception);
123      }
124    image_info=DestroyImageInfo(image_info);
125  }
126  if (iterations > 1)
127    {
128      elapsed_time=GetElapsedTime(&timer);
129      user_time=GetUserTime(&timer);
130      (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld\n",
131        iterations,1.0*iterations/elapsed_time,user_time,(long)
132        (elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0)));
133    }
134  exception=DestroyExceptionInfo(exception);
135  MagickCoreTerminus();
136  return(status == MagickFalse ? 0 : 1);
137}
Note: See TracBrowser for help on using the browser.