/src/graphicsmagick/magick/list.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | % Copyright (C) 2003-2023 GraphicsMagick Group |
3 | | % Copyright (C) 2002, 2003 ImageMagick Studio |
4 | | % |
5 | | % This program is covered by multiple licenses, which are described in |
6 | | % Copyright.txt. You should have received a copy of Copyright.txt with this |
7 | | % package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. |
8 | | % |
9 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
10 | | % % |
11 | | % % |
12 | | % % |
13 | | % L IIIII SSSSS TTTTT % |
14 | | % L I SS T % |
15 | | % L I SSS T % |
16 | | % L I SS T % |
17 | | % LLLLL IIIII SSSSS T % |
18 | | % % |
19 | | % % |
20 | | % GraphicsMagick Image List Methods % |
21 | | % % |
22 | | % % |
23 | | % Software Design % |
24 | | % John Cristy % |
25 | | % January 2003 % |
26 | | % % |
27 | | % % |
28 | | % % |
29 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
30 | | % |
31 | | % |
32 | | % |
33 | | */ |
34 | | |
35 | | /* |
36 | | Include declarations. |
37 | | */ |
38 | | #include "magick/studio.h" |
39 | | #include "magick/list.h" |
40 | | #include "magick/blob.h" |
41 | | #include "magick/utility.h" |
42 | | |
43 | | /* |
44 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
45 | | % % |
46 | | % % |
47 | | % % |
48 | | % A p p e n d I m a g e T o L i s t % |
49 | | % % |
50 | | % % |
51 | | % % |
52 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
53 | | % |
54 | | % AppendImageToList() appends an image to the end of the list. Please |
55 | | % note that this API allows the list pointer to be updated and in fact |
56 | | % it now updates the list pointer to be the image (or the end of the |
57 | | % image list) which was just added. |
58 | | % |
59 | | % The format of the AppendImageToList method is: |
60 | | % |
61 | | % AppendImageToList(Image **images,Image *image) |
62 | | % |
63 | | % A description of each parameter follows: |
64 | | % |
65 | | % o images: The image list. |
66 | | % |
67 | | % o image: The image. |
68 | | % |
69 | | % |
70 | | */ |
71 | | MagickExport void AppendImageToList(Image **images,Image *image) |
72 | 26.1k | { |
73 | 26.1k | register Image |
74 | 26.1k | *p; |
75 | | |
76 | 26.1k | assert(images != (Image **) NULL); |
77 | 26.1k | if (image == (Image *) NULL) |
78 | 0 | return; |
79 | 26.1k | assert(image->signature == MagickSignature); |
80 | 26.1k | if ((*images) == (Image *) NULL) |
81 | 3.83k | { |
82 | 3.83k | *images=image; |
83 | 3.83k | return; |
84 | 3.83k | } |
85 | 22.3k | assert((*images)->signature == MagickSignature); |
86 | 22.3k | for (p=(*images); p->next != (Image *) NULL; p=p->next); |
87 | 22.3k | p->next=image; |
88 | 22.3k | image->previous=p; |
89 | 22.3k | *images=image; |
90 | 22.3k | for (p=(*images); p->next != (Image *) NULL; p=p->next); |
91 | 22.3k | *images=image; |
92 | 22.3k | } |
93 | | |
94 | | /* |
95 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96 | | % % |
97 | | % % |
98 | | % % |
99 | | % C l o n e I m a g e L i s t % |
100 | | % % |
101 | | % % |
102 | | % % |
103 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
104 | | % |
105 | | % CloneImageList() returns a duplicate of the image list. |
106 | | % |
107 | | % The format of the CloneImageList method is: |
108 | | % |
109 | | % Image *CloneImageList(const Image *images,ExceptionInfo *exception) |
110 | | % |
111 | | % A description of each parameter follows: |
112 | | % |
113 | | % o images: The image list. |
114 | | % |
115 | | % o exception: Return any errors or warnings in this structure. |
116 | | % |
117 | | % |
118 | | */ |
119 | | MagickExport Image *CloneImageList(const Image *images,ExceptionInfo *exception) |
120 | 0 | { |
121 | 0 | Image |
122 | 0 | *clone, |
123 | 0 | *image; |
124 | |
|
125 | 0 | register Image |
126 | 0 | *p; |
127 | |
|
128 | 0 | if (images == (Image *) NULL) |
129 | 0 | return((Image *) NULL); |
130 | 0 | assert(images->signature == MagickSignature); |
131 | 0 | while (images->previous != (Image *) NULL) |
132 | 0 | images=images->previous; |
133 | 0 | image=(Image *) NULL; |
134 | 0 | for (p=(Image *) NULL; images != (Image *) NULL; images=images->next) |
135 | 0 | { |
136 | 0 | clone=CloneImage(images,0,0,True,exception); |
137 | 0 | if (clone == (Image *) NULL) |
138 | 0 | { |
139 | 0 | if (image != (Image *) NULL) |
140 | 0 | DestroyImageList(image); |
141 | 0 | return((Image *) NULL); |
142 | 0 | } |
143 | 0 | if (image == (Image *) NULL) |
144 | 0 | { |
145 | 0 | image=clone; |
146 | 0 | p=image; |
147 | 0 | continue; |
148 | 0 | } |
149 | 0 | p->next=clone; |
150 | 0 | clone->previous=p; |
151 | 0 | p=p->next; |
152 | 0 | } |
153 | 0 | return(image); |
154 | 0 | } |
155 | | |
156 | | /* |
157 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
158 | | % % |
159 | | % % |
160 | | % % |
161 | | % D e l e t e I m a g e F r o m L i s t % |
162 | | % % |
163 | | % % |
164 | | % % |
165 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
166 | | % |
167 | | % DeleteImageFromList() deletes an image from the list. |
168 | | % |
169 | | % The format of the DeleteImageFromList method is: |
170 | | % |
171 | | % DeleteImageFromList(Image **images) |
172 | | % |
173 | | % A description of each parameter follows: |
174 | | % |
175 | | % o images: The image list. |
176 | | % |
177 | | % |
178 | | */ |
179 | | MagickExport void DeleteImageFromList(Image **images) |
180 | 337k | { |
181 | 337k | register Image |
182 | 337k | *p; |
183 | | |
184 | 337k | assert(images != (Image **) NULL); |
185 | 337k | if ((*images) == (Image *) NULL) |
186 | 0 | return; |
187 | 337k | assert((*images)->signature == MagickSignature); |
188 | 337k | p=(*images); |
189 | 337k | if ((p->previous == (Image *) NULL) && (p->next == (Image *) NULL)) |
190 | 334k | *images=(Image *) NULL; |
191 | 2.71k | else |
192 | 2.71k | { |
193 | 2.71k | if (p->previous != (Image *) NULL) |
194 | 1.07k | { |
195 | 1.07k | p->previous->next=p->next; |
196 | 1.07k | *images=p->previous; |
197 | 1.07k | } |
198 | 2.71k | if (p->next != (Image *) NULL) |
199 | 2.71k | { |
200 | 2.71k | p->next->previous=p->previous; |
201 | 2.71k | *images=p->next; |
202 | 2.71k | } |
203 | 2.71k | } |
204 | 337k | DestroyImage(p); |
205 | 337k | } |
206 | | |
207 | | /* |
208 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
209 | | % % |
210 | | % % |
211 | | % % |
212 | | % D e s t r o y I m a g e L i s t % |
213 | | % % |
214 | | % % |
215 | | % % |
216 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
217 | | % |
218 | | % DestroyImageList() destroys an image list. There is no effect if the |
219 | | % image pointer is null. |
220 | | % |
221 | | % The format of the DestroyImageList method is: |
222 | | % |
223 | | % void DestroyImageList(Image *image) |
224 | | % |
225 | | % A description of each parameter follows: |
226 | | % |
227 | | % o image: The image sequence. |
228 | | % |
229 | | % |
230 | | */ |
231 | | MagickExport void DestroyImageList(Image *images) |
232 | 1.41M | { |
233 | 1.41M | register Image |
234 | 1.41M | *p; |
235 | | |
236 | 1.41M | if (images == (Image *) NULL) |
237 | 4.28k | return; |
238 | 1.40M | assert(images->signature == MagickSignature); |
239 | 1.46M | for (p=images; p->previous != (Image *) NULL; p=p->previous); |
240 | 2.94M | for (images=p; p != (Image *) NULL; images=p) |
241 | 1.54M | { |
242 | 1.54M | p=p->next; |
243 | 1.54M | images->next=0; |
244 | 1.54M | if(p) |
245 | 133k | p->previous=0; |
246 | 1.54M | DestroyImage(images); |
247 | 1.54M | } |
248 | 1.40M | } |
249 | | |
250 | | /* |
251 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
252 | | % % |
253 | | % % |
254 | | % % |
255 | | % G e t F i r s t I m a g e I n L i s t % |
256 | | % % |
257 | | % % |
258 | | % % |
259 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
260 | | % |
261 | | % GetFirstImageInList() returns a pointer to the first image in the list |
262 | | % |
263 | | % The format of the GetFirstImageInList method is: |
264 | | % |
265 | | % Image *GetFirstImageInList(const Image *images) |
266 | | % |
267 | | % A description of each parameter follows: |
268 | | % |
269 | | % o images: The image list. |
270 | | % |
271 | | */ |
272 | | MagickExport Image *GetFirstImageInList(const Image *images) |
273 | 338k | { |
274 | 338k | register const Image |
275 | 338k | *p; |
276 | | |
277 | 338k | if (images == (Image *) NULL) |
278 | 33.1k | return((Image *) NULL); |
279 | 305k | assert(images->signature == MagickSignature); |
280 | 320k | for (p=images; p->previous != (Image *) NULL; p=p->previous); |
281 | 305k | return((Image *) p); |
282 | 305k | } |
283 | | |
284 | | /* |
285 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
286 | | % % |
287 | | % % |
288 | | % % |
289 | | % G e t I m a g e F r o m L i s t % |
290 | | % % |
291 | | % % |
292 | | % % |
293 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
294 | | % |
295 | | % GetImageFromList() returns an image at the specified offset from the list. |
296 | | % |
297 | | % The format of the GetImageFromList method is: |
298 | | % |
299 | | % Image *GetImageFromList(const Image *images,const long offset) |
300 | | % |
301 | | % A description of each parameter follows: |
302 | | % |
303 | | % o images: The image list. |
304 | | % |
305 | | % o offset: The position within the list. |
306 | | % |
307 | | % |
308 | | */ |
309 | | MagickExport Image *GetImageFromList(const Image *images,const long offset) |
310 | 0 | { |
311 | 0 | register const Image |
312 | 0 | *p; |
313 | |
|
314 | 0 | register long |
315 | 0 | i; |
316 | |
|
317 | 0 | if (images == (Image *) NULL) |
318 | 0 | return((Image *) NULL); |
319 | 0 | assert(images->signature == MagickSignature); |
320 | 0 | for (p=images; p->previous != (Image *) NULL; p=p->previous); |
321 | 0 | for (i=0; p != (Image *) NULL; p=p->next) |
322 | 0 | if (i++ == offset) |
323 | 0 | break; |
324 | 0 | if (p == (Image *) NULL) |
325 | 0 | return((Image *) NULL); |
326 | 0 | return((Image *) p); |
327 | 0 | } |
328 | | |
329 | | /* |
330 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
331 | | % % |
332 | | % % |
333 | | % % |
334 | | % G e t I m a g e I n d e x I n L i s t % |
335 | | % % |
336 | | % % |
337 | | % % |
338 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
339 | | % |
340 | | % GetImageIndexInList() returns the offset in the list of the specified image. |
341 | | % |
342 | | % The format of the GetImageIndexInList method is: |
343 | | % |
344 | | % long GetImageIndexInList(const Image *images) |
345 | | % |
346 | | % A description of each parameter follows: |
347 | | % |
348 | | % o images: The image list. |
349 | | % |
350 | | % |
351 | | */ |
352 | | MagickExport long GetImageIndexInList(const Image *images) |
353 | 0 | { |
354 | 0 | register long |
355 | 0 | i; |
356 | |
|
357 | 0 | if (images == (const Image *) NULL) |
358 | 0 | return(-1); |
359 | 0 | assert(images->signature == MagickSignature); |
360 | 0 | for (i=0; images->previous != (Image *) NULL; i++) |
361 | 0 | images=images->previous; |
362 | 0 | return(i); |
363 | 0 | } |
364 | | |
365 | | /* |
366 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
367 | | % % |
368 | | % % |
369 | | % % |
370 | | % G e t I m a g e L i s t L e n g t h % |
371 | | % % |
372 | | % % |
373 | | % % |
374 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
375 | | % |
376 | | % GetImageListLength() returns the length of the list (the number of images in |
377 | | % the list). |
378 | | % |
379 | | % The format of the GetImageListLength method is: |
380 | | % |
381 | | % unsigned long GetImageListLength(const Image *images) |
382 | | % |
383 | | % A description of each parameter follows: |
384 | | % |
385 | | % o images: The image list. |
386 | | % |
387 | | % |
388 | | */ |
389 | | MagickExport unsigned long GetImageListLength(const Image *images) |
390 | 368k | { |
391 | 368k | register unsigned long |
392 | 368k | i; |
393 | | |
394 | 368k | if (images == (Image *) NULL) |
395 | 0 | return(0); |
396 | 368k | assert(images->signature == MagickSignature); |
397 | 14.8M | while (images->previous != (Image *) NULL) |
398 | 14.4M | images=images->previous; |
399 | 29.6M | for (i=0; images != (Image *) NULL; images=images->next) |
400 | 29.2M | i++; |
401 | 368k | return(i); |
402 | 368k | } |
403 | | |
404 | | /* |
405 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
406 | | % % |
407 | | % % |
408 | | % % |
409 | | % G e t L a s t I m a g e I n L i s t % |
410 | | % % |
411 | | % % |
412 | | % % |
413 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
414 | | % |
415 | | % GetLastImageInList() returns a pointer to the last image in the list |
416 | | % |
417 | | % The format of the GetLastImageInList method is: |
418 | | % |
419 | | % Image *GetLastImageInList(const Image *images) |
420 | | % |
421 | | % A description of each parameter follows: |
422 | | % |
423 | | % o images: The image list. |
424 | | % |
425 | | */ |
426 | | MagickExport Image *GetLastImageInList(const Image *images) |
427 | 0 | { |
428 | 0 | register const Image |
429 | 0 | *p; |
430 | |
|
431 | 0 | if (images == (Image *) NULL) |
432 | 0 | return((Image *) NULL); |
433 | 0 | assert(images->signature == MagickSignature); |
434 | 0 | for (p=images; p->next != (Image *) NULL; p=p->next); |
435 | 0 | return((Image *) p); |
436 | 0 | } |
437 | | |
438 | | /* |
439 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
440 | | % % |
441 | | % % |
442 | | % % |
443 | | % G e t N e x t I m a g e I n L i s t % |
444 | | % % |
445 | | % % |
446 | | % % |
447 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
448 | | % |
449 | | % GetNextImageInList() returns the next image in the list. |
450 | | % |
451 | | % The format of the GetNextImageInList method is: |
452 | | % |
453 | | % Image *GetNextImageInList(const Image *images) |
454 | | % |
455 | | % A description of each parameter follows: |
456 | | % |
457 | | % o images: The image list. |
458 | | % |
459 | | % |
460 | | */ |
461 | | MagickExport Image *GetNextImageInList(const Image *images) |
462 | 1.54k | { |
463 | 1.54k | if (images == (Image *) NULL) |
464 | 0 | return((Image *) NULL); |
465 | 1.54k | assert(images->signature == MagickSignature); |
466 | 1.54k | return(images->next); |
467 | 1.54k | } |
468 | | |
469 | | /* |
470 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
471 | | % % |
472 | | % % |
473 | | % % |
474 | | % G e t P r e v i o u s I m a g e I n L i s t % |
475 | | % % |
476 | | % % |
477 | | % % |
478 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
479 | | % |
480 | | % GetPreviousImageInList() returns the previous image in the list. |
481 | | % |
482 | | % The format of the GetPreviousImageInList method is: |
483 | | % |
484 | | % Image *GetPreviousImageInList(const Image *images) |
485 | | % |
486 | | % A description of each parameter follows: |
487 | | % |
488 | | % o images: The image list. |
489 | | % |
490 | | % |
491 | | */ |
492 | | MagickExport Image *GetPreviousImageInList(const Image *images) |
493 | 0 | { |
494 | 0 | if (images == (Image *) NULL) |
495 | 0 | return((Image *) NULL); |
496 | 0 | assert(images->signature == MagickSignature); |
497 | 0 | return(images->previous); |
498 | 0 | } |
499 | | |
500 | | /* |
501 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
502 | | % % |
503 | | % % |
504 | | % I m a g e L i s t T o A r r a y % |
505 | | % % |
506 | | % % |
507 | | % % |
508 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
509 | | % |
510 | | % ImageListToArray() is a convenience method that converts an image list to |
511 | | % a sequential array. For example, |
512 | | % |
513 | | % group = ImageListToArray(images, exception); |
514 | | % for (i = 0; i < n; i++) |
515 | | % puts(group[i]->filename); |
516 | | % |
517 | | % The format of the ImageListToArray method is: |
518 | | % |
519 | | % Image **ImageListToArray(const Image *images,ExceptionInfo *exception) |
520 | | % |
521 | | % A description of each parameter follows: |
522 | | % |
523 | | % o image: The image list. |
524 | | % |
525 | | % o exception: Return any errors or warnings in this structure. |
526 | | % |
527 | | % |
528 | | */ |
529 | | MagickExport Image **ImageListToArray(const Image *images, |
530 | | ExceptionInfo *exception) |
531 | 58 | { |
532 | 58 | Image |
533 | 58 | **group; |
534 | | |
535 | 58 | register long |
536 | 58 | i; |
537 | | |
538 | 58 | if (images == (Image *) NULL) |
539 | 0 | return((Image **) NULL); |
540 | 58 | assert(images->signature == MagickSignature); |
541 | 58 | group=MagickAllocateArray(Image **,((size_t) GetImageListLength(images)+1),sizeof(Image *)); |
542 | 58 | if (group == (Image **) NULL) |
543 | 0 | { |
544 | 0 | ThrowException3(exception,ResourceLimitError,MemoryAllocationFailed, |
545 | 0 | UnableToCreateImageGroup); |
546 | 0 | return((Image **) NULL); |
547 | 0 | } |
548 | 58 | while (images->previous != (Image *) NULL) |
549 | 0 | images=images->previous; |
550 | 651 | for (i=0; images != (Image *) NULL; images=images->next) |
551 | 593 | group[i++]=(Image *) images; |
552 | 58 | group[i] = (Image *) NULL; |
553 | 58 | return(group); |
554 | 58 | } |
555 | | |
556 | | /* |
557 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
558 | | % % |
559 | | % % |
560 | | % % |
561 | | % I n s e r t I m a g e I n L i s t % |
562 | | % % |
563 | | % % |
564 | | % % |
565 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
566 | | % |
567 | | % InsertImageInList() inserts an image in the list. |
568 | | % |
569 | | % The format of the InsertImageInList method is: |
570 | | % |
571 | | % InsertImageInList(Image **images,Image *image) |
572 | | % |
573 | | % A description of each parameter follows: |
574 | | % |
575 | | % o images: The image list. |
576 | | % |
577 | | % o image: The image. |
578 | | % |
579 | | % |
580 | | */ |
581 | | MagickExport void InsertImageInList(Image **images,Image *image) |
582 | 0 | { |
583 | 0 | Image |
584 | 0 | *split; |
585 | |
|
586 | 0 | assert(images != (Image **) NULL); |
587 | 0 | assert(image != (Image *) NULL); |
588 | 0 | assert(image->signature == MagickSignature); |
589 | 0 | if ((*images) == (Image *) NULL) |
590 | 0 | return; |
591 | 0 | assert((*images)->signature == MagickSignature); |
592 | 0 | split=SplitImageList(*images); |
593 | 0 | if (split == (Image *) NULL) |
594 | 0 | return; |
595 | 0 | AppendImageToList(images,image); |
596 | 0 | AppendImageToList(images,split); |
597 | 0 | } |
598 | | |
599 | | /* |
600 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
601 | | % % |
602 | | % % |
603 | | % % |
604 | | % N e w I m a g e L i s t % |
605 | | % % |
606 | | % % |
607 | | % % |
608 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
609 | | % |
610 | | % NewImageList() creates an empty image list. |
611 | | % |
612 | | % The format of the NewImageList method is: |
613 | | % |
614 | | % Image *NewImageList(void) |
615 | | % |
616 | | */ |
617 | | MagickExport Image *NewImageList(void) |
618 | 0 | { |
619 | 0 | return((Image *) NULL); |
620 | 0 | } |
621 | | |
622 | | /* |
623 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
624 | | % % |
625 | | % % |
626 | | % % |
627 | | % P r e p e n d I m a g e T o L i s t % |
628 | | % % |
629 | | % % |
630 | | % % |
631 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
632 | | % |
633 | | % PrependImageToList() prepends the image to the beginning of the list. |
634 | | % |
635 | | % The format of the PrependImageToList method is: |
636 | | % |
637 | | % PrependImageToList(Image *images,Image *image) |
638 | | % |
639 | | % A description of each parameter follows: |
640 | | % |
641 | | % o images: The image list. |
642 | | % |
643 | | % o image: The image. |
644 | | % |
645 | | % |
646 | | */ |
647 | | MagickExport void PrependImageToList(Image **images,Image *image) |
648 | 0 | { |
649 | 0 | AppendImageToList(&image,*images); |
650 | 0 | } |
651 | | |
652 | | /* |
653 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
654 | | % % |
655 | | % % |
656 | | % % |
657 | | % R e m o v e F i r s t I m a g e F r o m L i s t % |
658 | | % % |
659 | | % % |
660 | | % % |
661 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
662 | | % |
663 | | % RemoveFirstImageFromList() removes an image from the beginning of the list. |
664 | | % |
665 | | % The format of the RemoveFirstImageFromList method is: |
666 | | % |
667 | | % Image *RemoveFirstImageFromList(Image **images) |
668 | | % |
669 | | % A description of each parameter follows: |
670 | | % |
671 | | % o images: The image list. |
672 | | % |
673 | | % |
674 | | */ |
675 | | MagickExport Image *RemoveFirstImageFromList(Image **images) |
676 | 0 | { |
677 | 0 | Image |
678 | 0 | *image; |
679 | |
|
680 | 0 | assert(images != (Image **) NULL); |
681 | 0 | if ((*images) == (Image *) NULL) |
682 | 0 | return((Image *) NULL); |
683 | 0 | assert((*images)->signature == MagickSignature); |
684 | 0 | image=(*images); |
685 | 0 | while (image->previous != (Image *) NULL) |
686 | 0 | image=image->previous; |
687 | 0 | if (image == *images) |
688 | 0 | *images=(*images)->next; |
689 | 0 | if (image->next != (Image *) NULL) |
690 | 0 | { |
691 | 0 | image->next->previous=(Image *) NULL; |
692 | 0 | image->next=(Image *) NULL; |
693 | 0 | } |
694 | 0 | return(image); |
695 | 0 | } |
696 | | |
697 | | /* |
698 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
699 | | % % |
700 | | % % |
701 | | % % |
702 | | % R e m o v e L a s t I m a g e F r o m L i s t % |
703 | | % % |
704 | | % % |
705 | | % % |
706 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
707 | | % |
708 | | % RemoveLastImageFromList() removes the last image from the list. |
709 | | % |
710 | | % The format of the RemoveLastImageFromList method is: |
711 | | % |
712 | | % Image *RemoveLastImageFromList(Image **images) |
713 | | % |
714 | | % A description of each parameter follows: |
715 | | % |
716 | | % o images: The image list. |
717 | | % |
718 | | % |
719 | | */ |
720 | | MagickExport Image *RemoveLastImageFromList(Image **images) |
721 | 0 | { |
722 | 0 | Image |
723 | 0 | *image; |
724 | |
|
725 | 0 | assert(images != (Image **) NULL); |
726 | 0 | if ((*images) == (Image *) NULL) |
727 | 0 | return((Image *) NULL); |
728 | 0 | assert((*images)->signature == MagickSignature); |
729 | 0 | image=(*images); |
730 | 0 | while (image->next != (Image *) NULL) |
731 | 0 | image=image->next; |
732 | 0 | if (image == *images) |
733 | 0 | *images=(*images)->previous; |
734 | 0 | if (image->previous != (Image *) NULL) |
735 | 0 | { |
736 | 0 | image->previous->next=(Image *) NULL; |
737 | 0 | image->previous=(Image *) NULL; |
738 | 0 | } |
739 | 0 | return(image); |
740 | 0 | } |
741 | | |
742 | | /* |
743 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
744 | | % % |
745 | | % % |
746 | | % % |
747 | | % R e p l a c e I m a g e I n L i s t % |
748 | | % % |
749 | | % % |
750 | | % % |
751 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
752 | | % |
753 | | % ReplaceImageInList() replaces an image in the list. |
754 | | % |
755 | | % The format of the ReplaceImageInList method is: |
756 | | % |
757 | | % ReplaceImageInList(Image **images,Image *image) |
758 | | % |
759 | | % A description of each parameter follows: |
760 | | % |
761 | | % o images: The image list. |
762 | | % |
763 | | % o image: The image. |
764 | | % |
765 | | % |
766 | | */ |
767 | | MagickExport void ReplaceImageInList(Image **images,Image *image) |
768 | 12.9k | { |
769 | 12.9k | assert(images != (Image **) NULL); |
770 | 12.9k | assert(image != (Image *) NULL); |
771 | 12.9k | assert(image->signature == MagickSignature); |
772 | 12.9k | if ((*images) == (Image *) NULL) |
773 | 0 | return; |
774 | 12.9k | assert((*images)->signature == MagickSignature); |
775 | 12.9k | image->next=(*images)->next; |
776 | 12.9k | if (image->next != (Image *) NULL) |
777 | 0 | { |
778 | 0 | image->next->previous=image; |
779 | 0 | (*images)->next=(Image *) NULL; |
780 | 0 | } |
781 | 12.9k | image->previous=(*images)->previous; |
782 | 12.9k | if (image->previous != (Image *) NULL) |
783 | 0 | { |
784 | 0 | image->previous->next=image; |
785 | 0 | (*images)->previous=(Image *) NULL; |
786 | 0 | } |
787 | 12.9k | DestroyImage(*images); |
788 | 12.9k | (*images)=image; |
789 | 12.9k | } |
790 | | |
791 | | /* |
792 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
793 | | % % |
794 | | % % |
795 | | % % |
796 | | % R e v e r s e I m a g e L i s t % |
797 | | % % |
798 | | % % |
799 | | % % |
800 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
801 | | % |
802 | | % ReverseImageList() reverses the image list. |
803 | | % |
804 | | % The format of the ReverseImageList method is: |
805 | | % |
806 | | % ReverseImageList(const Image **images) |
807 | | % |
808 | | % A description of each parameter follows: |
809 | | % |
810 | | % o images: The image list. |
811 | | % |
812 | | % |
813 | | */ |
814 | | MagickExport void ReverseImageList(Image **images) |
815 | 0 | { |
816 | 0 | Image |
817 | 0 | *next; |
818 | |
|
819 | 0 | register Image |
820 | 0 | *p; |
821 | |
|
822 | 0 | assert(images != (Image **) NULL); |
823 | 0 | if ((*images) == (Image *) NULL) |
824 | 0 | return; |
825 | 0 | assert((*images)->signature == MagickSignature); |
826 | 0 | for (p=(*images); p->next != (Image *) NULL; p=p->next); |
827 | 0 | *images=p; |
828 | 0 | for ( ; p != (Image *) NULL; p=p->next) |
829 | 0 | { |
830 | 0 | next=p->next; |
831 | 0 | p->next=p->previous; |
832 | 0 | p->previous=next; |
833 | 0 | } |
834 | 0 | } |
835 | | |
836 | | /* |
837 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
838 | | % % |
839 | | % % |
840 | | % % |
841 | | % S p l i c e I m a g e I n t o L i s t % |
842 | | % % |
843 | | % % |
844 | | % % |
845 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
846 | | % |
847 | | % SpliceImageIntoList() removes 'length' images from the list and replaces |
848 | | % them with the specified splice. |
849 | | % |
850 | | % The format of the SpliceImageIntoList method is: |
851 | | % |
852 | | % SpliceImageIntoList(Image **images,const unsigned long length, |
853 | | % Image *splice) |
854 | | % |
855 | | % A description of each parameter follows: |
856 | | % |
857 | | % o images: The image list. |
858 | | % |
859 | | % o length: The length of the image list to remove. |
860 | | % |
861 | | % o splice: Replace the removed image list with this list. |
862 | | % |
863 | | % |
864 | | */ |
865 | | MagickExport void SpliceImageIntoList(Image **images,const unsigned long length, |
866 | | Image *splice) |
867 | 0 | { |
868 | 0 | Image |
869 | 0 | *split; |
870 | |
|
871 | 0 | register long |
872 | 0 | i; |
873 | |
|
874 | 0 | assert(images != (Image **) NULL); |
875 | 0 | assert(splice != (Image *) NULL); |
876 | 0 | assert(splice->signature == MagickSignature); |
877 | 0 | if ((*images) == (Image *) NULL) |
878 | 0 | return; |
879 | 0 | assert((*images)->signature == MagickSignature); |
880 | 0 | split=SplitImageList(*images); |
881 | 0 | if (split == (Image *) NULL) |
882 | 0 | return; |
883 | 0 | AppendImageToList(images,splice); |
884 | 0 | for (i=0; (i < (long) length) && (split != (Image *) NULL); i++) |
885 | 0 | (void) DeleteImageFromList(&split); |
886 | 0 | AppendImageToList(images,split); |
887 | 0 | } |
888 | | |
889 | | /* |
890 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
891 | | % % |
892 | | % % |
893 | | % % |
894 | | % S p l i t I m a g e L i s t % |
895 | | % % |
896 | | % % |
897 | | % % |
898 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
899 | | % |
900 | | % SplitImageList() splits an image into two lists. |
901 | | % |
902 | | % The format of the SplitImageList method is: |
903 | | % |
904 | | % Image *SplitImageList(Image *images) |
905 | | % |
906 | | % A description of each parameter follows: |
907 | | % |
908 | | % o images: The image list. |
909 | | % |
910 | | % |
911 | | */ |
912 | | MagickExport Image *SplitImageList(Image *images) |
913 | 0 | { |
914 | 0 | if ((images == (Image *) NULL) || (images->next == (Image *) NULL)) |
915 | 0 | return((Image *) NULL); |
916 | 0 | images=images->next; |
917 | 0 | images->previous->next=(Image *) NULL; |
918 | 0 | images->previous=(Image *) NULL; |
919 | 0 | return(images); |
920 | 0 | } |
921 | | |
922 | | /* |
923 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
924 | | % % |
925 | | % % |
926 | | % % |
927 | | + S y n c N e x t I m a g e I n L i s t % |
928 | | % % |
929 | | % % |
930 | | % % |
931 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
932 | | % |
933 | | % SyncNextImageInList() returns the next image in the list after the blob |
934 | | % referenced is synchronized with the current image. |
935 | | % |
936 | | % The format of the SyncNextImageInList method is: |
937 | | % |
938 | | % Image *SyncNextImageInList(const Image *images) |
939 | | % |
940 | | % A description of each parameter follows: |
941 | | % |
942 | | % o images: The image list. |
943 | | % |
944 | | % |
945 | | */ |
946 | | MagickExport Image *SyncNextImageInList(const Image *images) |
947 | 112k | { |
948 | 112k | if (images == (Image *) NULL) |
949 | 0 | return((Image *) NULL); |
950 | 112k | assert(images->signature == MagickSignature); |
951 | 112k | if (images->next == (Image *) NULL) |
952 | 0 | return((Image *) NULL); |
953 | 112k | if (images->blob != images->next->blob) |
954 | 26.1k | { |
955 | 26.1k | DestroyBlob(images->next); |
956 | 26.1k | images->next->blob=ReferenceBlob(images->blob); |
957 | 26.1k | } |
958 | 112k | return(images->next); |
959 | 112k | } |