MagickCore 7.1.0
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
monitor.c
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% M M OOO N N IIIII TTTTT OOO RRRR %
7% MM MM O O NN N I T O O R R %
8% M M M O O N N N I T O O RRRR %
9% M M O O N NN I T O O R R %
10% M M OOO N N IIIII T OOO R R %
11% %
12% %
13% MagickCore Progress Monitor Methods %
14% %
15% Software Design %
16% Cristy %
17% December 1995 %
18% %
19% %
20% Copyright @ 1999 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% https://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%
37%
38*/
39
40/*
41 Include declarations.
42*/
43#include "MagickCore/studio.h"
44#include "MagickCore/image.h"
45#include "MagickCore/log.h"
46#include "MagickCore/monitor.h"
47#include "MagickCore/monitor-private.h"
48
49/*
50 Static declarations.
51*/
52static SemaphoreInfo
53 *monitor_semaphore = (SemaphoreInfo *) NULL;
54
55/*
56%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57% %
58% %
59% %
60+ M o n i t o r C o m p o n e n t G e n e s i s %
61% %
62% %
63% %
64%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65%
66% MonitorComponentGenesis() instantiates the monitor component.
67%
68% The format of the MonitorComponentGenesis method is:
69%
70% MagickBooleanMonitor MonitorComponentGenesis(void)
71%
72*/
73MagickPrivate MagickBooleanType MonitorComponentGenesis(void)
74{
75 if (monitor_semaphore == (SemaphoreInfo *) NULL)
76 monitor_semaphore=AcquireSemaphoreInfo();
77 return(MagickTrue);
78}
79
80/*
81%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82% %
83% %
84% %
85+ M o n i t o r C o m p o n e n t T e r m i n u s %
86% %
87% %
88% %
89%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90%
91% MonitorComponentTerminus() destroy monitor component.
92%
93% The format of the MonitorComponentTerminus method is:
94%
95% void MonitorComponentTerminus(void)
96%
97*/
98MagickPrivate void MonitorComponentTerminus(void)
99{
100 if (monitor_semaphore == (SemaphoreInfo *) NULL)
101 ActivateSemaphoreInfo(&monitor_semaphore);
102 LockSemaphoreInfo(monitor_semaphore);
103 UnlockSemaphoreInfo(monitor_semaphore);
104 RelinquishSemaphoreInfo(&monitor_semaphore);
105}
106
107/*
108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109% %
110% %
111% %
112% S e t I m a g e P r o g r e s s %
113% %
114% %
115% %
116%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117%
118% SetImageProgress() returns the progress of an image processing operation.
119%
120% The format of the SetImageProgress method is:
121%
122% MagickBooleanType SetImageProgress(const char *text,
123% const MagickOffsetType offset,const MagickSizeType extent)
124%
125% A description of each parameter follows:
126%
127% o image: the image.
128%
129% o text: description of the image processing operation.
130%
131% o offset: the offset relative to the extent parameter.
132%
133% o extent: the extent of the progress.
134%
135*/
136MagickExport MagickBooleanType SetImageProgress(const Image *image,
137 const char *tag,const MagickOffsetType offset,const MagickSizeType extent)
138{
139 char
140 message[MagickPathExtent];
141
142 MagickBooleanType
143 status;
144
145 if (image->progress_monitor == (MagickProgressMonitor) NULL)
146 return(MagickTrue);
147 (void) FormatLocaleString(message,MagickPathExtent,"%s/%s",tag,
148 image->filename);
149 if (monitor_semaphore == (SemaphoreInfo *) NULL)
150 ActivateSemaphoreInfo(&monitor_semaphore);
151 LockSemaphoreInfo(monitor_semaphore);
152 status=image->progress_monitor(message,offset,extent,image->client_data);
153 UnlockSemaphoreInfo(monitor_semaphore);
154 return(status);
155}
156
157/*
158%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159% %
160% %
161% %
162% S e t I m a g e P r o g r e s s M o n i t o r %
163% %
164% %
165% %
166%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167%
168% SetImageProgressMonitor() sets the image progress monitor to the specified
169% method and returns the previous progress monitor if any. The progress
170% monitor method looks like this:
171%
172% MagickBooleanType MagickProgressMonitor(const char *text,
173% const MagickOffsetType offset,const MagickSizeType extent,
174% void *client_data)
175%
176% If the progress monitor returns MagickFalse, the current operation is
177% interrupted.
178%
179% The format of the SetImageProgressMonitor method is:
180%
181% MagickProgressMonitor SetImageProgressMonitor(Image *image,
182% const MagickProgressMonitor progress_monitor,void *client_data)
183%
184% A description of each parameter follows:
185%
186% o image: the image.
187%
188% o progress_monitor: Specifies a pointer to a method to monitor progress of
189% an image operation.
190%
191% o client_data: Specifies a pointer to any client data.
192%
193*/
194MagickExport MagickProgressMonitor SetImageProgressMonitor(Image *image,
195 const MagickProgressMonitor progress_monitor,void *client_data)
196{
197 MagickProgressMonitor
198 previous_monitor;
199
200 previous_monitor=image->progress_monitor;
201 image->progress_monitor=progress_monitor;
202 image->client_data=client_data;
203 return(previous_monitor);
204}
205
206/*
207%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208% %
209% %
210% %
211% S e t I m a g e I n f o P r o g r e s s M o n i t o r %
212% %
213% %
214% %
215%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216%
217% SetImageInfoProgressMonitor() sets the image_info progress monitor to the
218% specified method and returns the previous progress monitor if any. The
219% progress monitor method looks like this:
220%
221% MagickBooleanType MagickProgressMonitor(const char *text,
222% const MagickOffsetType offset,const MagickSizeType extent,
223% void *client_data)
224%
225% If the progress monitor returns MagickFalse, the current operation is
226% interrupted.
227%
228% The format of the SetImageInfoProgressMonitor method is:
229%
230% MagickProgressMonitor SetImageInfoProgressMonitor(ImageInfo *image_info,
231% const MagickProgressMonitor progress_monitor,void *client_data)
232%
233% A description of each parameter follows:
234%
235% o image_info: the image info.
236%
237% o progress_monitor: Specifies a pointer to a method to monitor progress of
238% an image operation.
239%
240% o client_data: Specifies a pointer to any client data.
241%
242*/
243MagickExport MagickProgressMonitor SetImageInfoProgressMonitor(
244 ImageInfo *image_info,const MagickProgressMonitor progress_monitor,
245 void *client_data)
246{
247 MagickProgressMonitor
248 previous_monitor;
249
250 previous_monitor=image_info->progress_monitor;
251 image_info->progress_monitor=progress_monitor;
252 image_info->client_data=client_data;
253 return(previous_monitor);
254}
Definition: image.h:152