% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
#include "MagickCore/color.h"
#include "MagickCore/color-private.h"
#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.h"
#include "MagickCore/constitute.h"
#include "MagickCore/delegate.h"
#include "MagickCore/exception.h"
#include "MagickCore/string-private.h"
#include "MagickCore/transform.h"
#include "MagickCore/utility.h"
+#include "MagickCore/utility-private.h"
#include "MagickCore/version.h"
#include "MagickCore/widget.h"
+#include "MagickCore/widget-private.h"
+#include "MagickCore/xwindow.h"
#include "MagickCore/xwindow-private.h"
\f
#if defined(MAGICKCORE_X11_DELEGATE)
*/
static Image
*XMagickCommand(Display *,XResourceInfo *,XWindows *,const CommandType,
- Image **,MagickStatusType *);
+ Image **,MagickStatusType *,ExceptionInfo *);
static MagickBooleanType
- XSaveImage(Display *,XResourceInfo *,XWindows *,Image *);
+ XSaveImage(Display *,XResourceInfo *,XWindows *,Image *,ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The format of the AnimateImages method is:
%
% MagickBooleanType AnimateImages(const ImageInfo *image_info,
-% Image *images)
+% Image *images,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o image: the image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType AnimateImages(const ImageInfo *image_info,
- Image *images)
+ Image *images,ExceptionInfo *exception)
{
char
*argv[1];
display=XOpenDisplay(image_info->server_name);
if (display == (Display *) NULL)
{
- (void) ThrowMagickException(&images->exception,GetMagickModule(),
- XServerError,"UnableToOpenXServer","`%s'",XDisplayName(
- image_info->server_name));
+ (void) ThrowMagickException(exception,GetMagickModule(),XServerError,
+ "UnableToOpenXServer","'%s'",XDisplayName(image_info->server_name));
return(MagickFalse);
}
- if (images->exception.severity != UndefinedException)
- CatchException(&images->exception);
+ if (exception->severity != UndefinedException)
+ CatchException(exception);
(void) XSetErrorHandler(XError);
resource_database=XGetResourceDatabase(display,GetClientName());
(void) ResetMagickMemory(&resource_info,0,sizeof(XResourceInfo));
resource_info.image_geometry=AcquireString(image_info->page);
resource_info.immutable=MagickTrue;
argv[0]=AcquireString(GetClientName());
- (void) XAnimateImages(display,&resource_info,argv,1,images);
+ (void) XAnimateImages(display,&resource_info,argv,1,images,exception);
+ (void) SetErrorHandler((ErrorHandler) NULL);
+ (void) SetWarningHandler((WarningHandler) NULL);
argv[0]=DestroyString(argv[0]);
(void) XCloseDisplay(display);
XDestroyResourceInfo(&resource_info);
- status=images->exception.severity == UndefinedException ?
- MagickTrue : MagickFalse;
+ status=exception->severity == UndefinedException ? MagickTrue : MagickFalse;
return(status != 0 ? MagickTrue : MagickFalse);
}
\f
%
% Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
% XWindows *windows,const CommandType command_type,Image **image,
-% MagickStatusType *state)
+% MagickStatusType *state,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o state: Specifies a MagickStatusType; XMagickCommand may return a
% modified state.
%
+% o exception: return any errors or warnings in this structure.
+%
%
*/
static Image *XMagickCommand(Display *display,XResourceInfo *resource_info,
XWindows *windows,const CommandType command_type,Image **image,
- MagickStatusType *state)
+ MagickStatusType *state,ExceptionInfo *exception)
{
Image
*nexus;
char
**filelist;
- ExceptionInfo
- *exception;
-
Image
*images,
*next;
return((Image *) NULL);
}
read_info=CloneImageInfo(resource_info->image_info);
- exception=AcquireExceptionInfo();
images=NewImageList();
XSetCursorState(display,windows,MagickTrue);
XCheckRefreshWindows(display,windows);
break;
}
filelist=(char **) RelinquishMagickMemory(filelist);
- exception=DestroyExceptionInfo(exception);
read_info=DestroyImageInfo(read_info);
if (images == (Image *) NULL)
{
*title;
title=InterpretImageProperties(resource_info->image_info,*image,
- resource_info->title);
+ resource_info->title,exception);
(void) CopyMagickString(windows->image.name,title,MaxTextExtent);
title=DestroyString(title);
}
/*
Save image.
*/
- status=XSaveImage(display,resource_info,windows,*image);
+ status=XSaveImage(display,resource_info,windows,*image,exception);
if (status == MagickFalse)
{
- XNoticeWidget(display,windows,"Unable to write X image:",
- (*image)->filename);
+ char
+ message[MaxTextExtent];
+
+ (void) FormatLocaleString(message,MaxTextExtent,"%s:%s",
+ exception->reason != (char *) NULL ? exception->reason : "",
+ exception->description != (char *) NULL ? exception->description :
+ "");
+ XNoticeWidget(display,windows,"Unable to save file:",message);
break;
}
break;
}
case InfoCommand:
{
- XDisplayImageInfo(display,resource_info,windows,(Image *) NULL,*image);
+ XDisplayImageInfo(display,resource_info,windows,(Image *) NULL,*image,
+ exception);
break;
}
case HelpCommand:
XSetCursorState(display,windows,MagickTrue);
XCheckRefreshWindows(display,windows);
status=InvokeDelegate(resource_info->image_info,*image,"browse",
- (char *) NULL,&(*image)->exception);
+ (char *) NULL,exception);
if (status == MagickFalse)
XNoticeWidget(display,windows,"Unable to browse documentation",
(char *) NULL);
% The format of the XAnimateBackgroundImage method is:
%
% void XAnimateBackgroundImage(Display *display,
-% XResourceInfo *resource_info,Image *images)
+% XResourceInfo *resource_info,Image *images,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o images: the image list.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
#endif
MagickExport void XAnimateBackgroundImage(Display *display,
- XResourceInfo *resource_info,Image *images)
+ XResourceInfo *resource_info,Image *images,ExceptionInfo *exception)
{
char
geometry[MaxTextExtent],
*/
if (window_info.id == root_window)
XDestroyWindowColors(display,root_window);
- coalesce_image=CoalesceImages(images,&images->exception);
+ coalesce_image=CoalesceImages(images,exception);
if (coalesce_image == (Image *) NULL)
ThrowXWindowFatalException(ResourceLimitError,"MemoryAllocationFailed",
images->filename);
(next->colors > (size_t) visual_info->colormap_size))
break;
for (i=0; i < (ssize_t) images->colors; i++)
- if (IsPixelPacketEquivalent(next->colormap+i,images->colormap+i) == MagickFalse)
+ if (IsPixelInfoEquivalent(next->colormap+i,images->colormap+i) == MagickFalse)
break;
if (i < (ssize_t) images->colors)
break;
next=GetNextImageInList(next);
}
if (next != (Image *) NULL)
- (void) RemapImages(resources.quantize_info,images,(Image *) NULL);
+ (void) RemapImages(resources.quantize_info,images,(Image *) NULL,
+ exception);
}
/*
Sort images by increasing scene number.
*/
number_scenes=GetImageListLength(images);
- image_list=ImageListToArray(images,&images->exception);
+ image_list=ImageListToArray(images,exception);
if (image_list == (Image **) NULL)
ThrowXWindowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed",images->filename);
(visual_info->klass == TrueColor) ||
(visual_info->klass == DirectColor))
(void) SetImageType(image_list[scene],image_list[scene]->matte ==
- MagickFalse ? TrueColorType : TrueColorMatteType);
+ MagickFalse ? TrueColorType : TrueColorMatteType,exception);
if ((display_image->columns < image_list[scene]->columns) &&
(display_image->rows < image_list[scene]->rows))
display_image=image_list[scene];
if ((resource_info->map_type != (char *) NULL) ||
(visual_info->klass == TrueColor) || (visual_info->klass == DirectColor))
(void) SetImageType(display_image,display_image->matte == MagickFalse ?
- TrueColorType : TrueColorMatteType);
+ TrueColorType : TrueColorMatteType,exception);
XMakeStandardColormap(display,visual_info,&resources,display_image,map_info,
- &pixel);
+ &pixel,exception);
/*
Graphic context superclass.
*/
window_info.x=(int) geometry_info.x;
window_info.y=(int) geometry_info.y;
status=XMakeImage(display,&resources,&window_info,image_list[0],
- window_info.width,window_info.height);
+ window_info.width,window_info.height,exception);
if (status == MagickFalse)
ThrowXWindowFatalException(XServerFatalError,"UnableToCreateXImage",
images->filename);
ThrowXWindowFatalException(XServerFatalError,"UnableToCreateXImage",
image_list[scene]->filename);
status=XMakeImage(display,&resources,&window_info,image_list[scene],
- columns,rows);
+ columns,rows,exception);
if (status == MagickFalse)
ThrowXWindowFatalException(XServerFatalError,"UnableToCreateXImage",
images->filename);
% The format of the XAnimateImages method is:
%
% Image *XAnimateImages(Display *display,XResourceInfo *resource_info,
-% char **argv,const int argc,Image *images)
+% char **argv,const int argc,Image *images,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o images: the image list.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport Image *XAnimateImages(Display *display,
- XResourceInfo *resource_info,char **argv,const int argc,Image *images)
+ XResourceInfo *resource_info,char **argv,const int argc,Image *images,
+ ExceptionInfo *exception)
{
#define MagickMenus 4
#define MaXWindows 8
status=chdir(working_directory);
if (status == -1)
- (void) ThrowMagickException(&images->exception,GetMagickModule(),
- FileOpenError,"UnableToOpenFile","%s",working_directory);
+ (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
+ "UnableToOpenFile","%s",working_directory);
warning_handler=resource_info->display_warnings ?
SetErrorHandler(XWarning) : SetErrorHandler((ErrorHandler) NULL);
warning_handler=resource_info->display_warnings ?
class_hints=windows->class_hints;
manager_hints=windows->manager_hints;
root_window=XRootWindow(display,visual_info->screen);
- coalesce_image=CoalesceImages(images,&images->exception);
+ coalesce_image=CoalesceImages(images,exception);
if (coalesce_image == (Image *) NULL)
ThrowXWindowFatalException(XServerFatalError,"MemoryAllocationFailed",
images->filename);
(next->colors > (size_t) visual_info->colormap_size))
break;
for (i=0; i < (ssize_t) images->colors; i++)
- if (IsPixelPacketEquivalent(next->colormap+i,images->colormap+i) == MagickFalse)
+ if (IsPixelInfoEquivalent(next->colormap+i,images->colormap+i) == MagickFalse)
break;
if (i < (ssize_t) images->colors)
break;
}
if (next != (Image *) NULL)
(void) RemapImages(resource_info->quantize_info,images,
- (Image *) NULL);
+ (Image *) NULL,exception);
}
/*
Sort images by increasing scene number.
*/
number_scenes=GetImageListLength(images);
- image_list=ImageListToArray(images,&images->exception);
+ image_list=ImageListToArray(images,exception);
if (image_list == (Image **) NULL)
ThrowXWindowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
images->filename);
(visual_info->klass == TrueColor) ||
(visual_info->klass == DirectColor))
(void) SetImageType(image_list[scene],image_list[scene]->matte ==
- MagickFalse ? TrueColorType : TrueColorMatteType);
+ MagickFalse ? TrueColorType : TrueColorMatteType,exception);
if ((display_image->columns < image_list[scene]->columns) &&
(display_image->rows < image_list[scene]->rows))
display_image=image_list[scene];
display_image->magick);
}
XMakeStandardColormap(display,visual_info,resource_info,display_image,
- map_info,pixel);
+ map_info,pixel,exception);
/*
Initialize graphic context.
*/
*title;
title=InterpretImageProperties(resource_info->image_info,display_image,
- resource_info->title);
+ resource_info->title,exception);
(void) CopyMagickString(windows->image.name,title,MaxTextExtent);
(void) CopyMagickString(windows->image.icon_name,title,MaxTextExtent);
title=DestroyString(title);
/*
Create X image.
*/
- (void) TransformImageColorspace(image_list[scene],RGBColorspace);
+ if (IssRGBColorspace(image_list[scene]->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image_list[scene],sRGBColorspace,
+ exception);
windows->image.pixmap=(Pixmap) NULL;
windows->image.matte_pixmap=(Pixmap) NULL;
if ((resource_info->map_type != (char *) NULL) ||
ThrowXWindowFatalException(XServerFatalError,"UnableToCreateXImage",
image_list[scene]->filename);
status=XMakeImage(display,resource_info,&windows->image,image_list[scene],
- columns,rows);
+ columns,rows,exception);
if (status == MagickFalse)
ThrowXWindowFatalException(XServerFatalError,"UnableToCreateXImage",
images->filename);
*title;
title=InterpretImageProperties(resource_info->image_info,
- image_list[scene],resource_info->title);
+ image_list[scene],resource_info->title,exception);
(void) CopyMagickString(windows->image.name,title,MaxTextExtent);
title=DestroyString(title);
}
image=image_list[0];
state=(MagickStatusType) (ForwardAnimationState | RepeatAnimationState);
(void) XMagickCommand(display,resource_info,windows,PlayCommand,&images,
- &state);
+ &state,exception);
do
{
if (XEventsQueued(display,QueuedAfterFlush) == 0)
*title;
title=InterpretImageProperties(resource_info->image_info,
- image,resource_info->title);
+ image,resource_info->title,exception);
(void) CopyMagickString(windows->image.name,title,
MaxTextExtent);
title=DestroyString(title);
}
if (command_type != NullCommand)
nexus=XMagickCommand(display,resource_info,windows,
- command_type,&image,&state);
+ command_type,&image,&state,exception);
continue;
}
switch (event.type)
(void) CopyMagickString(resource_info->image_info->filename,
((char *) data)+5,MaxTextExtent);
}
- nexus=ReadImage(resource_info->image_info,&image->exception);
- CatchException(&image->exception);
+ nexus=ReadImage(resource_info->image_info,exception);
+ CatchException(exception);
if (nexus != (Image *) NULL)
state|=ExitState;
(void) XFree((void *) data);
}
if (command_type != NullCommand)
nexus=XMagickCommand(display,resource_info,windows,
- command_type,&image,&state);
+ command_type,&image,&state,exception);
break;
}
case KeyRelease:
{
if (LocaleCompare(display_image->filename,"LOGO") == 0)
nexus=XMagickCommand(display,resource_info,windows,
- OpenCommand,&image,&state);
+ OpenCommand,&image,&state,exception);
else
state|=ExitState;
}
Create an icon image.
*/
XMakeStandardColormap(display,icon_visual,icon_resources,
- display_image,icon_map,icon_pixel);
+ display_image,icon_map,icon_pixel,exception);
(void) XMakeImage(display,icon_resources,&windows->icon,
- display_image,windows->icon.width,windows->icon.height);
+ display_image,windows->icon.width,windows->icon.height,
+ exception);
(void) XSetWindowBackgroundPixmap(display,windows->icon.id,
windows->icon.pixmap);
(void) XClearWindow(display,windows->icon.id);
break;
(void) CopyMagickString(resource_info->image_info->filename,
(char *) data,MaxTextExtent);
- nexus=ReadImage(resource_info->image_info,&image->exception);
- CatchException(&image->exception);
+ nexus=ReadImage(resource_info->image_info,exception);
+ CatchException(exception);
if (nexus != (Image *) NULL)
state|=ExitState;
(void) XFree((void *) data);
{
if (map_info->colormap == icon_map->colormap)
XConfigureImageColormap(display,resource_info,windows,
- display_image);
+ display_image,exception);
(void) XFreeStandardColormap(display,icon_visual,icon_map,
icon_pixel);
windows->icon.mapped=MagickFalse;
(void) directory;
status=chdir(resource_info->home_directory);
if (status == -1)
- (void) ThrowMagickException(&images->exception,GetMagickModule(),
- FileOpenError,"UnableToOpenFile","%s",resource_info->home_directory);
+ (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
+ "UnableToOpenFile","%s",resource_info->home_directory);
return(nexus);
}
\f
% The format of the XSaveImage method is:
%
% MagickBooleanType XSaveImage(Display *display,
-% XResourceInfo *resource_info,XWindows *windows,Image *image)
+% XResourceInfo *resource_info,XWindows *windows,Image *image,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
*/
static MagickBooleanType XSaveImage(Display *display,
- XResourceInfo *resource_info,XWindows *windows,Image *image)
+ XResourceInfo *resource_info,XWindows *windows,Image *image,
+ ExceptionInfo *exception)
{
char
filename[MaxTextExtent];
GetPathComponent(image->filename,TailPath,filename);
status=chdir(path);
if (status == -1)
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- FileOpenError,"UnableToOpenFile","%s",path);
+ (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
+ "UnableToOpenFile","%s",path);
}
XFileBrowserWidget(display,windows,"Save",filename);
if (*filename == '\0')
}
image_info=CloneImageInfo(resource_info->image_info);
(void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
- (void) SetImageInfo(image_info,1,&image->exception);
+ (void) SetImageInfo(image_info,1,exception);
if ((LocaleCompare(image_info->magick,"JPEG") == 0) ||
(LocaleCompare(image_info->magick,"JPG") == 0))
{
Write image.
*/
image=GetFirstImageInList(image);
- status=WriteImages(image_info,image,filename,&image->exception);
+ status=WriteImages(image_info,image,filename,exception);
if (status != MagickFalse)
image->taint=MagickFalse;
image_info=DestroyImageInfo(image_info);
%
% o image: the image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType AnimateImages(const ImageInfo *image_info,
- Image *image)
+ Image *image,ExceptionInfo *exception)
{
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (X11)",
- image->filename);
+ (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
+ "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image->filename);
return(MagickFalse);
}
#endif