]> granicus.if.org Git - imagemagick/blob - coders/x.c
(no commit message)
[imagemagick] / coders / x.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                                   X   X                                     %
7 %                                    X X                                      %
8 %                                     X                                       %
9 %                                    X X                                      %
10 %                                   X   X                                     %
11 %                                                                             %
12 %                                                                             %
13 %                    Read/Write Image from/to X11 Server.                     %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                John Cristy                                  %
17 %                                 July 1992                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    http://www.imagemagick.org/script/license.php                            %
27 %                                                                             %
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.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 */
38 \f
39 /*
40   Include declarations.
41 */
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/token.h"
60 #include "MagickCore/utility.h"
61 #include "MagickCore/xwindow.h"
62 #include "MagickCore/xwindow-private.h"
63 \f
64 /*
65   Forward declarations.
66 */
67 #if defined(MAGICKCORE_X11_DELEGATE)
68 static MagickBooleanType
69   WriteXImage(const ImageInfo *,Image *,ExceptionInfo *);
70 #endif
71 \f
72 #if defined(MAGICKCORE_X11_DELEGATE)
73 /*
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 %                                                                             %
76 %                                                                             %
77 %                                                                             %
78 %   R e a d X I m a g e                                                       %
79 %                                                                             %
80 %                                                                             %
81 %                                                                             %
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 %
84 %  ReadXImage() reads an image from an X window.
85 %
86 %  The format of the ReadXImage method is:
87 %
88 %      Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
89 %
90 %  A description of each parameter follows:
91 %
92 %    o image_info: the image info.
93 %
94 %    o exception: return any errors or warnings in this structure.
95 %
96 */
97 static Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
98 {
99   const char
100     *option;
101
102   XImportInfo
103     ximage_info;
104
105   (void) exception;
106   XGetImportInfo(&ximage_info);
107   option=GetImageOption(image_info,"x:screen");
108   if (option != (const char *) NULL)
109     ximage_info.screen=IsMagickTrue(option);
110   option=GetImageOption(image_info,"x:silent");
111   if (option != (const char *) NULL)
112     ximage_info.silent=IsMagickTrue(option);
113   return(XImportImage(image_info,&ximage_info,exception));
114 }
115 #endif
116 \f
117 /*
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 %                                                                             %
120 %                                                                             %
121 %                                                                             %
122 %   R e g i s t e r X I m a g e                                               %
123 %                                                                             %
124 %                                                                             %
125 %                                                                             %
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 %
128 %  RegisterXImage() adds attributes for the X image format to
129 %  the list of supported formats.  The attributes include the image format
130 %  tag, a method to read and/or write the format, whether the format
131 %  supports the saving of more than one frame to the same file or blob,
132 %  whether the format supports native in-memory I/O, and a brief
133 %  description of the format.
134 %
135 %  The format of the RegisterXImage method is:
136 %
137 %      size_t RegisterXImage(void)
138 %
139 */
140 ModuleExport size_t RegisterXImage(void)
141 {
142   MagickInfo
143     *entry;
144
145   entry=SetMagickInfo("X");
146 #if defined(MAGICKCORE_X11_DELEGATE)
147   entry->decoder=(DecodeImageHandler *) ReadXImage;
148   entry->encoder=(EncodeImageHandler *) WriteXImage;
149 #endif
150   entry->format_type=ImplicitFormatType;
151   entry->description=ConstantString("X Image");
152   entry->module=ConstantString("X");
153   (void) RegisterMagickInfo(entry);
154   return(MagickImageCoderSignature);
155 }
156 \f
157 /*
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 %                                                                             %
160 %                                                                             %
161 %                                                                             %
162 %   U n r e g i s t e r X I m a g e                                           %
163 %                                                                             %
164 %                                                                             %
165 %                                                                             %
166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 %
168 %  UnregisterXImage() removes format registrations made by the
169 %  X module from the list of supported formats.
170 %
171 %  The format of the UnregisterXImage method is:
172 %
173 %      UnregisterXImage(void)
174 %
175 */
176 ModuleExport void UnregisterXImage(void)
177 {
178   (void) UnregisterMagickInfo("X");
179 }
180 \f
181 /*
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 %                                                                             %
184 %                                                                             %
185 %                                                                             %
186 %   W r i t e X I m a g e                                                     %
187 %                                                                             %
188 %                                                                             %
189 %                                                                             %
190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 %
192 %  WriteXImage() writes an image to an X server.
193 %
194 %  The format of the WriteXImage method is:
195 %
196 %      MagickBooleanType WriteXImage(const ImageInfo *image_info,
197 %        Image *image,ExceptionInfo *exception)
198 %
199 %  A description of each parameter follows.
200 %
201 %    o image_info: the image info.
202 %
203 %    o image:  The image.
204 %
205 %    o exception: return any errors or warnings in this structure.
206 %
207 */
208 static MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image,
209   ExceptionInfo *exception)
210 {
211   return(DisplayImages(image_info,image,exception));
212 }