root / ImageMagick / trunk / utilities / import.c

Revision 12484, 5.7 kB (checked in by cristy, 3 weeks ago)
Line 
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%                                                                             %
4%                                                                             %
5%                                                                             %
6%                 IIIII  M   M  PPPP    OOO   RRRR   TTTTT                    %
7%                   I    MM MM  P   P  O   O  R   R    T                      %
8%                   I    M M M  PPPP   O   O  RRRR     T                      %
9%                   I    M   M  P      O   O  R R      T                      %
10%                 IIIII  M   M  P       OOO   R  R     T                      %
11%                                                                             %
12%                                                                             %
13%               Import image to a machine independent format.                 %
14%                                                                             %
15%                           Software Design                                   %
16%                             John Cristy                                     %
17%                              July 1992                                      %
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%  Import is an X Window System window dumping utility.  Import allows X
37%  users to store window images in a specially formatted dump file.  This
38%  file can then be read by the Display utility for redisplay, printing,
39%  editing, formatting, archiving, image processing, etc.  The target
40%  window can be specified by id or name or be selected by clicking the
41%  mouse in the desired window.  The keyboard bell is rung once at the
42%  beginning of the dump and twice when the dump is completed.
43%
44%
45*/
46
47/*
48  Include declarations.
49*/
50#include <stdio.h>
51#include <stdlib.h>
52#include <string.h>
53#include <math.h>
54#include <time.h>
55#include "wand/MagickWand.h"
56#if defined(__WINDOWS__)
57#include <windows.h>
58#endif
59
60/*
61%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62%                                                                             %
63%                                                                             %
64%                                                                             %
65%    M a i n                                                                  %
66%                                                                             %
67%                                                                             %
68%                                                                             %
69%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70%
71%
72*/
73int main(int argc,char **argv)
74{
75  char
76    *option;
77
78  double
79    elapsed_time,
80    user_time;
81
82  ExceptionInfo
83    *exception;
84
85  ImageInfo
86    *image_info;
87
88  MagickBooleanType
89    regard_warnings,
90    status;
91
92  register long
93    i;
94
95  TimerInfo
96    timer;
97
98  unsigned long
99    iterations;
100
101  MagickCoreGenesis(*argv,MagickTrue);
102  exception=AcquireExceptionInfo();
103  iterations=1;
104  status=MagickFalse;
105  regard_warnings=MagickFalse;
106  for (i=1; i < (long) (argc-1); i++)
107  {
108    option=argv[i];
109    if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
110      continue;
111    if (LocaleCompare("bench",option+1) == 0)
112      iterations=(unsigned long) atol(argv[++i]);
113    if (LocaleCompare("debug",option+1) == 0)
114      (void) SetLogEventMask(argv[++i]);
115    if (LocaleCompare("regard-warnings",option+1) == 0)
116      regard_warnings=MagickTrue;
117  }
118  GetTimerInfo(&timer);
119  for (i=0; i < (long) iterations; i++)
120  {
121    image_info=AcquireImageInfo();
122    status=ImportImageCommand(image_info,argc,argv,(char **) NULL,exception);
123    if (exception->severity != UndefinedException)
124      {
125        if ((exception->severity > ErrorException) ||
126            (regard_warnings != MagickFalse))
127          status=MagickTrue;
128        CatchException(exception);
129      }
130    image_info=DestroyImageInfo(image_info);
131  }
132  if (iterations > 1)
133    {
134      elapsed_time=GetElapsedTime(&timer);
135      user_time=GetUserTime(&timer);
136      (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld\n",
137        iterations,1.0*iterations/elapsed_time,user_time,(long)
138        (elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0)));
139    }
140  exception=DestroyExceptionInfo(exception);
141  MagickCoreTerminus();
142  return(status == MagickFalse ? 0 : 1);
143}
Note: See TracBrowser for help on using the browser.