42#include "MagickCore/studio.h"
43#include "MagickCore/animate.h"
44#include "MagickCore/animate-private.h"
45#include "MagickCore/attribute.h"
46#include "MagickCore/client.h"
47#include "MagickCore/color.h"
48#include "MagickCore/color-private.h"
49#include "MagickCore/colorspace.h"
50#include "MagickCore/colorspace-private.h"
51#include "MagickCore/constitute.h"
52#include "MagickCore/delegate.h"
53#include "MagickCore/exception.h"
54#include "MagickCore/exception-private.h"
55#include "MagickCore/geometry.h"
56#include "MagickCore/image-private.h"
57#include "MagickCore/layer.h"
58#include "MagickCore/list.h"
59#include "MagickCore/locale-private.h"
60#include "MagickCore/log.h"
61#include "MagickCore/image.h"
62#include "MagickCore/memory_.h"
63#include "MagickCore/monitor.h"
64#include "MagickCore/monitor-private.h"
65#include "MagickCore/option.h"
66#include "MagickCore/pixel-accessor.h"
67#include "MagickCore/property.h"
68#include "MagickCore/resource_.h"
69#include "MagickCore/string_.h"
70#include "MagickCore/string-private.h"
71#include "MagickCore/timer-private.h"
72#include "MagickCore/transform.h"
73#include "MagickCore/utility.h"
74#include "MagickCore/utility-private.h"
75#include "MagickCore/version.h"
76#include "MagickCore/widget.h"
77#include "MagickCore/widget-private.h"
78#include "MagickCore/xwindow.h"
79#include "MagickCore/xwindow-private.h"
81#if defined(MAGICKCORE_X11_DELEGATE)
85#define AutoReverseAnimationState 0x0004U
86#define ForwardAnimationState 0x0008U
87#define HighlightState 0x0010U
88#define PlayAnimationState 0x0020U
89#define RepeatAnimationState 0x0040U
90#define StepAnimationState 0x0080U
100 " Press any button to map or unmap the Command widget.\n"
103 " The Command widget lists a number of sub-menus and commands.\n"
121 " Browse Documentation\n"
126 " Menu items with a indented triangle have a sub-menu. They\n"
127 " are represented above as the indented items. To access a\n"
128 " sub-menu item, move the pointer to the appropriate menu and\n"
129 " press a button and drag. When you find the desired sub-menu\n"
130 " item, release the button and the command is executed. Move\n"
131 " the pointer away from the sub-menu if you decide not to\n"
132 " execute a particular command.\n"
134 "KEYBOARD ACCELERATORS\n"
135 " Accelerators are one or two key presses that effect a\n"
136 " particular command. The keyboard accelerators that\n"
137 " animate(1) understands is:\n"
139 " Ctl+O Press to open an image from a file.\n"
141 " space Press to display the next image in the sequence.\n"
143 " < Press to speed-up the display of the images. Refer to\n"
144 " -delay for more information.\n"
146 " > Press to slow the display of the images. Refer to\n"
147 " -delay for more information.\n"
149 " F1 Press to display helpful information about animate(1).\n"
151 " Find Press to browse documentation about ImageMagick.\n"
153 " ? Press to display information about the image. Press\n"
154 " any key or button to erase the information.\n"
156 " This information is printed: image name; image size;\n"
157 " and the total number of unique colors in the image.\n"
159 " Ctl-q Press to discard all images and exit program.\n"
185static const unsigned char
188 (
unsigned char) 0xaa,
189 (
unsigned char) 0x55,
190 (
unsigned char) 0xaa,
191 (
unsigned char) 0x55,
192 (
unsigned char) 0xaa,
193 (
unsigned char) 0x55,
194 (
unsigned char) 0xaa,
199 (
unsigned char) 0x00,
200 (
unsigned char) 0x00,
201 (
unsigned char) 0x00,
202 (
unsigned char) 0x00,
203 (
unsigned char) 0x00,
204 (
unsigned char) 0x00,
205 (
unsigned char) 0x00,
225 BrowseDocumentationCommand,
237#define HighlightWidth 8
238#define HighlightHeight 8
240#define ShadowHeight 8
246 *XMagickCommand(Display *,XResourceInfo *,XWindows *,
const AnimateCommand,
249static MagickBooleanType
281MagickExport MagickBooleanType AnimateImages(
const ImageInfo *image_info,
299 assert(image_info != (
const ImageInfo *) NULL);
300 assert(image_info->signature == MagickCoreSignature);
301 assert(images != (
Image *) NULL);
302 assert(images->signature == MagickCoreSignature);
303 if (IsEventLogging() != MagickFalse)
304 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
305 display=XOpenDisplay(image_info->server_name);
306 if (display == (Display *) NULL)
308 (void) ThrowMagickException(exception,GetMagickModule(),XServerError,
309 "UnableToOpenXServer",
"`%s'",XDisplayName(image_info->server_name));
312 if (exception->severity != UndefinedException)
313 CatchException(exception);
314 (void) XSetErrorHandler(XError);
315 resource_database=XGetResourceDatabase(display,GetClientName());
316 (void) memset(&resource_info,0,
sizeof(XResourceInfo));
317 XGetResourceInfo(image_info,resource_database,GetClientName(),&resource_info);
318 if (image_info->page != (
char *) NULL)
319 resource_info.image_geometry=AcquireString(image_info->page);
320 resource_info.immutable=MagickTrue;
321 argv[0]=AcquireString(GetClientName());
322 (void) XAnimateImages(display,&resource_info,argv,1,images,exception);
323 (void) SetErrorHandler((ErrorHandler) NULL);
324 (void) SetWarningHandler((WarningHandler) NULL);
325 argv[0]=DestroyString(argv[0]);
326 (void) XCloseDisplay(display);
327 XDestroyResourceInfo(&resource_info);
328 status=exception->severity == UndefinedException ? MagickTrue : MagickFalse;
329 return(status != 0 ? MagickTrue : MagickFalse);
371static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
372 XWindows *windows,
const AnimateCommand animate_command,
Image **image,
390 nexus=NewImageList();
391 switch (animate_command)
412 filenames[MagickPathExtent] =
"*";
414 if (resource_info->immutable != MagickFalse)
419 XFileBrowserWidget(display,windows,
"Animate",filenames);
420 if (*filenames ==
'\0')
421 return((
Image *) NULL);
425 filelist=(
char **) AcquireMagickMemory(
sizeof(
char *));
426 if (filelist == (
char **) NULL)
428 ThrowXWindowException(ResourceLimitError,
"MemoryAllocationFailed",
430 return((
Image *) NULL);
433 filelist[0]=filenames;
434 status=ExpandFilenames(&number_files,&filelist);
435 if ((status == MagickFalse) || (number_files == 0))
437 for (i=0; i < number_files; i++)
438 filelist[i]=DestroyString(filelist[i]);
439 filelist=(
char **) RelinquishMagickMemory(filelist);
440 if (number_files == 0)
442 ThrowXWindowException(ImageError,
"NoImagesWereLoaded",filenames);
443 return((
Image *) NULL);
445 ThrowXWindowException(ResourceLimitError,
"MemoryAllocationFailed",
447 return((
Image *) NULL);
449 read_info=CloneImageInfo(resource_info->image_info);
450 images=NewImageList();
451 XSetCursorState(display,windows,MagickTrue);
452 XCheckRefreshWindows(display,windows);
453 for (i=0; i < number_files; i++)
455 (void) CopyMagickString(read_info->filename,filelist[i],MagickPathExtent);
456 filelist[i]=DestroyString(filelist[i]);
457 *read_info->magick=
'\0';
458 next=ReadImage(read_info,exception);
459 CatchException(exception);
460 if (next != (
Image *) NULL)
461 AppendImageToList(&images,next);
462 if (number_files <= 5)
464 proceed=SetImageProgress(images,LoadImageTag,i,(MagickSizeType)
466 if (proceed == MagickFalse)
469 filelist=(
char **) RelinquishMagickMemory(filelist);
470 read_info=DestroyImageInfo(read_info);
471 if (images == (
Image *) NULL)
473 XSetCursorState(display,windows,MagickFalse);
474 ThrowXWindowException(ImageError,
"NoImagesWereLoaded",filenames);
475 return((
Image *) NULL);
477 nexus=GetFirstImageInList(images);
484 basename[MagickPathExtent],
485 name[MagickPathExtent];
493 *state|=PlayAnimationState;
494 *state&=(~AutoReverseAnimationState);
495 GetPathComponent((*image)->magick_filename,BasePath,basename);
496 (void) FormatLocaleString(name,MagickPathExtent,
"%s: %s",
497 MagickPackageName,basename);
498 (void) CloneString(&windows->image.name,name);
499 if (resource_info->title != (
char *) NULL)
504 title=InterpretImageProperties(resource_info->image_info,*image,
505 resource_info->title,exception);
506 (void) CloneString(&windows->image.name,title);
507 title=DestroyString(title);
509 status=XStringListToTextProperty(&windows->image.name,1,&window_name);
512 XSetWMName(display,windows->image.id,&window_name);
513 (void) XFree((
void *) window_name.value);
517 case StepBackwardCommand:
518 case StepForwardCommand:
520 *state|=StepAnimationState;
521 *state&=(~PlayAnimationState);
522 if (animate_command == StepBackwardCommand)
523 *state&=(~ForwardAnimationState);
524 if (animate_command == StepForwardCommand)
525 *state|=ForwardAnimationState;
530 *state|=RepeatAnimationState;
531 *state&=(~AutoReverseAnimationState);
532 *state|=PlayAnimationState;
535 case AutoReverseCommand:
537 *state|=AutoReverseAnimationState;
538 *state&=(~RepeatAnimationState);
539 *state|=PlayAnimationState;
547 status=XSaveImage(display,resource_info,windows,*image,exception);
548 if (status == MagickFalse)
551 message[MagickPathExtent];
553 (void) FormatLocaleString(message,MagickPathExtent,
"%s:%s",
554 exception->reason != (
char *) NULL ? exception->reason :
"",
555 exception->description != (
char *) NULL ? exception->description :
557 XNoticeWidget(display,windows,
"Unable to save file:",message);
564 resource_info->delay++;
569 if (resource_info->delay == 0)
571 resource_info->delay--;
576 *state=ForwardAnimationState;
577 *state&=(~AutoReverseAnimationState);
582 *state&=(~ForwardAnimationState);
583 *state&=(~AutoReverseAnimationState);
588 XDisplayImageInfo(display,resource_info,windows,(
Image *) NULL,*image,
597 XTextViewHelp(display,resource_info,windows,MagickFalse,
598 "Help Viewer - Animate",AnimateHelp);
601 case BrowseDocumentationCommand:
613 root_window=XRootWindow(display,XDefaultScreen(display));
614 mozilla_atom=XInternAtom(display,
"_MOZILLA_VERSION",MagickFalse);
615 mozilla_window=XWindowByProperty(display,root_window,mozilla_atom);
616 if (mozilla_window != (Window) NULL)
619 command[MagickPathExtent];
624 (void) FormatLocaleString(command,MagickPathExtent,
625 "openurl(%s,new-tab)",MagickAuthoritativeURL);
626 mozilla_atom=XInternAtom(display,
"_MOZILLA_COMMAND",MagickFalse);
627 (void) XChangeProperty(display,mozilla_window,mozilla_atom,
628 XA_STRING,8,PropModeReplace,(
unsigned char *) command,
629 (
int) strlen(command));
630 XSetCursorState(display,windows,MagickFalse);
633 XSetCursorState(display,windows,MagickTrue);
634 XCheckRefreshWindows(display,windows);
635 status=InvokeDelegate(resource_info->image_info,*image,
"browse",
636 (
char *) NULL,exception);
637 if (status == MagickFalse)
638 XNoticeWidget(display,windows,
"Unable to browse documentation",
640 XDelay(display,1500);
641 XSetCursorState(display,windows,MagickFalse);
646 XNoticeWidget(display,windows,GetMagickVersion((
size_t *) NULL),
647 GetMagickCopyright());
655 if (resource_info->confirm_exit == MagickFalse)
656 XClientMessage(display,windows->image.id,windows->im_protocols,
657 windows->im_exit,CurrentTime);
666 status=XConfirmWidget(display,windows,
"Do you really want to exit",
667 resource_info->client_name);
669 XClientMessage(display,windows->image.id,windows->im_protocols,
670 windows->im_exit,CurrentTime);
712#if defined(__cplusplus) || defined(c_plusplus)
716static int SceneCompare(
const void *x,
const void *y)
722 image_1=(
const Image **) x;
723 image_2=(
const Image **) y;
724 return((
int) ((*image_1)->scene-(*image_2)->scene));
727#if defined(__cplusplus) || defined(c_plusplus)
731MagickExport
void XAnimateBackgroundImage(Display *display,
735 geometry[MagickPathExtent],
736 visual_type[MagickPathExtent];
765 static XStandardColormap
769 *visual_info = (XVisualInfo *) NULL;
796 assert(images != (
Image *) NULL);
797 assert(images->signature == MagickCoreSignature);
798 if (IsEventLogging() != MagickFalse)
799 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
800 resources=(*resource_info);
801 window_info.id=(Window) NULL;
802 root_window=XRootWindow(display,XDefaultScreen(display));
803 if (LocaleCompare(resources.window_id,
"root") == 0)
804 window_info.id=root_window;
807 if (isdigit((
int) ((
unsigned char) *resources.window_id)) != 0)
808 window_info.id=XWindowByID(display,root_window,
809 (Window) strtol((
char *) resources.window_id,(
char **) NULL,0));
810 if (window_info.id == (Window) NULL)
812 XWindowByName(display,root_window,resources.window_id);
814 if (window_info.id == (Window) NULL)
816 ThrowXWindowException(XServerError,
"NoWindowWithSpecifiedIDExists",
817 resources.window_id);
823 window_attributes.width=XDisplayWidth(display,XDefaultScreen(display));
824 window_attributes.height=XDisplayHeight(display,XDefaultScreen(display));
825 (void) CopyMagickString(visual_type,
"default",MagickPathExtent);
826 status=XGetWindowAttributes(display,window_info.id,&window_attributes) != 0 ?
827 MagickTrue : MagickFalse;
828 if (status != MagickFalse)
829 (void) FormatLocaleString(visual_type,MagickPathExtent,
"0x%lx",
830 XVisualIDFromVisual(window_attributes.visual));
831 if (visual_info == (XVisualInfo *) NULL)
836 map_info=XAllocStandardColormap();
837 if (map_info == (XStandardColormap *) NULL)
838 ThrowXWindowFatalException(ResourceLimitFatalError,
839 "MemoryAllocationFailed",images->filename);
840 map_info->colormap=(Colormap) NULL;
841 pixel.pixels=(
unsigned long *) NULL;
845 resources.map_type=(
char *) NULL;
846 resources.visual_type=visual_type;
847 visual_info=XBestVisualInfo(display,map_info,&resources);
848 if (visual_info == (XVisualInfo *) NULL)
849 ThrowXWindowFatalException(XServerFatalError,
"UnableToGetVisual",
854 window_info.ximage=(XImage *) NULL;
855 window_info.matte_image=(XImage *) NULL;
856 window_info.pixmap=(Pixmap) NULL;
857 window_info.matte_pixmap=(Pixmap) NULL;
862 if (window_info.id == root_window)
863 XDestroyWindowColors(display,root_window);
864 coalesce_image=CoalesceImages(images,exception);
865 if (coalesce_image == (
Image *) NULL)
866 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
868 images=coalesce_image;
869 if (resources.map_type == (
char *) NULL)
870 if ((visual_info->klass != TrueColor) &&
871 (visual_info->klass != DirectColor))
879 for (next=images; next != (
Image *) NULL; )
881 next->alpha_trait=UndefinedPixelTrait;
882 if ((next->storage_class == DirectClass) ||
883 (next->colors != images->colors) ||
884 (next->colors > (
size_t) visual_info->colormap_size))
886 for (i=0; i < (ssize_t) images->colors; i++)
887 if (IsPixelInfoEquivalent(next->colormap+i,images->colormap+i) == MagickFalse)
889 if (i < (ssize_t) images->colors)
891 next=GetNextImageInList(next);
893 if (next != (
Image *) NULL)
894 (void) RemapImages(resources.quantize_info,images,(
Image *) NULL,
900 number_scenes=GetImageListLength(images);
901 image_list=ImageListToArray(images,exception);
902 if (image_list == (
Image **) NULL)
903 ThrowXWindowFatalException(ResourceLimitFatalError,
904 "MemoryAllocationFailed",images->filename);
905 for (i=0; i < (ssize_t) number_scenes; i++)
906 if (image_list[i]->scene == 0)
908 if (i == (ssize_t) number_scenes)
909 qsort((
void *) image_list,number_scenes,
sizeof(
Image *),SceneCompare);
913 resources.colormap=SharedColormap;
914 display_image=image_list[0];
915 for (scene=0; scene < (int) number_scenes; scene++)
917 if ((resource_info->map_type != (
char *) NULL) ||
918 (visual_info->klass == TrueColor) ||
919 (visual_info->klass == DirectColor))
920 (void) SetImageType(image_list[scene],image_list[scene]->alpha_trait ==
921 BlendPixelTrait ? TrueColorType : TrueColorAlphaType,exception);
922 if ((display_image->columns < image_list[scene]->columns) &&
923 (display_image->rows < image_list[scene]->rows))
924 display_image=image_list[scene];
926 if ((resource_info->map_type != (
char *) NULL) ||
927 (visual_info->klass == TrueColor) || (visual_info->klass == DirectColor))
928 (void) SetImageType(display_image,display_image->alpha_trait !=
929 BlendPixelTrait ? TrueColorType : TrueColorAlphaType,exception);
930 XMakeStandardColormap(display,visual_info,&resources,display_image,map_info,
935 context_values.background=pixel.background_color.pixel;
936 context_values.foreground=pixel.foreground_color.pixel;
937 pixel.annotate_context=XCreateGC(display,window_info.id,(
unsigned long)
938 (GCBackground | GCForeground),&context_values);
939 if (pixel.annotate_context == (GC) NULL)
940 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
945 XGetWindowInfo(display,visual_info,map_info,&pixel,(XFontStruct *) NULL,
946 &resources,&window_info);
950 window_info.width=(
unsigned int) image_list[0]->columns;
951 window_info.height=(
unsigned int) image_list[0]->rows;
952 if ((image_list[0]->columns != window_info.width) ||
953 (image_list[0]->rows != window_info.height))
954 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
955 image_list[0]->filename);
956 (void) FormatLocaleString(geometry,MagickPathExtent,
"%ux%u+0+0>",
957 window_attributes.width,window_attributes.height);
958 geometry_info.width=window_info.width;
959 geometry_info.height=window_info.height;
960 geometry_info.x=(ssize_t) window_info.x;
961 geometry_info.y=(ssize_t) window_info.y;
962 (void) ParseMetaGeometry(geometry,&geometry_info.x,&geometry_info.y,
963 &geometry_info.width,&geometry_info.height);
964 window_info.width=(
unsigned int) geometry_info.width;
965 window_info.height=(
unsigned int) geometry_info.height;
966 window_info.x=(int) geometry_info.x;
967 window_info.y=(int) geometry_info.y;
968 status=XMakeImage(display,&resources,&window_info,image_list[0],
969 window_info.width,window_info.height,exception);
970 if (status == MagickFalse)
971 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
975 if (resource_info->debug != MagickFalse)
977 (void) LogMagickEvent(X11Event,GetMagickModule(),
978 "Image: %s[%.20g] %.20gx%.20g ",image_list[0]->filename,(
double)
979 image_list[0]->scene,(
double) image_list[0]->columns,(
double)
980 image_list[0]->rows);
981 if (image_list[0]->colors != 0)
982 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
983 image_list[0]->colors);
984 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
985 image_list[0]->magick);
990 width=window_info.width;
991 height=window_info.height;
992 if (resources.backdrop != MagickFalse)
997 window_info.x=(int) (window_attributes.width/2)-
998 (window_info.ximage->width/2);
999 window_info.y=(int) (window_attributes.height/2)-
1000 (window_info.ximage->height/2);
1001 width=(
unsigned int) window_attributes.width;
1002 height=(
unsigned int) window_attributes.height;
1004 if (resources.image_geometry != (
char *) NULL)
1007 default_geometry[MagickPathExtent];
1019 size_hints=XAllocSizeHints();
1020 if (size_hints == (XSizeHints *) NULL)
1021 ThrowXWindowFatalException(ResourceLimitFatalError,
1022 "MemoryAllocationFailed",images->filename);
1023 size_hints->flags=0L;
1024 (void) FormatLocaleString(default_geometry,MagickPathExtent,
"%ux%u",width,
1026 flags=XWMGeometry(display,visual_info->screen,resources.image_geometry,
1027 default_geometry,window_info.border_width,size_hints,&window_info.x,
1028 &window_info.y,(
int *) &width,(
int *) &height,&gravity);
1029 if (((flags & (XValue | YValue))) != 0)
1031 width=(
unsigned int) window_attributes.width;
1032 height=(
unsigned int) window_attributes.height;
1034 (void) XFree((
void *) size_hints);
1039 window_info.pixmap=XCreatePixmap(display,window_info.id,(
unsigned int) width,
1040 (
unsigned int) height,window_info.depth);
1041 if (window_info.pixmap == (Pixmap) NULL)
1042 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXPixmap",
1047 if (((
unsigned int) width > window_info.width) ||
1048 ((
unsigned int) height > window_info.height))
1049 (void) XFillRectangle(display,window_info.pixmap,
1050 window_info.annotate_context,0,0,(
unsigned int) width,
1051 (
unsigned int) height);
1052 (void) XPutImage(display,window_info.pixmap,window_info.annotate_context,
1053 window_info.ximage,0,0,window_info.x,window_info.y,window_info.width,
1054 window_info.height);
1055 (void) XSetWindowBackgroundPixmap(display,window_info.id,window_info.pixmap);
1056 (void) XClearWindow(display,window_info.id);
1060 window_info.pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1061 sizeof(*window_info.pixmaps));
1062 window_info.matte_pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1063 sizeof(*window_info.matte_pixmaps));
1064 if ((window_info.pixmaps == (Pixmap *) NULL) ||
1065 (window_info.matte_pixmaps == (Pixmap *) NULL))
1066 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1068 window_info.pixmaps[0]=window_info.pixmap;
1069 window_info.matte_pixmaps[0]=window_info.pixmap;
1070 for (scene=1; scene < (int) number_scenes; scene++)
1079 window_info.pixmap=(Pixmap) NULL;
1080 window_info.matte_pixmap=(Pixmap) NULL;
1081 if ((resources.map_type != (
char *) NULL) ||
1082 (visual_info->klass == TrueColor) ||
1083 (visual_info->klass == DirectColor))
1084 if (image_list[scene]->storage_class == PseudoClass)
1085 XGetPixelInfo(display,visual_info,map_info,&resources,
1086 image_list[scene],window_info.pixel_info);
1087 columns=(
unsigned int) image_list[scene]->columns;
1088 rows=(
unsigned int) image_list[scene]->rows;
1089 if ((image_list[scene]->columns != columns) ||
1090 (image_list[scene]->rows != rows))
1091 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1092 image_list[scene]->filename);
1093 status=XMakeImage(display,&resources,&window_info,image_list[scene],
1094 columns,rows,exception);
1095 if (status == MagickFalse)
1096 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1098 if (resource_info->debug != MagickFalse)
1100 (void) LogMagickEvent(X11Event,GetMagickModule(),
1101 "Image: [%.20g] %s %.20gx%.20g ",(
double) image_list[scene]->scene,
1102 image_list[scene]->filename,(
double) columns,(
double) rows);
1103 if (image_list[scene]->colors != 0)
1104 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
1105 image_list[scene]->colors);
1106 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
1107 image_list[scene]->magick);
1112 window_info.pixmap=XCreatePixmap(display,window_info.id,width,height,
1114 if (window_info.pixmap == (Pixmap) NULL)
1115 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXPixmap",
1120 if ((width > window_info.width) || (height > window_info.height))
1121 (void) XFillRectangle(display,window_info.pixmap,
1122 window_info.annotate_context,0,0,width,height);
1123 (void) XPutImage(display,window_info.pixmap,window_info.annotate_context,
1124 window_info.ximage,0,0,window_info.x,window_info.y,window_info.width,
1125 window_info.height);
1126 (void) XSetWindowBackgroundPixmap(display,window_info.id,
1127 window_info.pixmap);
1128 (void) XClearWindow(display,window_info.id);
1129 window_info.pixmaps[scene]=window_info.pixmap;
1130 window_info.matte_pixmaps[scene]=window_info.matte_pixmap;
1131 if (image_list[scene]->alpha_trait)
1132 (void) XClearWindow(display,window_info.id);
1133 delay=1000*image_list[scene]->delay/(size_t) MagickMax(
1134 image_list[scene]->ticks_per_second,1L);
1135 XDelay(display,resources.delay*(delay == 0 ? 10 : delay));
1137 window_info.pixel_info=(&pixel);
1141 (void) XSelectInput(display,window_info.id,SubstructureNotifyMask);
1146 for (scene=0; scene < (int) number_scenes; scene++)
1148 if (XEventsQueued(display,QueuedAfterFlush) > 0)
1150 (void) XNextEvent(display,&event);
1151 if (event.type == DestroyNotify)
1154 window_info.pixmap=window_info.pixmaps[scene];
1155 window_info.matte_pixmap=window_info.matte_pixmaps[scene];
1156 (void) XSetWindowBackgroundPixmap(display,window_info.id,
1157 window_info.pixmap);
1158 (void) XClearWindow(display,window_info.id);
1159 (void) XSync(display,MagickFalse);
1160 delay=1000*image_list[scene]->delay/(size_t) MagickMax(
1161 image_list[scene]->ticks_per_second,1L);
1162 XDelay(display,resources.delay*(delay == 0 ? 10 : delay));
1165 if (iterations == (ssize_t) image_list[0]->iterations)
1167 }
while (event.type != DestroyNotify);
1168 (void) XSync(display,MagickFalse);
1169 image_list=(
Image **) RelinquishMagickMemory(image_list);
1170 images=DestroyImageList(images);
1207MagickExport
Image *XAnimateImages(Display *display,
1208 XResourceInfo *resource_info,
char **argv,
const int argc,
Image *images,
1211#define MagickMenus 4
1213#define MagickTitle "Commands"
1216 *
const CommandMenu[]=
1226 *
const AnimateMenu[]=
1242 *
const DirectionMenu[]=
1251 "Browse Documentation",
1257 *
const *Menus[MagickMenus]=
1265 static const AnimateCommand
1289 DirectionCommands[]=
1297 BrowseDocumentationCommand,
1301 static const AnimateCommand
1302 *Commands[MagickMenus]=
1314 command[MagickPathExtent],
1316 geometry[MagickPathExtent],
1318 resource_name[MagickPathExtent];
1347 working_directory[MagickPathExtent];
1353 *magick_windows[MaXWindows];
1407 assert(images != (
Image *) NULL);
1408 assert(images->signature == MagickCoreSignature);
1409 if (IsEventLogging() != MagickFalse)
1410 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
1411 warning_handler=(WarningHandler) NULL;
1412 windows=XSetWindows((XWindows *) ~0);
1413 if (windows != (XWindows *) NULL)
1418 if (*working_directory ==
'\0')
1419 (void) CopyMagickString(working_directory,
".",MagickPathExtent);
1420 status=chdir(working_directory);
1422 (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
1423 "UnableToOpenFile",
"%s",working_directory);
1424 warning_handler=resource_info->display_warnings ?
1425 SetErrorHandler(XWarning) : SetErrorHandler((ErrorHandler) NULL);
1426 warning_handler=resource_info->display_warnings ?
1427 SetWarningHandler(XWarning) : SetWarningHandler((WarningHandler) NULL);
1437 for (p=images; p != (
Image *) NULL; p=GetNextImageInList(p))
1439 if (p->storage_class == DirectClass)
1441 resource_info->colors=0;
1444 if (p->colors > resource_info->colors)
1445 resource_info->colors=p->colors;
1447 windows=XSetWindows(XInitializeWindows(display,resource_info));
1448 if (windows == (XWindows *) NULL)
1449 ThrowXWindowFatalException(XServerFatalError,
"MemoryAllocationFailed",
1455 magick_windows[number_windows++]=(&windows->icon);
1456 magick_windows[number_windows++]=(&windows->backdrop);
1457 magick_windows[number_windows++]=(&windows->image);
1458 magick_windows[number_windows++]=(&windows->info);
1459 magick_windows[number_windows++]=(&windows->command);
1460 magick_windows[number_windows++]=(&windows->widget);
1461 magick_windows[number_windows++]=(&windows->popup);
1462 for (i=0; i < (ssize_t) number_windows; i++)
1463 magick_windows[i]->
id=(Window) NULL;
1468 if (windows->font_info != (XFontStruct *) NULL)
1469 (void) XFreeFont(display,windows->font_info);
1470 windows->font_info=XBestFont(display,resource_info,MagickFalse);
1471 if (windows->font_info == (XFontStruct *) NULL)
1472 ThrowXWindowFatalException(XServerFatalError,
"UnableToLoadFont",
1473 resource_info->font);
1477 map_info=windows->map_info;
1478 icon_map=windows->icon_map;
1479 visual_info=windows->visual_info;
1480 icon_visual=windows->icon_visual;
1481 pixel=windows->pixel_info;
1482 icon_pixel=windows->icon_pixel;
1483 font_info=windows->font_info;
1484 icon_resources=windows->icon_resources;
1485 class_hints=windows->class_hints;
1486 manager_hints=windows->manager_hints;
1487 root_window=XRootWindow(display,visual_info->screen);
1488 coalesce_image=CoalesceImages(images,exception);
1489 if (coalesce_image == (
Image *) NULL)
1490 ThrowXWindowFatalException(XServerFatalError,
"MemoryAllocationFailed",
1492 images=coalesce_image;
1493 if (resource_info->map_type == (
char *) NULL)
1494 if ((visual_info->klass != TrueColor) &&
1495 (visual_info->klass != DirectColor))
1503 for (next=images; next != (
Image *) NULL; )
1505 next->alpha_trait=UndefinedPixelTrait;
1506 if ((next->storage_class == DirectClass) ||
1507 (next->colors != images->colors) ||
1508 (next->colors > (
size_t) visual_info->colormap_size))
1510 for (i=0; i < (ssize_t) images->colors; i++)
1511 if (IsPixelInfoEquivalent(next->colormap+i,images->colormap+i) == MagickFalse)
1513 if (i < (ssize_t) images->colors)
1515 next=GetNextImageInList(next);
1517 if (next != (
Image *) NULL)
1518 (void) RemapImages(resource_info->quantize_info,images,
1519 (
Image *) NULL,exception);
1524 number_scenes=GetImageListLength(images);
1525 image_list=ImageListToArray(images,exception);
1526 if (image_list == (
Image **) NULL)
1527 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1529 for (scene=0; scene < (ssize_t) number_scenes; scene++)
1530 if (image_list[scene]->scene == 0)
1532 if (scene == (ssize_t) number_scenes)
1533 qsort((
void *) image_list,number_scenes,
sizeof(
Image *),SceneCompare);
1537 nexus=NewImageList();
1538 display_image=image_list[0];
1539 for (scene=0; scene < (ssize_t) number_scenes; scene++)
1541 if ((resource_info->map_type != (
char *) NULL) ||
1542 (visual_info->klass == TrueColor) ||
1543 (visual_info->klass == DirectColor))
1544 (void) SetImageType(image_list[scene],image_list[scene]->alpha_trait ==
1545 BlendPixelTrait ? TrueColorType : TrueColorAlphaType,exception);
1546 if ((display_image->columns < image_list[scene]->columns) &&
1547 (display_image->rows < image_list[scene]->rows))
1548 display_image=image_list[scene];
1550 if (resource_info->debug != MagickFalse)
1552 (void) LogMagickEvent(X11Event,GetMagickModule(),
1553 "Image: %s[%.20g] %.20gx%.20g ",display_image->filename,(
double)
1554 display_image->scene,(
double) display_image->columns,(
double)
1555 display_image->rows);
1556 if (display_image->colors != 0)
1557 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
1558 display_image->colors);
1559 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
1560 display_image->magick);
1562 XMakeStandardColormap(display,visual_info,resource_info,display_image,
1563 map_info,pixel,exception);
1567 windows->context.id=(Window) NULL;
1568 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1569 resource_info,&windows->context);
1570 (void) CloneString(&class_hints->res_name,resource_info->client_name);
1571 (void) CloneString(&class_hints->res_class,resource_info->client_name);
1572 class_hints->res_class[0]=(char) LocaleToUppercase((
int)
1573 class_hints->res_class[0]);
1574 manager_hints->flags=InputHint | StateHint;
1575 manager_hints->input=MagickFalse;
1576 manager_hints->initial_state=WithdrawnState;
1577 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1579 if (resource_info->debug != MagickFalse)
1580 (void) LogMagickEvent(X11Event,GetMagickModule(),
1581 "Window id: 0x%lx (context)",windows->context.id);
1582 context_values.background=pixel->background_color.pixel;
1583 context_values.font=font_info->fid;
1584 context_values.foreground=pixel->foreground_color.pixel;
1585 context_values.graphics_exposures=MagickFalse;
1586 context_mask=(MagickStatusType)
1587 (GCBackground | GCFont | GCForeground | GCGraphicsExposures);
1588 if (pixel->annotate_context != (GC) NULL)
1589 (void) XFreeGC(display,pixel->annotate_context);
1590 pixel->annotate_context=
1591 XCreateGC(display,windows->context.id,context_mask,&context_values);
1592 if (pixel->annotate_context == (GC) NULL)
1593 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1595 context_values.background=pixel->depth_color.pixel;
1596 if (pixel->widget_context != (GC) NULL)
1597 (void) XFreeGC(display,pixel->widget_context);
1598 pixel->widget_context=
1599 XCreateGC(display,windows->context.id,context_mask,&context_values);
1600 if (pixel->widget_context == (GC) NULL)
1601 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1603 context_values.background=pixel->foreground_color.pixel;
1604 context_values.foreground=pixel->background_color.pixel;
1605 context_values.plane_mask=
1606 context_values.background ^ context_values.foreground;
1607 if (pixel->highlight_context != (GC) NULL)
1608 (void) XFreeGC(display,pixel->highlight_context);
1609 pixel->highlight_context=XCreateGC(display,windows->context.id,
1610 (
size_t) (context_mask | GCPlaneMask),&context_values);
1611 if (pixel->highlight_context == (GC) NULL)
1612 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1614 (void) XDestroyWindow(display,windows->context.id);
1618 XGetWindowInfo(display,icon_visual,icon_map,icon_pixel,(XFontStruct *) NULL,
1619 icon_resources,&windows->icon);
1620 windows->icon.geometry=resource_info->icon_geometry;
1621 XBestIconSize(display,&windows->icon,display_image);
1622 windows->icon.attributes.colormap=
1623 XDefaultColormap(display,icon_visual->screen);
1624 windows->icon.attributes.event_mask=ExposureMask | StructureNotifyMask;
1625 manager_hints->flags=InputHint | StateHint;
1626 manager_hints->input=MagickFalse;
1627 manager_hints->initial_state=IconicState;
1628 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1630 if (resource_info->debug != MagickFalse)
1631 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Window id: 0x%lx (icon)",
1636 if (icon_pixel->annotate_context != (GC) NULL)
1637 (void) XFreeGC(display,icon_pixel->annotate_context);
1638 context_values.background=icon_pixel->background_color.pixel;
1639 context_values.foreground=icon_pixel->foreground_color.pixel;
1640 icon_pixel->annotate_context=XCreateGC(display,windows->icon.id,
1641 (
size_t) (GCBackground | GCForeground),&context_values);
1642 if (icon_pixel->annotate_context == (GC) NULL)
1643 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1645 windows->icon.annotate_context=icon_pixel->annotate_context;
1649 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1650 resource_info,&windows->image);
1651 windows->image.shape=MagickTrue;
1652 if (resource_info->use_shared_memory == MagickFalse)
1653 windows->image.shared_memory=MagickFalse;
1654 if (resource_info->title != (
char *) NULL)
1659 title=InterpretImageProperties(resource_info->image_info,display_image,
1660 resource_info->title,exception);
1661 (void) CloneString(&windows->image.name,title);
1662 (void) CloneString(&windows->image.icon_name,title);
1663 title=DestroyString(title);
1668 filename[MagickPathExtent],
1669 window_name[MagickPathExtent];
1674 GetPathComponent(display_image->magick_filename,TailPath,filename);
1675 (void) FormatLocaleString(window_name,MagickPathExtent,
1676 "%s: %s[scene: %.20g frames: %.20g]",MagickPackageName,filename,(
double)
1677 display_image->scene,(
double) number_scenes);
1678 (void) CloneString(&windows->image.name,window_name);
1679 (void) CloneString(&windows->image.icon_name,filename);
1681 if (resource_info->immutable != MagickFalse)
1682 windows->image.immutable=MagickTrue;
1683 windows->image.shape=MagickTrue;
1684 windows->image.geometry=resource_info->image_geometry;
1685 (void) FormatLocaleString(geometry,MagickPathExtent,
"%ux%u+0+0>!",
1686 XDisplayWidth(display,visual_info->screen),
1687 XDisplayHeight(display,visual_info->screen));
1688 geometry_info.width=display_image->columns;
1689 geometry_info.height=display_image->rows;
1692 (void) ParseMetaGeometry(geometry,&geometry_info.x,&geometry_info.y,
1693 &geometry_info.width,&geometry_info.height);
1694 windows->image.width=(
unsigned int) geometry_info.width;
1695 windows->image.height=(
unsigned int) geometry_info.height;
1696 windows->image.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1697 ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask |
1698 KeyReleaseMask | LeaveWindowMask | OwnerGrabButtonMask |
1699 PropertyChangeMask | StructureNotifyMask | SubstructureNotifyMask;
1700 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1701 resource_info,&windows->backdrop);
1702 if ((resource_info->backdrop) || (windows->backdrop.id != (Window) NULL))
1707 windows->backdrop.x=0;
1708 windows->backdrop.y=0;
1709 (void) CloneString(&windows->backdrop.name,
"ImageMagick Backdrop");
1710 windows->backdrop.flags=(size_t) (USSize | USPosition);
1711 windows->backdrop.width=(
unsigned int)
1712 XDisplayWidth(display,visual_info->screen);
1713 windows->backdrop.height=(
unsigned int)
1714 XDisplayHeight(display,visual_info->screen);
1715 windows->backdrop.border_width=0;
1716 windows->backdrop.immutable=MagickTrue;
1717 windows->backdrop.attributes.do_not_propagate_mask=ButtonPressMask |
1719 windows->backdrop.attributes.event_mask=ButtonPressMask | KeyPressMask |
1720 StructureNotifyMask;
1721 manager_hints->flags=IconWindowHint | InputHint | StateHint;
1722 manager_hints->icon_window=windows->icon.id;
1723 manager_hints->input=MagickTrue;
1724 manager_hints->initial_state=
1725 resource_info->iconic ? IconicState : NormalState;
1726 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1727 &windows->backdrop);
1728 if (resource_info->debug != MagickFalse)
1729 (void) LogMagickEvent(X11Event,GetMagickModule(),
1730 "Window id: 0x%lx (backdrop)",windows->backdrop.id);
1731 (void) XMapWindow(display,windows->backdrop.id);
1732 (void) XClearWindow(display,windows->backdrop.id);
1733 if (windows->image.id != (Window) NULL)
1735 (void) XDestroyWindow(display,windows->image.id);
1736 windows->image.id=(Window) NULL;
1741 windows->image.flags|=USPosition;
1742 windows->image.x=(XDisplayWidth(display,visual_info->screen)/2)-
1743 ((ssize_t) windows->image.width/2);
1744 windows->image.y=(XDisplayHeight(display,visual_info->screen)/2)-
1745 ((ssize_t) windows->image.height/2);
1747 manager_hints->flags=IconWindowHint | InputHint | StateHint;
1748 manager_hints->icon_window=windows->icon.id;
1749 manager_hints->input=MagickTrue;
1750 manager_hints->initial_state=
1751 resource_info->iconic ? IconicState : NormalState;
1752 if (windows->group_leader.id != (Window) NULL)
1757 manager_hints->flags|=(MagickStatusType) WindowGroupHint;
1758 manager_hints->window_group=windows->group_leader.id;
1759 (void) XSelectInput(display,windows->group_leader.id,StructureNotifyMask);
1760 if (resource_info->debug != MagickFalse)
1761 (void) LogMagickEvent(X11Event,GetMagickModule(),
1762 "Window id: 0x%lx (group leader)",windows->group_leader.id);
1764 XMakeWindow(display,
1765 (Window) (resource_info->backdrop ? windows->backdrop.id : root_window),
1766 argv,argc,class_hints,manager_hints,&windows->image);
1767 (void) XChangeProperty(display,windows->image.id,windows->im_protocols,
1768 XA_STRING,8,PropModeReplace,(
unsigned char *) NULL,0);
1769 if (windows->group_leader.id != (Window) NULL)
1770 (void) XSetTransientForHint(display,windows->image.id,
1771 windows->group_leader.id);
1772 if (resource_info->debug != MagickFalse)
1773 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Window id: 0x%lx (image)",
1778 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1779 resource_info,&windows->info);
1780 (void) CloneString(&windows->info.name,
"Info");
1781 (void) CloneString(&windows->info.icon_name,
"Info");
1782 windows->info.border_width=1;
1785 windows->info.flags|=PPosition;
1786 windows->info.attributes.win_gravity=UnmapGravity;
1787 windows->info.attributes.event_mask=ButtonPressMask | ExposureMask |
1788 StructureNotifyMask;
1789 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1790 manager_hints->input=MagickFalse;
1791 manager_hints->initial_state=NormalState;
1792 manager_hints->window_group=windows->image.id;
1793 XMakeWindow(display,windows->image.id,argv,argc,class_hints,manager_hints,
1795 windows->info.highlight_stipple=XCreateBitmapFromData(display,
1796 windows->info.id,(
char *) HighlightBitmap,HighlightWidth,HighlightHeight);
1797 windows->info.shadow_stipple=XCreateBitmapFromData(display,
1798 windows->info.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1799 (void) XSetTransientForHint(display,windows->info.id,windows->image.id);
1800 if (windows->image.mapped)
1801 (void) XWithdrawWindow(display,windows->info.id,windows->info.screen);
1802 if (resource_info->debug != MagickFalse)
1803 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Window id: 0x%lx (info)",
1808 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1809 resource_info,&windows->command);
1810 windows->command.data=MagickMenus;
1811 (void) XCommandWidget(display,windows,CommandMenu,(XEvent *) NULL);
1812 (void) FormatLocaleString(resource_name,MagickPathExtent,
"%s.command",
1813 resource_info->client_name);
1814 windows->command.geometry=XGetResourceClass(resource_info->resource_database,
1815 resource_name,
"geometry",(
char *) NULL);
1816 (void) CloneString(&windows->command.name,MagickTitle);
1817 windows->command.border_width=0;
1818 windows->command.flags|=PPosition;
1819 windows->command.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1820 ButtonReleaseMask | EnterWindowMask | ExposureMask | LeaveWindowMask |
1821 OwnerGrabButtonMask | StructureNotifyMask;
1822 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1823 manager_hints->input=MagickTrue;
1824 manager_hints->initial_state=NormalState;
1825 manager_hints->window_group=windows->image.id;
1826 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1828 windows->command.highlight_stipple=XCreateBitmapFromData(display,
1829 windows->command.id,(
char *) HighlightBitmap,HighlightWidth,
1831 windows->command.shadow_stipple=XCreateBitmapFromData(display,
1832 windows->command.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1833 (void) XSetTransientForHint(display,windows->command.id,windows->image.id);
1834 if (resource_info->debug != MagickFalse)
1835 (void) LogMagickEvent(X11Event,GetMagickModule(),
1836 "Window id: 0x%lx (command)",windows->command.id);
1840 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1841 resource_info,&windows->widget);
1842 (void) FormatLocaleString(resource_name,MagickPathExtent,
"%s.widget",
1843 resource_info->client_name);
1844 windows->widget.geometry=XGetResourceClass(resource_info->resource_database,
1845 resource_name,
"geometry",(
char *) NULL);
1846 windows->widget.border_width=0;
1847 windows->widget.flags|=PPosition;
1848 windows->widget.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1849 ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask |
1850 KeyReleaseMask | LeaveWindowMask | OwnerGrabButtonMask |
1851 StructureNotifyMask;
1852 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1853 manager_hints->input=MagickTrue;
1854 manager_hints->initial_state=NormalState;
1855 manager_hints->window_group=windows->image.id;
1856 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1858 windows->widget.highlight_stipple=XCreateBitmapFromData(display,
1859 windows->widget.id,(
char *) HighlightBitmap,HighlightWidth,HighlightHeight);
1860 windows->widget.shadow_stipple=XCreateBitmapFromData(display,
1861 windows->widget.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1862 (void) XSetTransientForHint(display,windows->widget.id,windows->image.id);
1863 if (resource_info->debug != MagickFalse)
1864 (void) LogMagickEvent(X11Event,GetMagickModule(),
1865 "Window id: 0x%lx (widget)",windows->widget.id);
1869 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1870 resource_info,&windows->popup);
1871 windows->popup.border_width=0;
1872 windows->popup.flags|=PPosition;
1873 windows->popup.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1874 ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask |
1875 KeyReleaseMask | LeaveWindowMask | StructureNotifyMask;
1876 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1877 manager_hints->input=MagickTrue;
1878 manager_hints->initial_state=NormalState;
1879 manager_hints->window_group=windows->image.id;
1880 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1882 windows->popup.highlight_stipple=XCreateBitmapFromData(display,
1883 windows->popup.id,(
char *) HighlightBitmap,HighlightWidth,HighlightHeight);
1884 windows->popup.shadow_stipple=XCreateBitmapFromData(display,
1885 windows->popup.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1886 (void) XSetTransientForHint(display,windows->popup.id,windows->image.id);
1887 if (resource_info->debug != MagickFalse)
1888 (void) LogMagickEvent(X11Event,GetMagickModule(),
1889 "Window id: 0x%lx (pop up)",windows->popup.id);
1893 if (warning_handler == (WarningHandler) NULL)
1895 warning_handler=resource_info->display_warnings ?
1896 SetErrorHandler(XWarning) : SetErrorHandler((ErrorHandler) NULL);
1897 warning_handler=resource_info->display_warnings ?
1898 SetWarningHandler(XWarning) : SetWarningHandler((WarningHandler) NULL);
1908 window_changes.width=(int) windows->image.width;
1909 window_changes.height=(int) windows->image.height;
1910 (void) XReconfigureWMWindow(display,windows->image.id,windows->command.screen,
1911 (
unsigned int) (CWWidth | CWHeight),&window_changes);
1912 windows->image.pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1913 sizeof(*windows->image.pixmaps));
1914 windows->image.matte_pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1915 sizeof(*windows->image.pixmaps));
1916 if ((windows->image.pixmaps == (Pixmap *) NULL) ||
1917 (windows->image.matte_pixmaps == (Pixmap *) NULL))
1918 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1920 if ((windows->image.mapped == MagickFalse) ||
1921 (windows->backdrop.id != (Window) NULL))
1922 (void) XMapWindow(display,windows->image.id);
1923 XSetCursorState(display,windows,MagickTrue);
1924 for (scene=0; scene < (ssize_t) number_scenes; scene++)
1933 windows->image.pixmap=(Pixmap) NULL;
1934 windows->image.matte_pixmap=(Pixmap) NULL;
1935 if ((resource_info->map_type != (
char *) NULL) ||
1936 (visual_info->klass == TrueColor) ||
1937 (visual_info->klass == DirectColor))
1938 if (image_list[scene]->storage_class == PseudoClass)
1939 XGetPixelInfo(display,visual_info,map_info,resource_info,
1940 image_list[scene],windows->image.pixel_info);
1941 columns=(
unsigned int) image_list[scene]->columns;
1942 rows=(
unsigned int) image_list[scene]->rows;
1943 if ((image_list[scene]->columns != columns) ||
1944 (image_list[scene]->rows != rows))
1945 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1946 image_list[scene]->filename);
1947 status=XMakeImage(display,resource_info,&windows->image,image_list[scene],
1948 columns,rows,exception) == MagickFalse ? 0 : 1;
1949 if (status == MagickFalse)
1950 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1952 if (image_list[scene]->debug != MagickFalse)
1954 (void) LogMagickEvent(X11Event,GetMagickModule(),
1955 "Image: [%.20g] %s %.20gx%.20g ",(
double) image_list[scene]->scene,
1956 image_list[scene]->filename,(
double) columns,(
double) rows);
1957 if (image_list[scene]->colors != 0)
1958 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
1959 image_list[scene]->colors);
1960 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
1961 image_list[scene]->magick);
1966 if (resource_info->title != (
char *) NULL)
1971 title=InterpretImageProperties(resource_info->image_info,
1972 image_list[scene],resource_info->title,exception);
1973 (void) CloneString(&windows->image.name,title);
1974 title=DestroyString(title);
1979 window_name[MagickPathExtent];
1981 p=image_list[scene]->magick_filename+
1982 strlen(image_list[scene]->magick_filename)-1;
1983 while ((p > image_list[scene]->magick_filename) && (*(p-1) !=
'/'))
1985 (void) FormatLocaleString(window_name,MagickPathExtent,
1986 "%s: %s[%.20g of %.20g]",MagickPackageName,p,(
double) scene+1,
1987 (
double) number_scenes);
1988 (void) CloneString(&windows->image.name,window_name);
1990 status=XStringListToTextProperty(&windows->image.name,1,&window_name);
1991 if (status != Success)
1993 XSetWMName(display,windows->image.id,&window_name);
1994 (void) XFree((
void *) window_name.value);
1996 windows->image.pixmaps[scene]=windows->image.pixmap;
1997 windows->image.matte_pixmaps[scene]=windows->image.matte_pixmap;
2002 event.xexpose.width=(int) image_list[scene]->columns;
2003 event.xexpose.height=(int) image_list[scene]->rows;
2004 XRefreshWindow(display,&windows->image,&event);
2005 (void) XSync(display,MagickFalse);
2008 XSetCursorState(display,windows,MagickFalse);
2009 if (windows->command.mapped)
2010 (void) XMapRaised(display,windows->command.id);
2014 nexus=NewImageList();
2018 image=image_list[0];
2019 state=(MagickStatusType) (ForwardAnimationState | RepeatAnimationState);
2020 (void) XMagickCommand(display,resource_info,windows,PlayCommand,&images,
2024 if (XEventsQueued(display,QueuedAfterFlush) == 0)
2025 if ((state & PlayAnimationState) || (state & StepAnimationState))
2031 delay=1000*image->delay/(size_t) MagickMax(image->ticks_per_second,
2033 XDelay(display,resource_info->delay*(delay == 0 ? 10 : delay));
2034 if (state & ForwardAnimationState)
2039 if (scene < ((ssize_t) number_scenes-1))
2044 if (iterations == (ssize_t) image_list[0]->iterations)
2049 if ((state & AutoReverseAnimationState) != 0)
2051 state&=(~ForwardAnimationState);
2056 if ((state & RepeatAnimationState) == 0)
2057 state&=(~PlayAnimationState);
2068 if (scene > first_scene)
2073 if (iterations == (ssize_t) image_list[0]->iterations)
2076 state&=(~RepeatAnimationState);
2078 if (state & AutoReverseAnimationState)
2080 state|=ForwardAnimationState;
2086 if ((state & RepeatAnimationState) == MagickFalse)
2087 state&=(~PlayAnimationState);
2088 scene=(ssize_t) number_scenes-1;
2092 scene=MagickMax(scene,0);
2093 image=image_list[scene];
2094 if ((image != (
Image *) NULL) && (image->start_loop != 0))
2096 if ((state & StepAnimationState) ||
2097 (resource_info->title != (
char *) NULL))
2100 name[MagickPathExtent];
2105 p=image_list[scene]->filename+
2106 strlen(image_list[scene]->filename)-1;
2107 while ((p > image_list[scene]->filename) && (*(p-1) !=
'/'))
2109 (void) FormatLocaleString(name,MagickPathExtent,
2110 "%s: %s[%.20g of %.20g]",MagickPackageName,p,(
double)
2111 scene+1,(
double) number_scenes);
2112 (void) CloneString(&windows->image.name,name);
2113 if (resource_info->title != (
char *) NULL)
2118 title=InterpretImageProperties(resource_info->image_info,
2119 image,resource_info->title,exception);
2120 (void) CloneString(&windows->image.name,title);
2121 title=DestroyString(title);
2123 status=XStringListToTextProperty(&windows->image.name,1,
2125 if (status != Success)
2127 XSetWMName(display,windows->image.id,&window_name);
2128 (void) XFree((
void *) window_name.value);
2134 XGetPixelInfo(display,visual_info,map_info,resource_info,
2135 image_list[scene],windows->image.pixel_info);
2136 if (image != (
Image *) NULL)
2138 windows->image.ximage->width=(int) image->columns;
2139 windows->image.ximage->height=(int) image->rows;
2141 windows->image.pixmap=windows->image.pixmaps[scene];
2142 windows->image.matte_pixmap=windows->image.matte_pixmaps[scene];
2145 event.xexpose.width=(int) image->columns;
2146 event.xexpose.height=(int) image->rows;
2147 if ((state & ExitState) == 0)
2149 XRefreshWindow(display,&windows->image,&event);
2150 (void) XSync(display,MagickFalse);
2152 state&=(~StepAnimationState);
2153 if (pause != MagickFalse)
2154 for (i=0; i < (ssize_t) resource_info->pause; i++)
2159 status=XCheckTypedWindowEvent(display,windows->image.id,KeyPress,
2166 length=XLookupString((XKeyEvent *) &event.xkey,command,(
int)
2167 sizeof(command),&key_symbol,(XComposeStatus *) NULL);
2168 *(command+length)=
'\0';
2169 if ((key_symbol == XK_q) || (key_symbol == XK_Escape))
2171 XClientMessage(display,windows->image.id,
2172 windows->im_protocols,windows->im_exit,CurrentTime);
2183 timestamp=GetMagickTime();
2184 (void) XNextEvent(display,&event);
2185 if (windows->image.stasis == MagickFalse)
2186 windows->image.stasis=(GetMagickTime()-timestamp) > 0 ?
2187 MagickTrue : MagickFalse;
2188 if (event.xany.window == windows->command.id)
2196 id=XCommandWidget(display,windows,CommandMenu,&event);
2199 (void) CopyMagickString(command,CommandMenu[
id],MagickPathExtent);
2200 animate_command=CommandMenus[id];
2201 if (
id < MagickMenus)
2209 entry=XMenuWidget(display,windows,CommandMenu[
id],Menus[
id],
2213 (void) CopyMagickString(command,Menus[
id][entry],MagickPathExtent);
2214 animate_command=Commands[id][entry];
2216 if (animate_command != NullCommand)
2217 nexus=XMagickCommand(display,resource_info,windows,animate_command,
2218 &image,&state,exception);
2225 if (resource_info->debug != MagickFalse)
2226 (void) LogMagickEvent(X11Event,GetMagickModule(),
2227 "Button Press: 0x%lx %u +%d+%d",event.xbutton.window,
2228 event.xbutton.button,event.xbutton.x,event.xbutton.y);
2229 if ((event.xbutton.button == Button3) &&
2230 (event.xbutton.state & Mod1Mask))
2235 event.xbutton.button=Button2;
2236 event.xbutton.state&=(~(
unsigned int) Mod1Mask);
2238 if (event.xbutton.window == windows->backdrop.id)
2240 (void) XSetInputFocus(display,event.xbutton.window,RevertToParent,
2241 event.xbutton.time);
2244 if (event.xbutton.window == windows->image.id)
2246 if (resource_info->immutable != MagickFalse)
2254 if (windows->command.mapped)
2255 (void) XWithdrawWindow(display,windows->command.id,
2256 windows->command.screen);
2259 (void) XCommandWidget(display,windows,CommandMenu,
2261 (void) XMapRaised(display,windows->command.id);
2268 if (resource_info->debug != MagickFalse)
2269 (void) LogMagickEvent(X11Event,GetMagickModule(),
2270 "Button Release: 0x%lx %u +%d+%d",event.xbutton.window,
2271 event.xbutton.button,event.xbutton.x,event.xbutton.y);
2276 if (resource_info->debug != MagickFalse)
2277 (void) LogMagickEvent(X11Event,GetMagickModule(),
2278 "Client Message: 0x%lx 0x%lx %d 0x%lx",(
unsigned long)
2279 event.xclient.window,(
unsigned long) event.xclient.message_type,
2280 event.xclient.format,(
unsigned long) event.xclient.data.l[0]);
2281 if (event.xclient.message_type == windows->im_protocols)
2283 if (*event.xclient.data.l == (
long) windows->im_update_colormap)
2288 for (i=0; i < (ssize_t) number_windows; i++)
2290 if (magick_windows[i]->
id == windows->icon.id)
2292 context_values.background=pixel->background_color.pixel;
2293 context_values.foreground=pixel->foreground_color.pixel;
2294 (void) XChangeGC(display,magick_windows[i]->annotate_context,
2295 context_mask,&context_values);
2296 (void) XChangeGC(display,magick_windows[i]->widget_context,
2297 context_mask,&context_values);
2298 context_values.background=pixel->foreground_color.pixel;
2299 context_values.foreground=pixel->background_color.pixel;
2300 context_values.plane_mask=
2301 context_values.background ^ context_values.foreground;
2302 (void) XChangeGC(display,magick_windows[i]->highlight_context,
2303 (
size_t) (context_mask | GCPlaneMask),
2305 magick_windows[i]->attributes.background_pixel=
2306 pixel->background_color.pixel;
2307 magick_windows[i]->attributes.border_pixel=
2308 pixel->border_color.pixel;
2309 magick_windows[i]->attributes.colormap=map_info->colormap;
2310 (void) XChangeWindowAttributes(display,magick_windows[i]->
id,
2311 (
unsigned long) magick_windows[i]->mask,
2312 &magick_windows[i]->attributes);
2314 if (windows->backdrop.id != (Window) NULL)
2315 (void) XInstallColormap(display,map_info->colormap);
2318 if (*event.xclient.data.l == (
long) windows->im_exit)
2325 if (event.xclient.message_type == windows->dnd_protocols)
2345 if ((*event.xclient.data.l != 2) && (*event.xclient.data.l != 128))
2347 selection=XInternAtom(display,
"DndSelection",MagickFalse);
2348 status=XGetWindowProperty(display,root_window,selection,0L,2047L,
2349 MagickFalse,(Atom) AnyPropertyType,&type,&format,&length,&after,
2351 if ((status != Success) || (length == 0))
2353 if (*event.xclient.data.l == 2)
2358 (void) CopyMagickString(resource_info->image_info->filename,
2359 (
char *) data,MagickPathExtent);
2366 if (LocaleNCompare((
char *) data,
"file:",5) != 0)
2368 (void) XFree((
void *) data);
2371 (void) CopyMagickString(resource_info->image_info->filename,
2372 ((
char *) data)+5,MagickPathExtent);
2374 nexus=ReadImage(resource_info->image_info,exception);
2375 CatchException(exception);
2376 if (nexus != (
Image *) NULL)
2378 (void) XFree((
void *) data);
2384 if (event.xclient.message_type != windows->wm_protocols)
2386 if (*event.xclient.data.l == (
long) windows->wm_take_focus)
2388 (void) XSetInputFocus(display,event.xclient.window,RevertToParent,
2389 (Time) event.xclient.data.l[1]);
2392 if (*event.xclient.data.l != (
long) windows->wm_delete_window)
2394 (void) XWithdrawWindow(display,event.xclient.window,
2395 visual_info->screen);
2396 if (event.xclient.window == windows->image.id)
2403 case ConfigureNotify:
2405 if (resource_info->debug != MagickFalse)
2406 (void) LogMagickEvent(X11Event,GetMagickModule(),
2407 "Configure Notify: 0x%lx %dx%d+%d+%d %d",event.xconfigure.window,
2408 event.xconfigure.width,event.xconfigure.height,event.xconfigure.x,
2409 event.xconfigure.y,event.xconfigure.send_event);
2410 if (event.xconfigure.window == windows->image.id)
2412 if (event.xconfigure.send_event != 0)
2420 if (windows->command.geometry == (
char *) NULL)
2421 if (windows->command.mapped == MagickFalse)
2423 windows->command.x=
event.xconfigure.x-
2424 (ssize_t) windows->command.width-25;
2425 windows->command.y=
event.xconfigure.y;
2426 XConstrainWindowPosition(display,&windows->command);
2427 window_changes.x=windows->command.x;
2428 window_changes.y=windows->command.y;
2429 (void) XReconfigureWMWindow(display,windows->command.id,
2430 windows->command.screen,(
unsigned int) (CWX | CWY),
2433 if (windows->widget.geometry == (
char *) NULL)
2434 if (windows->widget.mapped == MagickFalse)
2437 event.xconfigure.x+
event.xconfigure.width/10;
2439 event.xconfigure.y+
event.xconfigure.height/10;
2440 XConstrainWindowPosition(display,&windows->widget);
2441 window_changes.x=windows->widget.x;
2442 window_changes.y=windows->widget.y;
2443 (void) XReconfigureWMWindow(display,windows->widget.id,
2444 windows->widget.screen,(
unsigned int) (CWX | CWY),
2451 windows->image.width=(
unsigned int) event.xconfigure.width;
2452 windows->image.height=(
unsigned int) event.xconfigure.height;
2455 if (event.xconfigure.window == windows->icon.id)
2460 windows->icon.width=(
unsigned int) event.xconfigure.width;
2461 windows->icon.height=(
unsigned int) event.xconfigure.height;
2471 if (resource_info->debug != MagickFalse)
2472 (void) LogMagickEvent(X11Event,GetMagickModule(),
2473 "Destroy Notify: 0x%lx",event.xdestroywindow.window);
2474 if (event.xdestroywindow.window == windows->group_leader.id)
2486 if (map_info->colormap != XDefaultColormap(display,visual_info->screen))
2487 if (event.xcrossing.mode != NotifyUngrab)
2488 XInstallColormap(display,map_info->colormap);
2493 if (resource_info->debug != MagickFalse)
2494 (void) LogMagickEvent(X11Event,GetMagickModule(),
2495 "Expose: 0x%lx %dx%d+%d+%d",event.xexpose.window,
2496 event.xexpose.width,event.xexpose.height,event.xexpose.x,
2501 if (event.xexpose.window == windows->image.id)
2503 windows->image.pixmap=windows->image.pixmaps[scene];
2504 windows->image.matte_pixmap=windows->image.matte_pixmaps[scene];
2505 XRefreshWindow(display,&windows->image,&event);
2508 if (event.xexpose.window == windows->icon.id)
2509 if (event.xexpose.count == 0)
2511 XRefreshWindow(display,&windows->icon,&event);
2524 length=XLookupString((XKeyEvent *) &event.xkey,command,(
int)
2525 sizeof(command),&key_symbol,(XComposeStatus *) NULL);
2526 *(command+length)=
'\0';
2527 if (resource_info->debug != MagickFalse)
2528 (void) LogMagickEvent(X11Event,GetMagickModule(),
2529 "Key press: 0x%lx (%c)",(
unsigned long) key_symbol,*command);
2530 animate_command=NullCommand;
2535 if ((event.xkey.state & ControlMask) == MagickFalse)
2537 animate_command=OpenCommand;
2542 animate_command=StepBackwardCommand;
2547 animate_command=StepForwardCommand;
2552 animate_command=FasterCommand;
2557 animate_command=SlowerCommand;
2562 animate_command=HelpCommand;
2567 animate_command=BrowseDocumentationCommand;
2572 animate_command=InfoCommand;
2578 animate_command=QuitCommand;
2584 if (animate_command != NullCommand)
2585 nexus=XMagickCommand(display,resource_info,windows,
2586 animate_command,&image,&state,exception);
2594 (void) XLookupString((XKeyEvent *) &event.xkey,command,(
int)
2595 sizeof(command),&key_symbol,(XComposeStatus *) NULL);
2596 if (resource_info->debug != MagickFalse)
2597 (void) LogMagickEvent(X11Event,GetMagickModule(),
2598 "Key release: 0x%lx (%c)",(
unsigned long) key_symbol,*command);
2606 if (map_info->colormap != XDefaultColormap(display,visual_info->screen))
2607 if (event.xcrossing.mode != NotifyUngrab)
2608 XUninstallColormap(display,map_info->colormap);
2613 if (resource_info->debug != MagickFalse)
2614 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Map Notify: 0x%lx",
2616 if (event.xmap.window == windows->backdrop.id)
2618 (void) XSetInputFocus(display,event.xmap.window,RevertToParent,
2620 windows->backdrop.mapped=MagickTrue;
2623 if (event.xmap.window == windows->image.id)
2625 if (windows->backdrop.id != (Window) NULL)
2626 (void) XInstallColormap(display,map_info->colormap);
2627 if (LocaleCompare(image_list[0]->magick,
"LOGO") == 0)
2629 if (LocaleCompare(display_image->filename,
"LOGO") == 0)
2630 nexus=XMagickCommand(display,resource_info,windows,
2631 OpenCommand,&image,&state,exception);
2635 windows->image.mapped=MagickTrue;
2638 if (event.xmap.window == windows->info.id)
2640 windows->info.mapped=MagickTrue;
2643 if (event.xmap.window == windows->icon.id)
2648 XMakeStandardColormap(display,icon_visual,icon_resources,
2649 display_image,icon_map,icon_pixel,exception);
2650 (void) XMakeImage(display,icon_resources,&windows->icon,
2651 display_image,windows->icon.width,windows->icon.height,
2653 (void) XSetWindowBackgroundPixmap(display,windows->icon.id,
2654 windows->icon.pixmap);
2655 (void) XClearWindow(display,windows->icon.id);
2656 (void) XWithdrawWindow(display,windows->info.id,
2657 windows->info.screen);
2658 windows->icon.mapped=MagickTrue;
2661 if (event.xmap.window == windows->command.id)
2663 windows->command.mapped=MagickTrue;
2666 if (event.xmap.window == windows->popup.id)
2668 windows->popup.mapped=MagickTrue;
2671 if (event.xmap.window == windows->widget.id)
2673 windows->widget.mapped=MagickTrue;
2680 (void) XRefreshKeyboardMapping(&event.xmapping);
2685 case PropertyNotify:
2701 if (resource_info->debug != MagickFalse)
2702 (void) LogMagickEvent(X11Event,GetMagickModule(),
2703 "Property Notify: 0x%lx 0x%lx %d",(
unsigned long)
2704 event.xproperty.window,(
unsigned long) event.xproperty.atom,
2705 event.xproperty.state);
2706 if (event.xproperty.atom != windows->im_remote_command)
2711 status=XGetWindowProperty(display,event.xproperty.window,
2712 event.xproperty.atom,0L,(
long) MagickPathExtent,MagickFalse,(Atom)
2713 AnyPropertyType,&type,&format,&length,&after,&data);
2714 if ((status != Success) || (length == 0))
2716 (void) CopyMagickString(resource_info->image_info->filename,
2717 (
char *) data,MagickPathExtent);
2718 nexus=ReadImage(resource_info->image_info,exception);
2719 CatchException(exception);
2720 if (nexus != (
Image *) NULL)
2722 (void) XFree((
void *) data);
2725 case ReparentNotify:
2727 if (resource_info->debug != MagickFalse)
2728 (void) LogMagickEvent(X11Event,GetMagickModule(),
2729 "Reparent Notify: 0x%lx=>0x%lx",event.xreparent.parent,
2730 event.xreparent.window);
2735 if (resource_info->debug != MagickFalse)
2736 (void) LogMagickEvent(X11Event,GetMagickModule(),
2737 "Unmap Notify: 0x%lx",event.xunmap.window);
2738 if (event.xunmap.window == windows->backdrop.id)
2740 windows->backdrop.mapped=MagickFalse;
2743 if (event.xunmap.window == windows->image.id)
2745 windows->image.mapped=MagickFalse;
2748 if (event.xunmap.window == windows->info.id)
2750 windows->info.mapped=MagickFalse;
2753 if (event.xunmap.window == windows->icon.id)
2755 if (map_info->colormap == icon_map->colormap)
2756 XConfigureImageColormap(display,resource_info,windows,
2757 display_image,exception);
2758 (void) XFreeStandardColormap(display,icon_visual,icon_map,
2760 windows->icon.mapped=MagickFalse;
2763 if (event.xunmap.window == windows->command.id)
2765 windows->command.mapped=MagickFalse;
2768 if (event.xunmap.window == windows->popup.id)
2770 if (windows->backdrop.id != (Window) NULL)
2771 (void) XSetInputFocus(display,windows->image.id,RevertToParent,
2773 windows->popup.mapped=MagickFalse;
2776 if (event.xunmap.window == windows->widget.id)
2778 if (windows->backdrop.id != (Window) NULL)
2779 (void) XSetInputFocus(display,windows->image.id,RevertToParent,
2781 windows->widget.mapped=MagickFalse;
2788 if (resource_info->debug != MagickFalse)
2789 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Event type: %d",
2795 while (!(state & ExitState));
2796 image_list=(
Image **) RelinquishMagickMemory(image_list);
2797 images=DestroyImageList(images);
2798 if ((windows->visual_info->klass == GrayScale) ||
2799 (windows->visual_info->klass == PseudoColor) ||
2800 (windows->visual_info->klass == DirectColor))
2805 if (windows->info.mapped)
2806 (void) XWithdrawWindow(display,windows->info.id,windows->info.screen);
2807 if (windows->command.mapped)
2808 (void) XWithdrawWindow(display,windows->command.id,
2809 windows->command.screen);
2811 if (resource_info->backdrop == MagickFalse)
2812 if (windows->backdrop.mapped)
2814 (void) XWithdrawWindow(display,windows->backdrop.id,\
2815 windows->backdrop.screen);
2816 (void) XDestroyWindow(display,windows->backdrop.id);
2817 windows->backdrop.id=(Window) NULL;
2818 (void) XWithdrawWindow(display,windows->image.id,windows->image.screen);
2819 (void) XDestroyWindow(display,windows->image.id);
2820 windows->image.id=(Window) NULL;
2822 XSetCursorState(display,windows,MagickTrue);
2823 XCheckRefreshWindows(display,windows);
2824 for (scene=1; scene < (ssize_t) number_scenes; scene++)
2826 if (windows->image.pixmaps[scene] != (Pixmap) NULL)
2827 (void) XFreePixmap(display,windows->image.pixmaps[scene]);
2828 windows->image.pixmaps[scene]=(Pixmap) NULL;
2829 if (windows->image.matte_pixmaps[scene] != (Pixmap) NULL)
2830 (void) XFreePixmap(display,windows->image.matte_pixmaps[scene]);
2831 windows->image.matte_pixmaps[scene]=(Pixmap) NULL;
2833 XSetCursorState(display,windows,MagickFalse);
2834 windows->image.pixmaps=(Pixmap *)
2835 RelinquishMagickMemory(windows->image.pixmaps);
2836 windows->image.matte_pixmaps=(Pixmap *)
2837 RelinquishMagickMemory(windows->image.matte_pixmaps);
2838 if (nexus == (
Image *) NULL)
2843 if (windows->image.mapped != MagickFalse)
2844 (void) XWithdrawWindow(display,windows->image.id,windows->image.screen);
2845 XDelay(display,SuspendTime);
2846 (void) XFreeStandardColormap(display,icon_visual,icon_map,icon_pixel);
2847 if (resource_info->map_type == (
char *) NULL)
2848 (void) XFreeStandardColormap(display,visual_info,map_info,pixel);
2849 DestroyXResources();
2851 (void) XSync(display,MagickFalse);
2855 (void) SetErrorHandler(warning_handler);
2856 (void) SetWarningHandler(warning_handler);
2860 directory=getcwd(working_directory,MagickPathExtent);
2862 if (*resource_info->home_directory ==
'\0')
2863 (void) CopyMagickString(resource_info->home_directory,
".",MagickPathExtent);
2864 status=chdir(resource_info->home_directory);
2866 (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
2867 "UnableToOpenFile",
"%s",resource_info->home_directory);
2906static MagickBooleanType XSaveImage(Display *display,
2907 XResourceInfo *resource_info,XWindows *windows,
Image *image,
2911 filename[MagickPathExtent];
2922 if (resource_info->write_filename != (
char *) NULL)
2923 (void) CopyMagickString(filename,resource_info->write_filename,
2928 path[MagickPathExtent];
2933 GetPathComponent(image->filename,HeadPath,path);
2934 GetPathComponent(image->filename,TailPath,filename);
2936 (void) CopyMagickString(path,
".",MagickPathExtent);
2939 (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
2940 "UnableToOpenFile",
"%s",path);
2942 XFileBrowserWidget(display,windows,
"Save",filename);
2943 if (*filename ==
'\0')
2945 if (IsPathAccessible(filename) != MagickFalse)
2953 status=XConfirmWidget(display,windows,
"Overwrite",filename);
2957 image_info=CloneImageInfo(resource_info->image_info);
2958 (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
2959 (void) SetImageInfo(image_info,1,exception);
2960 if ((LocaleCompare(image_info->magick,
"JPEG") == 0) ||
2961 (LocaleCompare(image_info->magick,
"JPG") == 0))
2964 quality[MagickPathExtent];
2972 (void) FormatLocaleString(quality,MagickPathExtent,
"%.20g",(
double)
2973 image_info->quality);
2974 status=XDialogWidget(display,windows,
"Save",
"Enter JPEG quality:",
2976 if (*quality ==
'\0')
2978 image->quality=StringToUnsignedLong(quality);
2979 image_info->interlace=status != MagickFalse ? NoInterlace :
2982 if ((LocaleCompare(image_info->magick,
"EPS") == 0) ||
2983 (LocaleCompare(image_info->magick,
"PDF") == 0) ||
2984 (LocaleCompare(image_info->magick,
"PS") == 0) ||
2985 (LocaleCompare(image_info->magick,
"PS2") == 0))
2988 geometry[MagickPathExtent];
2993 (void) CopyMagickString(geometry,PSPageGeometry,MagickPathExtent);
2994 if (LocaleCompare(image_info->magick,
"PDF") == 0)
2995 (void) CopyMagickString(geometry,PSPageGeometry,MagickPathExtent);
2996 if (image_info->page != (
char *) NULL)
2997 (void) CopyMagickString(geometry,image_info->page,MagickPathExtent);
2998 XListBrowserWidget(display,windows,&windows->widget,PageSizes,
"Select",
2999 "Select page geometry:",geometry);
3000 if (*geometry !=
'\0')
3001 image_info->page=GetPageGeometry(geometry);
3006 image=GetFirstImageInList(image);
3007 status=WriteImages(image_info,image,filename,exception);
3008 if (status != MagickFalse)
3009 image->taint=MagickFalse;
3010 image_info=DestroyImageInfo(image_info);
3011 XSetCursorState(display,windows,MagickFalse);
3012 return(status != 0 ? MagickTrue : MagickFalse);
3045MagickExport MagickBooleanType AnimateImages(
const ImageInfo *image_info,
3048 assert(image_info != (
const ImageInfo *) NULL);
3049 assert(image_info->signature == MagickCoreSignature);
3051 assert(image != (
Image *) NULL);
3052 assert(image->signature == MagickCoreSignature);
3053 if (IsEventLogging() != MagickFalse)
3054 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3055 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
3056 "DelegateLibrarySupportNotBuiltIn",
"'%s' (X11)",image->filename);
3057 return(MagickFalse);