2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write Image from/to X11 Server. %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "MagickCore/studio.h"
43 #include "MagickCore/blob.h"
44 #include "MagickCore/blob-private.h"
45 #include "MagickCore/client.h"
46 #include "MagickCore/display.h"
47 #include "MagickCore/exception.h"
48 #include "MagickCore/exception-private.h"
49 #include "MagickCore/image.h"
50 #include "MagickCore/image-private.h"
51 #include "MagickCore/list.h"
52 #include "MagickCore/magick.h"
53 #include "MagickCore/memory_.h"
54 #include "MagickCore/option.h"
55 #include "MagickCore/quantum-private.h"
56 #include "MagickCore/static.h"
57 #include "MagickCore/string_.h"
58 #include "MagickCore/module.h"
59 #include "MagickCore/utility.h"
60 #include "MagickCore/xwindow.h"
61 #include "MagickCore/xwindow-private.h"
66 #if defined(MAGICKCORE_X11_DELEGATE)
67 static MagickBooleanType
68 WriteXImage(const ImageInfo *,Image *,ExceptionInfo *);
71 #if defined(MAGICKCORE_X11_DELEGATE)
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 % R e a d X I m a g e %
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 % ReadXImage() reads an image from an X window.
85 % The format of the ReadXImage method is:
87 % Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
89 % A description of each parameter follows:
91 % o image_info: the image info.
93 % o exception: return any errors or warnings in this structure.
96 static Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
105 XGetImportInfo(&ximage_info);
106 option=GetImageOption(image_info,"x:screen");
107 if (option != (const char *) NULL)
108 ximage_info.screen=IsMagickTrue(option);
109 option=GetImageOption(image_info,"x:silent");
110 if (option != (const char *) NULL)
111 ximage_info.silent=IsMagickTrue(option);
112 return(XImportImage(image_info,&ximage_info,exception));
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 % R e g i s t e r X I m a g e %
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 % RegisterXImage() adds attributes for the X image format to
128 % the list of supported formats. The attributes include the image format
129 % tag, a method to read and/or write the format, whether the format
130 % supports the saving of more than one frame to the same file or blob,
131 % whether the format supports native in-memory I/O, and a brief
132 % description of the format.
134 % The format of the RegisterXImage method is:
136 % size_t RegisterXImage(void)
139 ModuleExport size_t RegisterXImage(void)
144 entry=SetMagickInfo("X");
145 #if defined(MAGICKCORE_X11_DELEGATE)
146 entry->decoder=(DecodeImageHandler *) ReadXImage;
147 entry->encoder=(EncodeImageHandler *) WriteXImage;
149 entry->format_type=ImplicitFormatType;
150 entry->description=ConstantString("X Image");
151 entry->module=ConstantString("X");
152 (void) RegisterMagickInfo(entry);
153 return(MagickImageCoderSignature);
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 % U n r e g i s t e r X I m a g e %
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 % UnregisterXImage() removes format registrations made by the
168 % X module from the list of supported formats.
170 % The format of the UnregisterXImage method is:
172 % UnregisterXImage(void)
175 ModuleExport void UnregisterXImage(void)
177 (void) UnregisterMagickInfo("X");
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185 % W r i t e X I m a g e %
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 % WriteXImage() writes an image to an X server.
193 % The format of the WriteXImage method is:
195 % MagickBooleanType WriteXImage(const ImageInfo *image_info,
196 % Image *image,ExceptionInfo *exception)
198 % A description of each parameter follows.
200 % o image_info: the image info.
202 % o image: The image.
204 % o exception: return any errors or warnings in this structure.
207 static MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image,
208 ExceptionInfo *exception)
210 return(DisplayImages(image_info,image,exception));