42#include "magick/studio.h"
43#include "magick/animate.h"
44#include "magick/animate-private.h"
45#include "magick/attribute.h"
46#include "magick/client.h"
47#include "magick/color.h"
48#include "magick/color-private.h"
49#include "magick/colorspace.h"
50#include "magick/colorspace-private.h"
51#include "magick/constitute.h"
52#include "magick/delegate.h"
53#include "magick/exception.h"
54#include "magick/exception-private.h"
55#include "magick/geometry.h"
56#include "magick/image-private.h"
57#include "magick/layer.h"
58#include "magick/list.h"
59#include "magick/locale-private.h"
60#include "magick/log.h"
61#include "magick/image.h"
62#include "magick/memory_.h"
63#include "magick/monitor.h"
64#include "magick/monitor-private.h"
65#include "magick/option.h"
66#include "magick/property.h"
67#include "magick/resource_.h"
68#include "magick/string_.h"
69#include "magick/string-private.h"
70#include "magick/timer-private.h"
71#include "magick/transform.h"
72#include "magick/utility.h"
73#include "magick/version.h"
74#include "magick/widget.h"
75#include "magick/xwindow-private.h"
77#if defined(MAGICKCORE_X11_DELEGATE)
81#define AutoReverseAnimationState 0x0004
82#define ForwardAnimationState 0x0008
83#define HighlightState 0x0010
84#define PlayAnimationState 0x0020
85#define RepeatAnimationState 0x0040
86#define StepAnimationState 0x0080
96 " Press any button to map or unmap the Command widget.\n"
99 " The Command widget lists a number of sub-menus and commands.\n"
117 " Browse Documentation\n"
122 " Menu items with a indented triangle have a sub-menu. They\n"
123 " are represented above as the indented items. To access a\n"
124 " sub-menu item, move the pointer to the appropriate menu and\n"
125 " press a button and drag. When you find the desired sub-menu\n"
126 " item, release the button and the command is executed. Move\n"
127 " the pointer away from the sub-menu if you decide not to\n"
128 " execute a particular command.\n"
130 "KEYBOARD ACCELERATORS\n"
131 " Accelerators are one or two key presses that effect a\n"
132 " particular command. The keyboard accelerators that\n"
133 " animate(1) understands is:\n"
135 " Ctl+O Press to open an image from a file.\n"
137 " space Press to display the next image in the sequence.\n"
139 " < Press to speed-up the display of the images. Refer to\n"
140 " -delay for more information.\n"
142 " > Press to slow the display of the images. Refer to\n"
143 " -delay for more information.\n"
145 " F1 Press to display helpful information about animate(1).\n"
147 " Find Press to browse documentation about ImageMagick.\n"
149 " ? Press to display information about the image. Press\n"
150 " any key or button to erase the information.\n"
152 " This information is printed: image name; image size;\n"
153 " and the total number of unique colors in the image.\n"
155 " Ctl-q Press to discard all images and exit program.\n"
181static const unsigned char
184 (
unsigned char) 0xaa,
185 (
unsigned char) 0x55,
186 (
unsigned char) 0xaa,
187 (
unsigned char) 0x55,
188 (
unsigned char) 0xaa,
189 (
unsigned char) 0x55,
190 (
unsigned char) 0xaa,
195 (
unsigned char) 0x00,
196 (
unsigned char) 0x00,
197 (
unsigned char) 0x00,
198 (
unsigned char) 0x00,
199 (
unsigned char) 0x00,
200 (
unsigned char) 0x00,
201 (
unsigned char) 0x00,
221 BrowseDocumentationCommand,
233#define HighlightWidth 8
234#define HighlightHeight 8
236#define ShadowHeight 8
242 *XMagickCommand(Display *,XResourceInfo *,XWindows *,
const AnimateCommand,
243 Image **,MagickStatusType *);
245static MagickBooleanType
246 XSaveImage(Display *,XResourceInfo *,XWindows *,
Image *);
275MagickExport MagickBooleanType AnimateImages(
const ImageInfo *image_info,
293 assert(image_info != (
const ImageInfo *) NULL);
294 assert(image_info->signature == MagickCoreSignature);
295 assert(images != (
Image *) NULL);
296 assert(images->signature == MagickCoreSignature);
297 if (IsEventLogging() != MagickFalse)
298 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
299 display=XOpenDisplay(image_info->server_name);
300 if (display == (Display *) NULL)
302 (void) ThrowMagickException(&images->exception,GetMagickModule(),
303 XServerError,
"UnableToOpenXServer",
"`%s'",XDisplayName(
304 image_info->server_name));
307 if (images->exception.severity != UndefinedException)
308 CatchException(&images->exception);
309 (void) XSetErrorHandler(XError);
310 resource_database=XGetResourceDatabase(display,GetClientName());
311 (void) memset(&resource_info,0,
sizeof(XResourceInfo));
312 XGetResourceInfo(image_info,resource_database,GetClientName(),&resource_info);
313 if (image_info->page != (
char *) NULL)
314 resource_info.image_geometry=AcquireString(image_info->page);
315 resource_info.immutable=MagickTrue;
316 argv[0]=AcquireString(GetClientName());
317 (void) XAnimateImages(display,&resource_info,argv,1,images);
318 (void) SetErrorHandler((ErrorHandler) NULL);
319 (void) SetWarningHandler((WarningHandler) NULL);
320 argv[0]=DestroyString(argv[0]);
321 (void) XCloseDisplay(display);
322 XDestroyResourceInfo(&resource_info);
323 status=images->exception.severity == UndefinedException ?
324 MagickTrue : MagickFalse;
325 return(status != 0 ? MagickTrue : MagickFalse);
365static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
366 XWindows *windows,
const AnimateCommand animate_command,
Image **image,
367 MagickStatusType *state)
384 nexus=NewImageList();
385 switch (animate_command)
409 filenames[MaxTextExtent] =
"*";
411 if (resource_info->immutable != MagickFalse)
416 XFileBrowserWidget(display,windows,
"Animate",filenames);
417 if (*filenames ==
'\0')
418 return((
Image *) NULL);
422 filelist=(
char **) AcquireMagickMemory(
sizeof(
char *));
423 if (filelist == (
char **) NULL)
425 ThrowXWindowException(ResourceLimitError,
"MemoryAllocationFailed",
427 return((
Image *) NULL);
430 filelist[0]=filenames;
431 status=ExpandFilenames(&number_files,&filelist);
432 if ((status == MagickFalse) || (number_files == 0))
434 for (i=0; i < number_files; i++)
435 filelist[i]=DestroyString(filelist[i]);
436 filelist=(
char **) RelinquishMagickMemory(filelist);
437 if (number_files == 0)
439 ThrowXWindowException(ImageError,
"NoImagesWereLoaded",filenames);
440 return((
Image *) NULL);
442 ThrowXWindowException(ResourceLimitError,
"MemoryAllocationFailed",
444 return((
Image *) NULL);
446 read_info=CloneImageInfo(resource_info->image_info);
447 exception=AcquireExceptionInfo();
448 images=NewImageList();
449 XSetCursorState(display,windows,MagickTrue);
450 XCheckRefreshWindows(display,windows);
451 for (i=0; i < number_files; i++)
453 (void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
454 filelist[i]=DestroyString(filelist[i]);
455 *read_info->magick=
'\0';
456 next=ReadImage(read_info,exception);
457 CatchException(exception);
458 if (next != (
Image *) NULL)
459 AppendImageToList(&images,next);
460 if (number_files <= 5)
462 proceed=SetImageProgress(images,LoadImageTag,i,(MagickSizeType)
464 if (proceed == MagickFalse)
467 filelist=(
char **) RelinquishMagickMemory(filelist);
468 exception=DestroyExceptionInfo(exception);
469 read_info=DestroyImageInfo(read_info);
470 if (images == (
Image *) NULL)
472 XSetCursorState(display,windows,MagickFalse);
473 ThrowXWindowException(ImageError,
"NoImagesWereLoaded",filenames);
474 return((
Image *) NULL);
476 nexus=GetFirstImageInList(images);
483 basename[MaxTextExtent],
492 *state|=PlayAnimationState;
493 *state&=(~AutoReverseAnimationState);
494 GetPathComponent((*image)->magick_filename,BasePath,basename);
495 (void) FormatLocaleString(name,MaxTextExtent,
"%s: %s", MagickPackageName,
497 (void) CloneString(&windows->image.name,name);
498 if (resource_info->title != (
char *) NULL)
503 title=InterpretImageProperties(resource_info->image_info,*image,
504 resource_info->title);
505 (void) CloneString(&windows->image.name,title);
506 title=DestroyString(title);
508 status=XStringListToTextProperty(&windows->image.name,1,&window_name);
511 XSetWMName(display,windows->image.id,&window_name);
512 (void) XFree((
void *) window_name.value);
516 case StepBackwardCommand:
517 case StepForwardCommand:
519 *state|=StepAnimationState;
520 *state&=(~PlayAnimationState);
521 if (animate_command == StepBackwardCommand)
522 *state&=(~ForwardAnimationState);
523 if (animate_command == StepForwardCommand)
524 *state|=ForwardAnimationState;
525 if (resource_info->title != (
char *) NULL)
531 *state|=RepeatAnimationState;
532 *state&=(~AutoReverseAnimationState);
533 *state|=PlayAnimationState;
536 case AutoReverseCommand:
538 *state|=AutoReverseAnimationState;
539 *state&=(~RepeatAnimationState);
540 *state|=PlayAnimationState;
548 status=XSaveImage(display,resource_info,windows,*image);
549 if (status == MagickFalse)
552 message[MaxTextExtent];
554 (void) FormatLocaleString(message,MaxTextExtent,
"%s:%s",
555 (*image)->exception.reason != (
char *) NULL ?
556 (*image)->exception.reason :
"",
557 (*image)->exception.description != (
char *) NULL ?
558 (*image)->exception.description :
"");
559 XNoticeWidget(display,windows,
"Unable to save file:",message);
566 resource_info->delay++;
571 if (resource_info->delay == 0)
573 resource_info->delay--;
578 *state=ForwardAnimationState;
579 *state&=(~AutoReverseAnimationState);
584 *state&=(~ForwardAnimationState);
585 *state&=(~AutoReverseAnimationState);
590 XDisplayImageInfo(display,resource_info,windows,(
Image *) NULL,*image);
598 XTextViewHelp(display,resource_info,windows,MagickFalse,
599 "Help Viewer - Animate",AnimateHelp);
602 case BrowseDocumentationCommand:
614 root_window=XRootWindow(display,XDefaultScreen(display));
615 mozilla_atom=XInternAtom(display,
"_MOZILLA_VERSION",MagickFalse);
616 mozilla_window=XWindowByProperty(display,root_window,mozilla_atom);
617 if (mozilla_window != (Window) NULL)
620 command[MaxTextExtent];
625 (void) FormatLocaleString(command,MaxTextExtent,
626 "openurl(%s,new-tab)",MagickAuthoritativeURL);
627 mozilla_atom=XInternAtom(display,
"_MOZILLA_COMMAND",MagickFalse);
628 (void) XChangeProperty(display,mozilla_window,mozilla_atom,
629 XA_STRING,8,PropModeReplace,(
unsigned char *) command,
630 (
int) strlen(command));
631 XSetCursorState(display,windows,MagickFalse);
634 XSetCursorState(display,windows,MagickTrue);
635 XCheckRefreshWindows(display,windows);
636 status=InvokeDelegate(resource_info->image_info,*image,
"browse",
637 (
char *) NULL,&(*image)->exception);
638 if (status == MagickFalse)
639 XNoticeWidget(display,windows,
"Unable to browse documentation",
641 XDelay(display,1500);
642 XSetCursorState(display,windows,MagickFalse);
647 XNoticeWidget(display,windows,GetMagickVersion((
size_t *) NULL),
648 GetMagickCopyright());
656 if (resource_info->confirm_exit == MagickFalse)
657 XClientMessage(display,windows->image.id,windows->im_protocols,
658 windows->im_exit,CurrentTime);
667 status=XConfirmWidget(display,windows,
"Do you really want to exit",
668 resource_info->client_name);
670 XClientMessage(display,windows->image.id,windows->im_protocols,
671 windows->im_exit,CurrentTime);
711#if defined(__cplusplus) || defined(c_plusplus)
715static int SceneCompare(
const void *x,
const void *y)
721 image_1=(
const Image **) x;
722 image_2=(
const Image **) y;
723 return((
int) ((*image_1)->scene-(*image_2)->scene));
726#if defined(__cplusplus) || defined(c_plusplus)
730MagickExport
void XAnimateBackgroundImage(Display *display,
731 XResourceInfo *resource_info,
Image *images)
734 geometry[MaxTextExtent],
735 visual_type[MaxTextExtent];
764 static XStandardColormap
768 *visual_info = (XVisualInfo *) NULL;
795 assert(images != (
Image *) NULL);
796 assert(images->signature == MagickCoreSignature);
797 if (IsEventLogging() != MagickFalse)
798 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
799 resources=(*resource_info);
800 window_info.id=(Window) NULL;
801 root_window=XRootWindow(display,XDefaultScreen(display));
802 if (LocaleCompare(resources.window_id,
"root") == 0)
803 window_info.id=root_window;
806 if (isdigit((
int) ((
unsigned char) *resources.window_id)) != 0)
807 window_info.id=XWindowByID(display,root_window,
808 (Window) strtol((
char *) resources.window_id,(
char **) NULL,0));
809 if (window_info.id == (Window) NULL)
811 XWindowByName(display,root_window,resources.window_id);
813 if (window_info.id == (Window) NULL)
815 ThrowXWindowException(XServerError,
"NoWindowWithSpecifiedIDExists",
816 resources.window_id);
822 window_attributes.width=XDisplayWidth(display,XDefaultScreen(display));
823 window_attributes.height=XDisplayHeight(display,XDefaultScreen(display));
824 (void) CopyMagickString(visual_type,
"default",MaxTextExtent);
825 status=XGetWindowAttributes(display,window_info.id,&window_attributes) != 0 ?
826 MagickTrue : MagickFalse;
827 if (status != MagickFalse)
828 (void) FormatLocaleString(visual_type,MaxTextExtent,
"0x%lx",
829 XVisualIDFromVisual(window_attributes.visual));
830 if (visual_info == (XVisualInfo *) NULL)
835 map_info=XAllocStandardColormap();
836 if (map_info == (XStandardColormap *) NULL)
837 ThrowXWindowFatalException(ResourceLimitFatalError,
838 "MemoryAllocationFailed",images->filename);
839 map_info->colormap=(Colormap) NULL;
840 pixel.pixels=(
unsigned long *) NULL;
844 resources.map_type=(
char *) NULL;
845 resources.visual_type=visual_type;
846 visual_info=XBestVisualInfo(display,map_info,&resources);
847 if (visual_info == (XVisualInfo *) NULL)
848 ThrowXWindowFatalException(XServerFatalError,
"UnableToGetVisual",
853 window_info.ximage=(XImage *) NULL;
854 window_info.matte_image=(XImage *) NULL;
855 window_info.pixmap=(Pixmap) NULL;
856 window_info.matte_pixmap=(Pixmap) NULL;
861 if (window_info.id == root_window)
862 XDestroyWindowColors(display,root_window);
863 coalesce_image=CoalesceImages(images,&images->exception);
864 if (coalesce_image == (
Image *) NULL)
865 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
867 images=coalesce_image;
868 if (resources.map_type == (
char *) NULL)
869 if ((visual_info->klass != TrueColor) &&
870 (visual_info->klass != DirectColor))
878 for (next=images; next != (
Image *) NULL; )
880 next->matte=MagickFalse;
881 if ((next->storage_class == DirectClass) ||
882 (next->colors != images->colors) ||
883 (next->colors > (
size_t) visual_info->colormap_size))
885 for (i=0; i < (ssize_t) images->colors; i++)
886 if (IsColorEqual(next->colormap+i,images->colormap+i) == MagickFalse)
888 if (i < (ssize_t) images->colors)
890 next=GetNextImageInList(next);
892 if (next != (
Image *) NULL)
893 (void) RemapImages(resources.quantize_info,images,(
Image *) NULL);
898 number_scenes=GetImageListLength(images);
899 image_list=ImageListToArray(images,&images->exception);
900 if (image_list == (
Image **) NULL)
901 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
903 for (i=0; i < (ssize_t) number_scenes; i++)
904 if (image_list[i]->scene == 0)
906 if (i == (ssize_t) number_scenes)
907 qsort((
void *) image_list,number_scenes,
sizeof(
Image *),SceneCompare);
911 resources.colormap=SharedColormap;
912 display_image=image_list[0];
913 for (scene=0; scene < (int) number_scenes; scene++)
915 if ((resource_info->map_type != (
char *) NULL) ||
916 (visual_info->klass == TrueColor) ||
917 (visual_info->klass == DirectColor))
918 (void) SetImageType(image_list[scene],image_list[scene]->matte ==
919 MagickFalse ? TrueColorType : TrueColorMatteType);
920 if ((display_image->columns < image_list[scene]->columns) &&
921 (display_image->rows < image_list[scene]->rows))
922 display_image=image_list[scene];
924 if ((resource_info->map_type != (
char *) NULL) ||
925 (visual_info->klass == TrueColor) || (visual_info->klass == DirectColor))
926 (void) SetImageType(display_image,display_image->matte == MagickFalse ?
927 TrueColorType : TrueColorMatteType);
928 XMakeStandardColormap(display,visual_info,&resources,display_image,map_info,
933 context_values.background=pixel.background_color.pixel;
934 context_values.foreground=pixel.foreground_color.pixel;
935 pixel.annotate_context=XCreateGC(display,window_info.id,(
unsigned long)
936 (GCBackground | GCForeground),&context_values);
937 if (pixel.annotate_context == (GC) NULL)
938 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
943 XGetWindowInfo(display,visual_info,map_info,&pixel,(XFontStruct *) NULL,
944 &resources,&window_info);
948 window_info.width=(
unsigned int) image_list[0]->columns;
949 window_info.height=(
unsigned int) image_list[0]->rows;
950 if ((image_list[0]->columns != window_info.width) ||
951 (image_list[0]->rows != window_info.height))
952 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
953 image_list[0]->filename);
954 (void) FormatLocaleString(geometry,MaxTextExtent,
"%ux%u+0+0>",
955 window_attributes.width,window_attributes.height);
956 geometry_info.width=window_info.width;
957 geometry_info.height=window_info.height;
958 geometry_info.x=(ssize_t) window_info.x;
959 geometry_info.y=(ssize_t) window_info.y;
960 (void) ParseMetaGeometry(geometry,&geometry_info.x,&geometry_info.y,
961 &geometry_info.width,&geometry_info.height);
962 window_info.width=(
unsigned int) geometry_info.width;
963 window_info.height=(
unsigned int) geometry_info.height;
964 window_info.x=(int) geometry_info.x;
965 window_info.y=(int) geometry_info.y;
966 status=XMakeImage(display,&resources,&window_info,image_list[0],
967 window_info.width,window_info.height);
968 if (status == MagickFalse)
969 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
973 if (resource_info->debug != MagickFalse)
975 (void) LogMagickEvent(X11Event,GetMagickModule(),
976 "Image: %s[%.20g] %.20gx%.20g ",image_list[0]->filename,(
double)
977 image_list[0]->scene,(
double) image_list[0]->columns,(
double)
978 image_list[0]->rows);
979 if (image_list[0]->colors != 0)
980 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
981 image_list[0]->colors);
982 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
983 image_list[0]->magick);
988 width=window_info.width;
989 height=window_info.height;
990 if (resources.backdrop != MagickFalse)
995 window_info.x=(int) (window_attributes.width/2)-
996 (window_info.ximage->width/2);
997 window_info.y=(int) (window_attributes.height/2)-
998 (window_info.ximage->height/2);
999 width=(
unsigned int) window_attributes.width;
1000 height=(
unsigned int) window_attributes.height;
1002 if (resources.image_geometry != (
char *) NULL)
1005 default_geometry[MaxTextExtent];
1017 size_hints=XAllocSizeHints();
1018 if (size_hints == (XSizeHints *) NULL)
1019 ThrowXWindowFatalException(ResourceLimitFatalError,
1020 "MemoryAllocationFailed",images->filename);
1021 size_hints->flags=0L;
1022 (void) FormatLocaleString(default_geometry,MaxTextExtent,
"%ux%u",width,
1024 flags=XWMGeometry(display,visual_info->screen,resources.image_geometry,
1025 default_geometry,window_info.border_width,size_hints,&window_info.x,
1026 &window_info.y,(
int *) &width,(
int *) &height,&gravity);
1027 if (((flags & (XValue | YValue))) != 0)
1029 width=(
unsigned int) window_attributes.width;
1030 height=(
unsigned int) window_attributes.height;
1032 (void) XFree((
void *) size_hints);
1037 window_info.pixmap=XCreatePixmap(display,window_info.id,(
unsigned int) width,
1038 (
unsigned int) height,window_info.depth);
1039 if (window_info.pixmap == (Pixmap) NULL)
1040 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXPixmap",
1045 if (((
unsigned int) width > window_info.width) ||
1046 ((
unsigned int) height > window_info.height))
1047 (void) XFillRectangle(display,window_info.pixmap,
1048 window_info.annotate_context,0,0,(
unsigned int) width,
1049 (
unsigned int) height);
1050 (void) XPutImage(display,window_info.pixmap,window_info.annotate_context,
1051 window_info.ximage,0,0,window_info.x,window_info.y,window_info.width,
1052 window_info.height);
1053 (void) XSetWindowBackgroundPixmap(display,window_info.id,window_info.pixmap);
1054 (void) XClearWindow(display,window_info.id);
1058 window_info.pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1059 sizeof(*window_info.pixmaps));
1060 window_info.matte_pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1061 sizeof(*window_info.matte_pixmaps));
1062 if ((window_info.pixmaps == (Pixmap *) NULL) ||
1063 (window_info.matte_pixmaps == (Pixmap *) NULL))
1064 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1066 window_info.pixmaps[0]=window_info.pixmap;
1067 window_info.matte_pixmaps[0]=window_info.pixmap;
1068 for (scene=1; scene < (int) number_scenes; scene++)
1077 window_info.pixmap=(Pixmap) NULL;
1078 window_info.matte_pixmap=(Pixmap) NULL;
1079 if ((resources.map_type != (
char *) NULL) ||
1080 (visual_info->klass == TrueColor) ||
1081 (visual_info->klass == DirectColor))
1082 if (image_list[scene]->storage_class == PseudoClass)
1083 XGetPixelPacket(display,visual_info,map_info,&resources,
1084 image_list[scene],window_info.pixel_info);
1085 columns=(
unsigned int) image_list[scene]->columns;
1086 rows=(
unsigned int) image_list[scene]->rows;
1087 if ((image_list[scene]->columns != columns) ||
1088 (image_list[scene]->rows != rows))
1089 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1090 image_list[scene]->filename);
1091 status=XMakeImage(display,&resources,&window_info,image_list[scene],
1093 if (status == MagickFalse)
1094 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1096 if (resource_info->debug != MagickFalse)
1098 (void) LogMagickEvent(X11Event,GetMagickModule(),
1099 "Image: [%.20g] %s %.20gx%.20g ",(
double) image_list[scene]->scene,
1100 image_list[scene]->filename,(
double) columns,(
double) rows);
1101 if (image_list[scene]->colors != 0)
1102 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
1103 image_list[scene]->colors);
1104 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
1105 image_list[scene]->magick);
1110 window_info.pixmap=XCreatePixmap(display,window_info.id,width,height,
1112 if (window_info.pixmap == (Pixmap) NULL)
1113 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXPixmap",
1118 if ((width > window_info.width) || (height > window_info.height))
1119 (void) XFillRectangle(display,window_info.pixmap,
1120 window_info.annotate_context,0,0,width,height);
1121 (void) XPutImage(display,window_info.pixmap,window_info.annotate_context,
1122 window_info.ximage,0,0,window_info.x,window_info.y,window_info.width,
1123 window_info.height);
1124 (void) XSetWindowBackgroundPixmap(display,window_info.id,
1125 window_info.pixmap);
1126 (void) XClearWindow(display,window_info.id);
1127 window_info.pixmaps[scene]=window_info.pixmap;
1128 window_info.matte_pixmaps[scene]=window_info.matte_pixmap;
1129 if (image_list[scene]->matte)
1130 (void) XClearWindow(display,window_info.id);
1131 delay=1000*image_list[scene]->delay/MagickMax(
1132 image_list[scene]->ticks_per_second,1L);
1133 XDelay(display,resources.delay*(delay == 0 ? 10 : delay));
1135 window_info.pixel_info=(&pixel);
1139 (void) XSelectInput(display,window_info.id,SubstructureNotifyMask);
1144 for (scene=0; scene < (int) number_scenes; scene++)
1146 if (XEventsQueued(display,QueuedAfterFlush) > 0)
1148 (void) XNextEvent(display,&event);
1149 if (event.type == DestroyNotify)
1152 window_info.pixmap=window_info.pixmaps[scene];
1153 window_info.matte_pixmap=window_info.matte_pixmaps[scene];
1154 (void) XSetWindowBackgroundPixmap(display,window_info.id,
1155 window_info.pixmap);
1156 (void) XClearWindow(display,window_info.id);
1157 (void) XSync(display,MagickFalse);
1158 delay=1000*image_list[scene]->delay/MagickMax(
1159 image_list[scene]->ticks_per_second,1L);
1160 XDelay(display,resources.delay*(delay == 0 ? 10 : delay));
1163 if (iterations == (ssize_t) image_list[0]->iterations)
1165 }
while (event.type != DestroyNotify);
1166 (void) XSync(display,MagickFalse);
1167 image_list=(
Image **) RelinquishMagickMemory(image_list);
1168 images=DestroyImageList(images);
1203MagickExport
Image *XAnimateImages(Display *display,
1204 XResourceInfo *resource_info,
char **argv,
const int argc,
Image *images)
1206#define MagickMenus 4
1208#define MagickTitle "Commands"
1211 *
const CommandMenu[]=
1221 *
const AnimateMenu[]=
1237 *
const DirectionMenu[]=
1246 "Browse Documentation",
1252 *
const *Menus[MagickMenus]=
1260 static const AnimateCommand
1284 DirectionCommands[]=
1292 BrowseDocumentationCommand,
1296 static const AnimateCommand
1297 *Commands[MagickMenus]=
1309 command[MaxTextExtent],
1311 geometry[MaxTextExtent],
1312 resource_name[MaxTextExtent];
1346 working_directory[MaxTextExtent];
1352 *magick_windows[MaXWindows];
1406 assert(images != (
Image *) NULL);
1407 assert(images->signature == MagickCoreSignature);
1408 if (IsEventLogging() != MagickFalse)
1409 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",images->filename);
1410 warning_handler=(WarningHandler) NULL;
1411 windows=XSetWindows((XWindows *) ~0);
1412 if (windows != (XWindows *) NULL)
1417 if (*working_directory ==
'\0')
1418 (void) CopyMagickString(working_directory,
".",MaxTextExtent);
1419 status=chdir(working_directory);
1421 (void) ThrowMagickException(&images->exception,GetMagickModule(),
1422 FileOpenError,
"UnableToOpenFile",
"%s",working_directory);
1423 warning_handler=resource_info->display_warnings ?
1424 SetErrorHandler(XWarning) : SetErrorHandler((ErrorHandler) NULL);
1425 warning_handler=resource_info->display_warnings ?
1426 SetWarningHandler(XWarning) : SetWarningHandler((WarningHandler) NULL);
1436 for (p=images; p != (
Image *) NULL; p=GetNextImageInList(p))
1438 if (p->storage_class == DirectClass)
1440 resource_info->colors=0;
1443 if (p->colors > resource_info->colors)
1444 resource_info->colors=p->colors;
1446 windows=XSetWindows(XInitializeWindows(display,resource_info));
1447 if (windows == (XWindows *) NULL)
1448 ThrowXWindowFatalException(XServerFatalError,
"MemoryAllocationFailed",
1454 magick_windows[number_windows++]=(&windows->icon);
1455 magick_windows[number_windows++]=(&windows->backdrop);
1456 magick_windows[number_windows++]=(&windows->image);
1457 magick_windows[number_windows++]=(&windows->info);
1458 magick_windows[number_windows++]=(&windows->command);
1459 magick_windows[number_windows++]=(&windows->widget);
1460 magick_windows[number_windows++]=(&windows->popup);
1461 for (i=0; i < (ssize_t) number_windows; i++)
1462 magick_windows[i]->
id=(Window) NULL;
1467 if (windows->font_info != (XFontStruct *) NULL)
1468 (void) XFreeFont(display,windows->font_info);
1469 windows->font_info=XBestFont(display,resource_info,MagickFalse);
1470 if (windows->font_info == (XFontStruct *) NULL)
1471 ThrowXWindowFatalException(XServerFatalError,
"UnableToLoadFont",
1472 resource_info->font);
1476 map_info=windows->map_info;
1477 icon_map=windows->icon_map;
1478 visual_info=windows->visual_info;
1479 icon_visual=windows->icon_visual;
1480 pixel=windows->pixel_info;
1481 icon_pixel=windows->icon_pixel;
1482 font_info=windows->font_info;
1483 icon_resources=windows->icon_resources;
1484 class_hints=windows->class_hints;
1485 manager_hints=windows->manager_hints;
1486 root_window=XRootWindow(display,visual_info->screen);
1487 coalesce_image=CoalesceImages(images,&images->exception);
1488 if (coalesce_image == (
Image *) NULL)
1489 ThrowXWindowFatalException(XServerFatalError,
"MemoryAllocationFailed",
1491 images=coalesce_image;
1492 if (resource_info->map_type == (
char *) NULL)
1493 if ((visual_info->klass != TrueColor) &&
1494 (visual_info->klass != DirectColor))
1502 for (next=images; next != (
Image *) NULL; )
1504 next->matte=MagickFalse;
1505 if ((next->storage_class == DirectClass) ||
1506 (next->colors != images->colors) ||
1507 (next->colors > (
size_t) visual_info->colormap_size))
1509 for (i=0; i < (ssize_t) images->colors; i++)
1510 if (IsColorEqual(next->colormap+i,images->colormap+i) == MagickFalse)
1512 if (i < (ssize_t) images->colors)
1514 next=GetNextImageInList(next);
1516 if (next != (
Image *) NULL)
1517 (void) RemapImages(resource_info->quantize_info,images,
1523 number_scenes=GetImageListLength(images);
1524 image_list=ImageListToArray(images,&images->exception);
1525 if (image_list == (
Image **) NULL)
1526 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1528 for (scene=0; scene < (ssize_t) number_scenes; scene++)
1529 if (image_list[scene]->scene == 0)
1531 if (scene == (ssize_t) number_scenes)
1532 qsort((
void *) image_list,number_scenes,
sizeof(
Image *),SceneCompare);
1536 nexus=NewImageList();
1537 display_image=image_list[0];
1538 for (scene=0; scene < (ssize_t) number_scenes; scene++)
1540 if ((resource_info->map_type != (
char *) NULL) ||
1541 (visual_info->klass == TrueColor) ||
1542 (visual_info->klass == DirectColor))
1543 (void) SetImageType(image_list[scene],image_list[scene]->matte ==
1544 MagickFalse ? TrueColorType : TrueColorMatteType);
1545 if ((display_image->columns < image_list[scene]->columns) &&
1546 (display_image->rows < image_list[scene]->rows))
1547 display_image=image_list[scene];
1549 if (resource_info->debug != MagickFalse)
1551 (void) LogMagickEvent(X11Event,GetMagickModule(),
1552 "Image: %s[%.20g] %.20gx%.20g ",display_image->filename,(
double)
1553 display_image->scene,(
double) display_image->columns,(
double)
1554 display_image->rows);
1555 if (display_image->colors != 0)
1556 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
1557 display_image->colors);
1558 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
1559 display_image->magick);
1561 XMakeStandardColormap(display,visual_info,resource_info,display_image,
1566 windows->context.id=(Window) NULL;
1567 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1568 resource_info,&windows->context);
1569 (void) CloneString(&class_hints->res_name,resource_info->client_name);
1570 (void) CloneString(&class_hints->res_class,resource_info->client_name);
1571 class_hints->res_class[0]=(char) LocaleToUppercase((
int)
1572 class_hints->res_class[0]);
1573 manager_hints->flags=InputHint | StateHint;
1574 manager_hints->input=MagickFalse;
1575 manager_hints->initial_state=WithdrawnState;
1576 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1578 if (resource_info->debug != MagickFalse)
1579 (void) LogMagickEvent(X11Event,GetMagickModule(),
1580 "Window id: 0x%lx (context)",windows->context.id);
1581 context_values.background=pixel->background_color.pixel;
1582 context_values.font=font_info->fid;
1583 context_values.foreground=pixel->foreground_color.pixel;
1584 context_values.graphics_exposures=MagickFalse;
1585 context_mask=(MagickStatusType)
1586 (GCBackground | GCFont | GCForeground | GCGraphicsExposures);
1587 if (pixel->annotate_context != (GC) NULL)
1588 (void) XFreeGC(display,pixel->annotate_context);
1589 pixel->annotate_context=
1590 XCreateGC(display,windows->context.id,context_mask,&context_values);
1591 if (pixel->annotate_context == (GC) NULL)
1592 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1594 context_values.background=pixel->depth_color.pixel;
1595 if (pixel->widget_context != (GC) NULL)
1596 (void) XFreeGC(display,pixel->widget_context);
1597 pixel->widget_context=
1598 XCreateGC(display,windows->context.id,context_mask,&context_values);
1599 if (pixel->widget_context == (GC) NULL)
1600 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1602 context_values.background=pixel->foreground_color.pixel;
1603 context_values.foreground=pixel->background_color.pixel;
1604 context_values.plane_mask=
1605 context_values.background ^ context_values.foreground;
1606 if (pixel->highlight_context != (GC) NULL)
1607 (void) XFreeGC(display,pixel->highlight_context);
1608 pixel->highlight_context=XCreateGC(display,windows->context.id,
1609 (
size_t) (context_mask | GCPlaneMask),&context_values);
1610 if (pixel->highlight_context == (GC) NULL)
1611 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1613 (void) XDestroyWindow(display,windows->context.id);
1617 XGetWindowInfo(display,icon_visual,icon_map,icon_pixel,(XFontStruct *) NULL,
1618 icon_resources,&windows->icon);
1619 windows->icon.geometry=resource_info->icon_geometry;
1620 XBestIconSize(display,&windows->icon,display_image);
1621 windows->icon.attributes.colormap=
1622 XDefaultColormap(display,icon_visual->screen);
1623 windows->icon.attributes.event_mask=ExposureMask | StructureNotifyMask;
1624 manager_hints->flags=InputHint | StateHint;
1625 manager_hints->input=MagickFalse;
1626 manager_hints->initial_state=IconicState;
1627 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1629 if (resource_info->debug != MagickFalse)
1630 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Window id: 0x%lx (icon)",
1635 if (icon_pixel->annotate_context != (GC) NULL)
1636 (void) XFreeGC(display,icon_pixel->annotate_context);
1637 context_values.background=icon_pixel->background_color.pixel;
1638 context_values.foreground=icon_pixel->foreground_color.pixel;
1639 icon_pixel->annotate_context=XCreateGC(display,windows->icon.id,
1640 (
size_t) (GCBackground | GCForeground),&context_values);
1641 if (icon_pixel->annotate_context == (GC) NULL)
1642 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateGraphicContext",
1644 windows->icon.annotate_context=icon_pixel->annotate_context;
1648 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1649 resource_info,&windows->image);
1650 windows->image.shape=MagickTrue;
1651 if (resource_info->use_shared_memory == MagickFalse)
1652 windows->image.shared_memory=MagickFalse;
1653 if (resource_info->title != (
char *) NULL)
1658 title=InterpretImageProperties(resource_info->image_info,display_image,
1659 resource_info->title);
1660 (void) CloneString(&windows->image.name,title);
1661 (void) CloneString(&windows->image.icon_name,title);
1662 title=DestroyString(title);
1667 filename[MaxTextExtent],
1668 window_name[MaxTextExtent];
1673 GetPathComponent(display_image->magick_filename,TailPath,filename);
1674 (void) FormatLocaleString(window_name,MaxTextExtent,
1675 "%s: %s[scene: %.20g frames: %.20g]",MagickPackageName,filename,(
double)
1676 display_image->scene,(
double) number_scenes);
1677 (void) CloneString(&windows->image.name,window_name);
1678 (void) CloneString(&windows->image.icon_name,filename);
1680 if (resource_info->immutable != MagickFalse)
1681 windows->image.immutable=MagickTrue;
1682 windows->image.shape=MagickTrue;
1683 windows->image.geometry=resource_info->image_geometry;
1684 (void) FormatLocaleString(geometry,MaxTextExtent,
"%ux%u+0+0>!",
1685 XDisplayWidth(display,visual_info->screen),
1686 XDisplayHeight(display,visual_info->screen));
1687 geometry_info.width=display_image->columns;
1688 geometry_info.height=display_image->rows;
1691 (void) ParseMetaGeometry(geometry,&geometry_info.x,&geometry_info.y,
1692 &geometry_info.width,&geometry_info.height);
1693 windows->image.width=(
unsigned int) geometry_info.width;
1694 windows->image.height=(
unsigned int) geometry_info.height;
1695 windows->image.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1696 ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask |
1697 KeyReleaseMask | LeaveWindowMask | OwnerGrabButtonMask |
1698 PropertyChangeMask | StructureNotifyMask | SubstructureNotifyMask;
1699 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1700 resource_info,&windows->backdrop);
1701 if ((resource_info->backdrop) || (windows->backdrop.id != (Window) NULL))
1706 windows->backdrop.x=0;
1707 windows->backdrop.y=0;
1708 (void) CloneString(&windows->backdrop.name,
"ImageMagick Backdrop");
1709 windows->backdrop.flags=(size_t) (USSize | USPosition);
1710 windows->backdrop.width=(
unsigned int)
1711 XDisplayWidth(display,visual_info->screen);
1712 windows->backdrop.height=(
unsigned int)
1713 XDisplayHeight(display,visual_info->screen);
1714 windows->backdrop.border_width=0;
1715 windows->backdrop.immutable=MagickTrue;
1716 windows->backdrop.attributes.do_not_propagate_mask=ButtonPressMask |
1718 windows->backdrop.attributes.event_mask=ButtonPressMask | KeyPressMask |
1719 StructureNotifyMask;
1720 manager_hints->flags=IconWindowHint | InputHint | StateHint;
1721 manager_hints->icon_window=windows->icon.id;
1722 manager_hints->input=MagickTrue;
1723 manager_hints->initial_state=
1724 resource_info->iconic ? IconicState : NormalState;
1725 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1726 &windows->backdrop);
1727 if (resource_info->debug != MagickFalse)
1728 (void) LogMagickEvent(X11Event,GetMagickModule(),
1729 "Window id: 0x%lx (backdrop)",windows->backdrop.id);
1730 (void) XMapWindow(display,windows->backdrop.id);
1731 (void) XClearWindow(display,windows->backdrop.id);
1732 if (windows->image.id != (Window) NULL)
1734 (void) XDestroyWindow(display,windows->image.id);
1735 windows->image.id=(Window) NULL;
1740 windows->image.flags|=USPosition;
1741 windows->image.x=(XDisplayWidth(display,visual_info->screen)/2)-
1742 (windows->image.width/2);
1743 windows->image.y=(XDisplayHeight(display,visual_info->screen)/2)-
1744 (windows->image.height/2);
1746 manager_hints->flags=IconWindowHint | InputHint | StateHint;
1747 manager_hints->icon_window=windows->icon.id;
1748 manager_hints->input=MagickTrue;
1749 manager_hints->initial_state=
1750 resource_info->iconic ? IconicState : NormalState;
1751 if (windows->group_leader.id != (Window) NULL)
1756 manager_hints->flags|=(MagickStatusType) WindowGroupHint;
1757 manager_hints->window_group=windows->group_leader.id;
1758 (void) XSelectInput(display,windows->group_leader.id,StructureNotifyMask);
1759 if (resource_info->debug != MagickFalse)
1760 (void) LogMagickEvent(X11Event,GetMagickModule(),
1761 "Window id: 0x%lx (group leader)",windows->group_leader.id);
1763 XMakeWindow(display,
1764 (Window) (resource_info->backdrop ? windows->backdrop.id : root_window),
1765 argv,argc,class_hints,manager_hints,&windows->image);
1766 (void) XChangeProperty(display,windows->image.id,windows->im_protocols,
1767 XA_STRING,8,PropModeReplace,(
unsigned char *) NULL,0);
1768 if (windows->group_leader.id != (Window) NULL)
1769 (void) XSetTransientForHint(display,windows->image.id,
1770 windows->group_leader.id);
1771 if (resource_info->debug != MagickFalse)
1772 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Window id: 0x%lx (image)",
1777 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1778 resource_info,&windows->info);
1779 (void) CloneString(&windows->info.name,
"Info");
1780 (void) CloneString(&windows->info.icon_name,
"Info");
1781 windows->info.border_width=1;
1784 windows->info.flags|=PPosition;
1785 windows->info.attributes.win_gravity=UnmapGravity;
1786 windows->info.attributes.event_mask=ButtonPressMask | ExposureMask |
1787 StructureNotifyMask;
1788 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1789 manager_hints->input=MagickFalse;
1790 manager_hints->initial_state=NormalState;
1791 manager_hints->window_group=windows->image.id;
1792 XMakeWindow(display,windows->image.id,argv,argc,class_hints,manager_hints,
1794 windows->info.highlight_stipple=XCreateBitmapFromData(display,
1795 windows->info.id,(
char *) HighlightBitmap,HighlightWidth,HighlightHeight);
1796 windows->info.shadow_stipple=XCreateBitmapFromData(display,
1797 windows->info.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1798 (void) XSetTransientForHint(display,windows->info.id,windows->image.id);
1799 if (windows->image.mapped)
1800 (void) XWithdrawWindow(display,windows->info.id,windows->info.screen);
1801 if (resource_info->debug != MagickFalse)
1802 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Window id: 0x%lx (info)",
1807 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1808 resource_info,&windows->command);
1809 windows->command.data=MagickMenus;
1810 (void) XCommandWidget(display,windows,CommandMenu,(XEvent *) NULL);
1811 (void) FormatLocaleString(resource_name,MaxTextExtent,
"%s.command",
1812 resource_info->client_name);
1813 windows->command.geometry=XGetResourceClass(resource_info->resource_database,
1814 resource_name,
"geometry",(
char *) NULL);
1815 (void) CloneString(&windows->command.name,MagickTitle);
1816 windows->command.border_width=0;
1817 windows->command.flags|=PPosition;
1818 windows->command.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1819 ButtonReleaseMask | EnterWindowMask | ExposureMask | LeaveWindowMask |
1820 OwnerGrabButtonMask | StructureNotifyMask;
1821 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1822 manager_hints->input=MagickTrue;
1823 manager_hints->initial_state=NormalState;
1824 manager_hints->window_group=windows->image.id;
1825 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1827 windows->command.highlight_stipple=XCreateBitmapFromData(display,
1828 windows->command.id,(
char *) HighlightBitmap,HighlightWidth,
1830 windows->command.shadow_stipple=XCreateBitmapFromData(display,
1831 windows->command.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1832 (void) XSetTransientForHint(display,windows->command.id,windows->image.id);
1833 if (resource_info->debug != MagickFalse)
1834 (void) LogMagickEvent(X11Event,GetMagickModule(),
1835 "Window id: 0x%lx (command)",windows->command.id);
1839 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1840 resource_info,&windows->widget);
1841 (void) FormatLocaleString(resource_name,MaxTextExtent,
"%s.widget",
1842 resource_info->client_name);
1843 windows->widget.geometry=XGetResourceClass(resource_info->resource_database,
1844 resource_name,
"geometry",(
char *) NULL);
1845 windows->widget.border_width=0;
1846 windows->widget.flags|=PPosition;
1847 windows->widget.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1848 ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask |
1849 KeyReleaseMask | LeaveWindowMask | OwnerGrabButtonMask |
1850 StructureNotifyMask;
1851 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1852 manager_hints->input=MagickTrue;
1853 manager_hints->initial_state=NormalState;
1854 manager_hints->window_group=windows->image.id;
1855 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1857 windows->widget.highlight_stipple=XCreateBitmapFromData(display,
1858 windows->widget.id,(
char *) HighlightBitmap,HighlightWidth,HighlightHeight);
1859 windows->widget.shadow_stipple=XCreateBitmapFromData(display,
1860 windows->widget.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1861 (void) XSetTransientForHint(display,windows->widget.id,windows->image.id);
1862 if (resource_info->debug != MagickFalse)
1863 (void) LogMagickEvent(X11Event,GetMagickModule(),
1864 "Window id: 0x%lx (widget)",windows->widget.id);
1868 XGetWindowInfo(display,visual_info,map_info,pixel,font_info,
1869 resource_info,&windows->popup);
1870 windows->popup.border_width=0;
1871 windows->popup.flags|=PPosition;
1872 windows->popup.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
1873 ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask |
1874 KeyReleaseMask | LeaveWindowMask | StructureNotifyMask;
1875 manager_hints->flags=InputHint | StateHint | WindowGroupHint;
1876 manager_hints->input=MagickTrue;
1877 manager_hints->initial_state=NormalState;
1878 manager_hints->window_group=windows->image.id;
1879 XMakeWindow(display,root_window,argv,argc,class_hints,manager_hints,
1881 windows->popup.highlight_stipple=XCreateBitmapFromData(display,
1882 windows->popup.id,(
char *) HighlightBitmap,HighlightWidth,HighlightHeight);
1883 windows->popup.shadow_stipple=XCreateBitmapFromData(display,
1884 windows->popup.id,(
char *) ShadowBitmap,ShadowWidth,ShadowHeight);
1885 (void) XSetTransientForHint(display,windows->popup.id,windows->image.id);
1886 if (resource_info->debug != MagickFalse)
1887 (void) LogMagickEvent(X11Event,GetMagickModule(),
1888 "Window id: 0x%lx (pop up)",windows->popup.id);
1892 if (warning_handler == (WarningHandler) NULL)
1894 warning_handler=resource_info->display_warnings ?
1895 SetErrorHandler(XWarning) : SetErrorHandler((ErrorHandler) NULL);
1896 warning_handler=resource_info->display_warnings ?
1897 SetWarningHandler(XWarning) : SetWarningHandler((WarningHandler) NULL);
1907 window_changes.width=(int) windows->image.width;
1908 window_changes.height=(int) windows->image.height;
1909 (void) XReconfigureWMWindow(display,windows->image.id,windows->command.screen,
1910 (
unsigned int) (CWWidth | CWHeight),&window_changes);
1911 windows->image.pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1912 sizeof(*windows->image.pixmaps));
1913 windows->image.matte_pixmaps=(Pixmap *) AcquireQuantumMemory(number_scenes,
1914 sizeof(*windows->image.pixmaps));
1915 if ((windows->image.pixmaps == (Pixmap *) NULL) ||
1916 (windows->image.matte_pixmaps == (Pixmap *) NULL))
1917 ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",
1919 if ((windows->image.mapped == MagickFalse) ||
1920 (windows->backdrop.id != (Window) NULL))
1921 (void) XMapWindow(display,windows->image.id);
1922 XSetCursorState(display,windows,MagickTrue);
1923 for (scene=0; scene < (ssize_t) number_scenes; scene++)
1932 windows->image.pixmap=(Pixmap) NULL;
1933 windows->image.matte_pixmap=(Pixmap) NULL;
1934 if ((resource_info->map_type != (
char *) NULL) ||
1935 (visual_info->klass == TrueColor) ||
1936 (visual_info->klass == DirectColor))
1937 if (image_list[scene]->storage_class == PseudoClass)
1938 XGetPixelPacket(display,visual_info,map_info,resource_info,
1939 image_list[scene],windows->image.pixel_info);
1940 columns=(
unsigned int) image_list[scene]->columns;
1941 rows=(
unsigned int) image_list[scene]->rows;
1942 if ((image_list[scene]->columns != columns) ||
1943 (image_list[scene]->rows != rows))
1944 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1945 image_list[scene]->filename);
1946 status=XMakeImage(display,resource_info,&windows->image,image_list[scene],
1948 if (status == MagickFalse)
1949 ThrowXWindowFatalException(XServerFatalError,
"UnableToCreateXImage",
1951 if (image_list[scene]->debug != MagickFalse)
1953 (void) LogMagickEvent(X11Event,GetMagickModule(),
1954 "Image: [%.20g] %s %.20gx%.20g ",(
double) image_list[scene]->scene,
1955 image_list[scene]->filename,(
double) columns,(
double) rows);
1956 if (image_list[scene]->colors != 0)
1957 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%.20gc ",(
double)
1958 image_list[scene]->colors);
1959 (void) LogMagickEvent(X11Event,GetMagickModule(),
"%s",
1960 image_list[scene]->magick);
1965 if (resource_info->title != (
char *) NULL)
1970 title=InterpretImageProperties(resource_info->image_info,
1971 image_list[scene],resource_info->title);
1972 (void) CloneString(&windows->image.name,title);
1973 title=DestroyString(title);
1978 window_name[MaxTextExtent];
1980 p=image_list[scene]->magick_filename+
1981 strlen(image_list[scene]->magick_filename)-1;
1982 while ((p > image_list[scene]->magick_filename) && (*(p-1) !=
'/'))
1984 (void) FormatLocaleString(window_name,MaxTextExtent,
1985 "%s: %s[%.20g of %.20g]",MagickPackageName,p,(
double) scene+1,
1986 (
double) number_scenes);
1987 (void) CloneString(&windows->image.name,window_name);
1989 status=XStringListToTextProperty(&windows->image.name,1,&window_name);
1990 if (status != Success)
1992 XSetWMName(display,windows->image.id,&window_name);
1993 (void) XFree((
void *) window_name.value);
1995 windows->image.pixmaps[scene]=windows->image.pixmap;
1996 windows->image.matte_pixmaps[scene]=windows->image.matte_pixmap;
2001 event.xexpose.width=(int) image_list[scene]->columns;
2002 event.xexpose.height=(int) image_list[scene]->rows;
2003 XRefreshWindow(display,&windows->image,&event);
2004 (void) XSync(display,MagickFalse);
2007 XSetCursorState(display,windows,MagickFalse);
2008 if (windows->command.mapped)
2009 (void) XMapRaised(display,windows->command.id);
2013 nexus=NewImageList();
2017 image=image_list[0];
2018 state=(MagickStatusType) (ForwardAnimationState | RepeatAnimationState);
2019 (void) XMagickCommand(display,resource_info,windows,PlayCommand,&images,
2023 if (XEventsQueued(display,QueuedAfterFlush) == 0)
2024 if ((state & PlayAnimationState) || (state & StepAnimationState))
2030 delay=1000*image->delay/MagickMax(image->ticks_per_second,1L);
2031 XDelay(display,resource_info->delay*(delay == 0 ? 10 : delay));
2032 if (state & ForwardAnimationState)
2037 if (scene < ((ssize_t) number_scenes-1))
2042 if (iterations == (ssize_t) image_list[0]->iterations)
2047 if ((state & AutoReverseAnimationState) != 0)
2049 state&=(~ForwardAnimationState);
2054 if ((state & RepeatAnimationState) == 0)
2055 state&=(~PlayAnimationState);
2066 if (scene > first_scene)
2071 if (iterations == (ssize_t) image_list[0]->iterations)
2074 state&=(~RepeatAnimationState);
2076 if (state & AutoReverseAnimationState)
2078 state|=ForwardAnimationState;
2084 if ((state & RepeatAnimationState) == MagickFalse)
2085 state&=(~PlayAnimationState);
2086 scene=(ssize_t) number_scenes-1;
2090 scene=MagickMax(scene,0);
2091 image=image_list[scene];
2092 if ((image != (
Image *) NULL) && (image->start_loop != 0))
2094 if ((state & StepAnimationState) ||
2095 (resource_info->title != (
char *) NULL))
2098 name[MaxTextExtent];
2103 p=image_list[scene]->filename+
2104 strlen(image_list[scene]->filename)-1;
2105 while ((p > image_list[scene]->filename) && (*(p-1) !=
'/'))
2107 (void) FormatLocaleString(name,MaxTextExtent,
2108 "%s: %s[%.20g of %.20g]",MagickPackageName,p,(
double) scene+1,
2109 (
double) number_scenes);
2110 (void) CloneString(&windows->image.name,name);
2111 if (resource_info->title != (
char *) NULL)
2116 title=InterpretImageProperties(resource_info->image_info,
2117 image,resource_info->title);
2118 (void) CloneString(&windows->image.name,title);
2119 title=DestroyString(title);
2121 status=XStringListToTextProperty(&windows->image.name,1,
2123 if (status != Success)
2125 XSetWMName(display,windows->image.id,&window_name);
2126 (void) XFree((
void *) window_name.value);
2132 XGetPixelPacket(display,visual_info,map_info,resource_info,
2133 image_list[scene],windows->image.pixel_info);
2134 if (image != (
Image *) NULL)
2136 windows->image.ximage->width=(int) image->columns;
2137 windows->image.ximage->height=(int) image->rows;
2139 windows->image.pixmap=windows->image.pixmaps[scene];
2140 windows->image.matte_pixmap=windows->image.matte_pixmaps[scene];
2143 event.xexpose.width=(int) image->columns;
2144 event.xexpose.height=(int) image->rows;
2145 if ((state & ExitState) == 0)
2147 XRefreshWindow(display,&windows->image,&event);
2148 (void) XSync(display,MagickFalse);
2150 state&=(~StepAnimationState);
2151 if (pause != MagickFalse)
2152 for (i=0; i < (ssize_t) resource_info->pause; i++)
2157 status=XCheckTypedWindowEvent(display,windows->image.id,KeyPress,
2164 length=XLookupString((XKeyEvent *) &event.xkey,command,(
int)
2165 sizeof(command),&key_symbol,(XComposeStatus *) NULL);
2166 *(command+length)=
'\0';
2167 if ((key_symbol == XK_q) || (key_symbol == XK_Escape))
2169 XClientMessage(display,windows->image.id,
2170 windows->im_protocols,windows->im_exit,CurrentTime);
2181 timestamp=GetMagickTime();
2182 (void) XNextEvent(display,&event);
2183 if (windows->image.stasis == MagickFalse)
2184 windows->image.stasis=(GetMagickTime()-timestamp) > 0 ?
2185 MagickTrue : MagickFalse;
2186 if (event.xany.window == windows->command.id)
2194 id=XCommandWidget(display,windows,CommandMenu,&event);
2197 (void) CopyMagickString(command,CommandMenu[
id],MaxTextExtent);
2198 animate_command=CommandMenus[id];
2199 if (
id < MagickMenus)
2207 entry=XMenuWidget(display,windows,CommandMenu[
id],Menus[
id],
2211 (void) CopyMagickString(command,Menus[
id][entry],MaxTextExtent);
2212 animate_command=Commands[id][entry];
2214 if (animate_command != NullCommand)
2215 nexus=XMagickCommand(display,resource_info,windows,
2216 animate_command,&image,&state);
2223 if (resource_info->debug != MagickFalse)
2224 (void) LogMagickEvent(X11Event,GetMagickModule(),
2225 "Button Press: 0x%lx %u +%d+%d",event.xbutton.window,
2226 event.xbutton.button,event.xbutton.x,event.xbutton.y);
2227 if ((event.xbutton.button == Button3) &&
2228 (event.xbutton.state & Mod1Mask))
2233 event.xbutton.button=Button2;
2234 event.xbutton.state&=(~Mod1Mask);
2236 if (event.xbutton.window == windows->backdrop.id)
2238 (void) XSetInputFocus(display,event.xbutton.window,RevertToParent,
2239 event.xbutton.time);
2242 if (event.xbutton.window == windows->image.id)
2244 if (resource_info->immutable != MagickFalse)
2252 if (windows->command.mapped)
2253 (void) XWithdrawWindow(display,windows->command.id,
2254 windows->command.screen);
2257 (void) XCommandWidget(display,windows,CommandMenu,
2259 (void) XMapRaised(display,windows->command.id);
2266 if (resource_info->debug != MagickFalse)
2267 (void) LogMagickEvent(X11Event,GetMagickModule(),
2268 "Button Release: 0x%lx %u +%d+%d",event.xbutton.window,
2269 event.xbutton.button,event.xbutton.x,event.xbutton.y);
2274 if (resource_info->debug != MagickFalse)
2275 (void) LogMagickEvent(X11Event,GetMagickModule(),
2276 "Client Message: 0x%lx 0x%lx %d 0x%lx",(
unsigned long)
2277 event.xclient.window,(
unsigned long) event.xclient.message_type,
2278 event.xclient.format,(
unsigned long) event.xclient.data.l[0]);
2279 if (event.xclient.message_type == windows->im_protocols)
2281 if (*event.xclient.data.l == (
long) windows->im_update_colormap)
2286 for (i=0; i < (ssize_t) number_windows; i++)
2288 if (magick_windows[i]->
id == windows->icon.id)
2290 context_values.background=pixel->background_color.pixel;
2291 context_values.foreground=pixel->foreground_color.pixel;
2292 (void) XChangeGC(display,magick_windows[i]->annotate_context,
2293 context_mask,&context_values);
2294 (void) XChangeGC(display,magick_windows[i]->widget_context,
2295 context_mask,&context_values);
2296 context_values.background=pixel->foreground_color.pixel;
2297 context_values.foreground=pixel->background_color.pixel;
2298 context_values.plane_mask=
2299 context_values.background ^ context_values.foreground;
2300 (void) XChangeGC(display,magick_windows[i]->highlight_context,
2301 (
size_t) (context_mask | GCPlaneMask),
2303 magick_windows[i]->attributes.background_pixel=
2304 pixel->background_color.pixel;
2305 magick_windows[i]->attributes.border_pixel=
2306 pixel->border_color.pixel;
2307 magick_windows[i]->attributes.colormap=map_info->colormap;
2308 (void) XChangeWindowAttributes(display,magick_windows[i]->
id,
2309 (
unsigned long) magick_windows[i]->mask,
2310 &magick_windows[i]->attributes);
2312 if (windows->backdrop.id != (Window) NULL)
2313 (void) XInstallColormap(display,map_info->colormap);
2316 if (*event.xclient.data.l == (
long) windows->im_exit)
2323 if (event.xclient.message_type == windows->dnd_protocols)
2343 if ((*event.xclient.data.l != 2) && (*event.xclient.data.l != 128))
2345 selection=XInternAtom(display,
"DndSelection",MagickFalse);
2346 status=XGetWindowProperty(display,root_window,selection,0L,2047L,
2347 MagickFalse,(Atom) AnyPropertyType,&type,&format,&length,&after,
2349 if ((status != Success) || (length == 0))
2351 if (*event.xclient.data.l == 2)
2356 (void) CopyMagickString(resource_info->image_info->filename,
2357 (
char *) data,MaxTextExtent);
2364 if (LocaleNCompare((
char *) data,
"file:",5) != 0)
2366 (void) XFree((
void *) data);
2369 (void) CopyMagickString(resource_info->image_info->filename,
2370 ((
char *) data)+5,MaxTextExtent);
2372 nexus=ReadImage(resource_info->image_info,&image->exception);
2373 CatchException(&image->exception);
2374 if (nexus != (
Image *) NULL)
2376 (void) XFree((
void *) data);
2382 if (event.xclient.message_type != windows->wm_protocols)
2384 if (*event.xclient.data.l == (
long) windows->wm_take_focus)
2386 (void) XSetInputFocus(display,event.xclient.window,RevertToParent,
2387 (Time) event.xclient.data.l[1]);
2390 if (*event.xclient.data.l != (
long) windows->wm_delete_window)
2392 (void) XWithdrawWindow(display,event.xclient.window,
2393 visual_info->screen);
2394 if (event.xclient.window == windows->image.id)
2401 case ConfigureNotify:
2403 if (resource_info->debug != MagickFalse)
2404 (void) LogMagickEvent(X11Event,GetMagickModule(),
2405 "Configure Notify: 0x%lx %dx%d+%d+%d %d",event.xconfigure.window,
2406 event.xconfigure.width,event.xconfigure.height,event.xconfigure.x,
2407 event.xconfigure.y,event.xconfigure.send_event);
2408 if (event.xconfigure.window == windows->image.id)
2410 if (event.xconfigure.send_event != 0)
2418 if (windows->command.geometry == (
char *) NULL)
2419 if (windows->command.mapped == MagickFalse)
2422 event.xconfigure.x-windows->command.width-25;
2423 windows->command.y=
event.xconfigure.y;
2424 XConstrainWindowPosition(display,&windows->command);
2425 window_changes.x=windows->command.x;
2426 window_changes.y=windows->command.y;
2427 (void) XReconfigureWMWindow(display,windows->command.id,
2428 windows->command.screen,(
unsigned int) (CWX | CWY),
2431 if (windows->widget.geometry == (
char *) NULL)
2432 if (windows->widget.mapped == MagickFalse)
2435 event.xconfigure.x+
event.xconfigure.width/10;
2437 event.xconfigure.y+
event.xconfigure.height/10;
2438 XConstrainWindowPosition(display,&windows->widget);
2439 window_changes.x=windows->widget.x;
2440 window_changes.y=windows->widget.y;
2441 (void) XReconfigureWMWindow(display,windows->widget.id,
2442 windows->widget.screen,(
unsigned int) (CWX | CWY),
2449 windows->image.width=(
unsigned int) event.xconfigure.width;
2450 windows->image.height=(
unsigned int) event.xconfigure.height;
2453 if (event.xconfigure.window == windows->icon.id)
2458 windows->icon.width=(
unsigned int) event.xconfigure.width;
2459 windows->icon.height=(
unsigned int) event.xconfigure.height;
2469 if (resource_info->debug != MagickFalse)
2470 (void) LogMagickEvent(X11Event,GetMagickModule(),
2471 "Destroy Notify: 0x%lx",event.xdestroywindow.window);
2472 if (event.xdestroywindow.window == windows->group_leader.id)
2484 if (map_info->colormap != XDefaultColormap(display,visual_info->screen))
2485 if (event.xcrossing.mode != NotifyUngrab)
2486 XInstallColormap(display,map_info->colormap);
2491 if (resource_info->debug != MagickFalse)
2492 (void) LogMagickEvent(X11Event,GetMagickModule(),
2493 "Expose: 0x%lx %dx%d+%d+%d",event.xexpose.window,
2494 event.xexpose.width,event.xexpose.height,event.xexpose.x,
2499 if (event.xexpose.window == windows->image.id)
2501 windows->image.pixmap=windows->image.pixmaps[scene];
2502 windows->image.matte_pixmap=windows->image.matte_pixmaps[scene];
2503 XRefreshWindow(display,&windows->image,&event);
2506 if (event.xexpose.window == windows->icon.id)
2507 if (event.xexpose.count == 0)
2509 XRefreshWindow(display,&windows->icon,&event);
2522 length=XLookupString((XKeyEvent *) &event.xkey,command,(
int)
2523 sizeof(command),&key_symbol,(XComposeStatus *) NULL);
2524 *(command+length)=
'\0';
2525 if (resource_info->debug != MagickFalse)
2526 (void) LogMagickEvent(X11Event,GetMagickModule(),
2527 "Key press: 0x%lx (%c)",(
unsigned long) key_symbol,*command);
2528 animate_command=NullCommand;
2533 if ((event.xkey.state & ControlMask) == MagickFalse)
2535 animate_command=OpenCommand;
2540 animate_command=StepBackwardCommand;
2545 animate_command=StepForwardCommand;
2550 animate_command=FasterCommand;
2555 animate_command=SlowerCommand;
2560 animate_command=HelpCommand;
2565 animate_command=BrowseDocumentationCommand;
2570 animate_command=InfoCommand;
2576 animate_command=QuitCommand;
2582 if (animate_command != NullCommand)
2583 nexus=XMagickCommand(display,resource_info,windows,animate_command,
2592 (void) XLookupString((XKeyEvent *) &event.xkey,command,(
int)
2593 sizeof(command),&key_symbol,(XComposeStatus *) NULL);
2594 if (resource_info->debug != MagickFalse)
2595 (void) LogMagickEvent(X11Event,GetMagickModule(),
2596 "Key release: 0x%lx (%c)",(
unsigned long) key_symbol,*command);
2604 if (map_info->colormap != XDefaultColormap(display,visual_info->screen))
2605 if (event.xcrossing.mode != NotifyUngrab)
2606 XUninstallColormap(display,map_info->colormap);
2611 if (resource_info->debug != MagickFalse)
2612 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Map Notify: 0x%lx",
2614 if (event.xmap.window == windows->backdrop.id)
2616 (void) XSetInputFocus(display,event.xmap.window,RevertToParent,
2618 windows->backdrop.mapped=MagickTrue;
2621 if (event.xmap.window == windows->image.id)
2623 if (windows->backdrop.id != (Window) NULL)
2624 (void) XInstallColormap(display,map_info->colormap);
2625 if (LocaleCompare(image_list[0]->magick,
"LOGO") == 0)
2627 if (LocaleCompare(display_image->filename,
"LOGO") == 0)
2628 nexus=XMagickCommand(display,resource_info,windows,
2629 OpenCommand,&image,&state);
2633 windows->image.mapped=MagickTrue;
2636 if (event.xmap.window == windows->info.id)
2638 windows->info.mapped=MagickTrue;
2641 if (event.xmap.window == windows->icon.id)
2646 XMakeStandardColormap(display,icon_visual,icon_resources,
2647 display_image,icon_map,icon_pixel);
2648 (void) XMakeImage(display,icon_resources,&windows->icon,
2649 display_image,windows->icon.width,windows->icon.height);
2650 (void) XSetWindowBackgroundPixmap(display,windows->icon.id,
2651 windows->icon.pixmap);
2652 (void) XClearWindow(display,windows->icon.id);
2653 (void) XWithdrawWindow(display,windows->info.id,
2654 windows->info.screen);
2655 windows->icon.mapped=MagickTrue;
2658 if (event.xmap.window == windows->command.id)
2660 windows->command.mapped=MagickTrue;
2663 if (event.xmap.window == windows->popup.id)
2665 windows->popup.mapped=MagickTrue;
2668 if (event.xmap.window == windows->widget.id)
2670 windows->widget.mapped=MagickTrue;
2677 (void) XRefreshKeyboardMapping(&event.xmapping);
2682 case PropertyNotify:
2698 if (resource_info->debug != MagickFalse)
2699 (void) LogMagickEvent(X11Event,GetMagickModule(),
2700 "Property Notify: 0x%lx 0x%lx %d",(
unsigned long)
2701 event.xproperty.window,(
unsigned long) event.xproperty.atom,
2702 event.xproperty.state);
2703 if (event.xproperty.atom != windows->im_remote_command)
2708 status=XGetWindowProperty(display,event.xproperty.window,
2709 event.xproperty.atom,0L,(
long) MaxTextExtent,MagickFalse,(Atom)
2710 AnyPropertyType,&type,&format,&length,&after,&data);
2711 if ((status != Success) || (length == 0))
2713 (void) CopyMagickString(resource_info->image_info->filename,
2714 (
char *) data,MaxTextExtent);
2715 nexus=ReadImage(resource_info->image_info,&image->exception);
2716 CatchException(&image->exception);
2717 if (nexus != (
Image *) NULL)
2719 (void) XFree((
void *) data);
2722 case ReparentNotify:
2724 if (resource_info->debug != MagickFalse)
2725 (void) LogMagickEvent(X11Event,GetMagickModule(),
2726 "Reparent Notify: 0x%lx=>0x%lx",event.xreparent.parent,
2727 event.xreparent.window);
2732 if (resource_info->debug != MagickFalse)
2733 (void) LogMagickEvent(X11Event,GetMagickModule(),
2734 "Unmap Notify: 0x%lx",event.xunmap.window);
2735 if (event.xunmap.window == windows->backdrop.id)
2737 windows->backdrop.mapped=MagickFalse;
2740 if (event.xunmap.window == windows->image.id)
2742 windows->image.mapped=MagickFalse;
2745 if (event.xunmap.window == windows->info.id)
2747 windows->info.mapped=MagickFalse;
2750 if (event.xunmap.window == windows->icon.id)
2752 if (map_info->colormap == icon_map->colormap)
2753 XConfigureImageColormap(display,resource_info,windows,
2755 (void) XFreeStandardColormap(display,icon_visual,icon_map,
2757 windows->icon.mapped=MagickFalse;
2760 if (event.xunmap.window == windows->command.id)
2762 windows->command.mapped=MagickFalse;
2765 if (event.xunmap.window == windows->popup.id)
2767 if (windows->backdrop.id != (Window) NULL)
2768 (void) XSetInputFocus(display,windows->image.id,RevertToParent,
2770 windows->popup.mapped=MagickFalse;
2773 if (event.xunmap.window == windows->widget.id)
2775 if (windows->backdrop.id != (Window) NULL)
2776 (void) XSetInputFocus(display,windows->image.id,RevertToParent,
2778 windows->widget.mapped=MagickFalse;
2785 if (resource_info->debug != MagickFalse)
2786 (void) LogMagickEvent(X11Event,GetMagickModule(),
"Event type: %d",
2792 while (!(state & ExitState));
2793 image_list=(
Image **) RelinquishMagickMemory(image_list);
2794 images=DestroyImageList(images);
2795 if ((windows->visual_info->klass == GrayScale) ||
2796 (windows->visual_info->klass == PseudoColor) ||
2797 (windows->visual_info->klass == DirectColor))
2802 if (windows->info.mapped)
2803 (void) XWithdrawWindow(display,windows->info.id,windows->info.screen);
2804 if (windows->command.mapped)
2805 (void) XWithdrawWindow(display,windows->command.id,
2806 windows->command.screen);
2808 if (resource_info->backdrop == MagickFalse)
2809 if (windows->backdrop.mapped)
2811 (void) XWithdrawWindow(display,windows->backdrop.id,\
2812 windows->backdrop.screen);
2813 (void) XDestroyWindow(display,windows->backdrop.id);
2814 windows->backdrop.id=(Window) NULL;
2815 (void) XWithdrawWindow(display,windows->image.id,windows->image.screen);
2816 (void) XDestroyWindow(display,windows->image.id);
2817 windows->image.id=(Window) NULL;
2819 XSetCursorState(display,windows,MagickTrue);
2820 XCheckRefreshWindows(display,windows);
2821 for (scene=1; scene < (ssize_t) number_scenes; scene++)
2823 if (windows->image.pixmaps[scene] != (Pixmap) NULL)
2824 (void) XFreePixmap(display,windows->image.pixmaps[scene]);
2825 windows->image.pixmaps[scene]=(Pixmap) NULL;
2826 if (windows->image.matte_pixmaps[scene] != (Pixmap) NULL)
2827 (void) XFreePixmap(display,windows->image.matte_pixmaps[scene]);
2828 windows->image.matte_pixmaps[scene]=(Pixmap) NULL;
2830 XSetCursorState(display,windows,MagickFalse);
2831 windows->image.pixmaps=(Pixmap *)
2832 RelinquishMagickMemory(windows->image.pixmaps);
2833 windows->image.matte_pixmaps=(Pixmap *)
2834 RelinquishMagickMemory(windows->image.matte_pixmaps);
2835 if (nexus == (
Image *) NULL)
2840 if (windows->image.mapped != MagickFalse)
2841 (void) XWithdrawWindow(display,windows->image.id,windows->image.screen);
2842 XDelay(display,SuspendTime);
2843 (void) XFreeStandardColormap(display,icon_visual,icon_map,icon_pixel);
2844 if (resource_info->map_type == (
char *) NULL)
2845 (void) XFreeStandardColormap(display,visual_info,map_info,pixel);
2846 DestroyXResources();
2848 (void) XSync(display,MagickFalse);
2852 (void) SetErrorHandler(warning_handler);
2853 (void) SetWarningHandler(warning_handler);
2857 directory=getcwd(working_directory,MaxTextExtent);
2859 if (*resource_info->home_directory ==
'\0')
2860 (void) CopyMagickString(resource_info->home_directory,
".",MaxTextExtent);
2861 status=chdir(resource_info->home_directory);
2863 (void) ThrowMagickException(&images->exception,GetMagickModule(),
2864 FileOpenError,
"UnableToOpenFile",
"%s",resource_info->home_directory);
2902static MagickBooleanType XSaveImage(Display *display,
2903 XResourceInfo *resource_info,XWindows *windows,
Image *image)
2906 filename[MaxTextExtent];
2917 if (resource_info->write_filename != (
char *) NULL)
2918 (void) CopyMagickString(filename,resource_info->write_filename,
2923 path[MaxTextExtent];
2928 GetPathComponent(image->filename,HeadPath,path);
2929 GetPathComponent(image->filename,TailPath,filename);
2931 (void) CopyMagickString(path,
".",MaxTextExtent);
2934 (void) ThrowMagickException(&image->exception,GetMagickModule(),
2935 FileOpenError,
"UnableToOpenFile",
"%s",path);
2937 XFileBrowserWidget(display,windows,
"Save",filename);
2938 if (*filename ==
'\0')
2940 if (IsPathAccessible(filename) != MagickFalse)
2948 status=XConfirmWidget(display,windows,
"Overwrite",filename);
2952 image_info=CloneImageInfo(resource_info->image_info);
2953 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
2954 (void) SetImageInfo(image_info,1,&image->exception);
2955 if ((LocaleCompare(image_info->magick,
"JPEG") == 0) ||
2956 (LocaleCompare(image_info->magick,
"JPG") == 0))
2959 quality[MaxTextExtent];
2967 (void) FormatLocaleString(quality,MaxTextExtent,
"%.20g",(
double)
2968 image_info->quality);
2969 status=XDialogWidget(display,windows,
"Save",
"Enter JPEG quality:",
2971 if (*quality ==
'\0')
2973 image->quality=StringToUnsignedLong(quality);
2974 image_info->interlace=status != MagickFalse ? NoInterlace :
2977 if ((LocaleCompare(image_info->magick,
"EPS") == 0) ||
2978 (LocaleCompare(image_info->magick,
"PDF") == 0) ||
2979 (LocaleCompare(image_info->magick,
"PS") == 0) ||
2980 (LocaleCompare(image_info->magick,
"PS2") == 0))
2983 geometry[MaxTextExtent];
2988 (void) CopyMagickString(geometry,PSPageGeometry,MaxTextExtent);
2989 if (LocaleCompare(image_info->magick,
"PDF") == 0)
2990 (void) CopyMagickString(geometry,PSPageGeometry,MaxTextExtent);
2991 if (image_info->page != (
char *) NULL)
2992 (void) CopyMagickString(geometry,image_info->page,MaxTextExtent);
2993 XListBrowserWidget(display,windows,&windows->widget,PageSizes,
"Select",
2994 "Select page geometry:",geometry);
2995 if (*geometry !=
'\0')
2996 image_info->page=GetPageGeometry(geometry);
3001 image=GetFirstImageInList(image);
3002 status=WriteImages(image_info,image,filename,&image->exception);
3003 if (status != MagickFalse)
3004 image->taint=MagickFalse;
3005 image_info=DestroyImageInfo(image_info);
3006 XSetCursorState(display,windows,MagickFalse);
3007 return(status != 0 ? MagickTrue : MagickFalse);
3038MagickExport MagickBooleanType AnimateImages(
const ImageInfo *image_info,
3041 assert(image_info != (
const ImageInfo *) NULL);
3042 assert(image_info->signature == MagickCoreSignature);
3044 assert(image != (
Image *) NULL);
3045 assert(image->signature == MagickCoreSignature);
3046 if (IsEventLogging() != MagickFalse)
3047 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3048 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3049 MissingDelegateError,
"DelegateLibrarySupportNotBuiltIn",
"`%s' (X11)",
3051 return(MagickFalse);