]> 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-2010 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 "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/blob-private.h"
45 #include "magick/client.h"
46 #include "magick/display.h"
47 #include "magick/exception.h"
48 #include "magick/exception-private.h"
49 #include "magick/image.h"
50 #include "magick/image-private.h"
51 #include "magick/list.h"
52 #include "magick/magick.h"
53 #include "magick/memory_.h"
54 #include "magick/option.h"
55 #include "magick/quantum-private.h"
56 #include "magick/static.h"
57 #include "magick/string_.h"
58 #include "magick/module.h"
59 #include "magick/utility.h"
60 #include "magick/xwindow.h"
61 #include "magick/xwindow-private.h"
62 \f
63 /*
64   Forward declarations.
65 */
66 #if defined(MAGICKCORE_X11_DELEGATE)
67 static MagickBooleanType
68   WriteXImage(const ImageInfo *,Image *);
69 #endif
70 \f
71 #if defined(MAGICKCORE_X11_DELEGATE)
72 /*
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %                                                                             %
75 %                                                                             %
76 %                                                                             %
77 %   R e a d X I m a g e                                                       %
78 %                                                                             %
79 %                                                                             %
80 %                                                                             %
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 %
83 %  ReadXImage() reads an image from an X window.
84 %
85 %  The format of the ReadXImage method is:
86 %
87 %      Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
88 %
89 %  A description of each parameter follows:
90 %
91 %    o image_info: the image info.
92 %
93 %    o exception: return any errors or warnings in this structure.
94 %
95 */
96 static Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
97 {
98   const char
99     *option;
100
101   XImportInfo
102     ximage_info;
103
104   (void) 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   return(XImportImage(image_info,&ximage_info));
110 }
111 #endif
112 \f
113 /*
114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
115 %                                                                             %
116 %                                                                             %
117 %                                                                             %
118 %   R e g i s t e r X I m a g e                                               %
119 %                                                                             %
120 %                                                                             %
121 %                                                                             %
122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123 %
124 %  RegisterXImage() adds attributes for the X image format to
125 %  the list of supported formats.  The attributes include the image format
126 %  tag, a method to read and/or write the format, whether the format
127 %  supports the saving of more than one frame to the same file or blob,
128 %  whether the format supports native in-memory I/O, and a brief
129 %  description of the format.
130 %
131 %  The format of the RegisterXImage method is:
132 %
133 %      size_t RegisterXImage(void)
134 %
135 */
136 ModuleExport size_t RegisterXImage(void)
137 {
138   MagickInfo
139     *entry;
140
141   entry=SetMagickInfo("X");
142 #if defined(MAGICKCORE_X11_DELEGATE)
143   entry->decoder=(DecodeImageHandler *) ReadXImage;
144   entry->encoder=(EncodeImageHandler *) WriteXImage;
145 #endif
146   entry->format_type=ExplicitFormatType;
147   entry->description=ConstantString("X Image");
148   entry->module=ConstantString("X");
149   (void) RegisterMagickInfo(entry);
150   return(MagickImageCoderSignature);
151 }
152 \f
153 /*
154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 %                                                                             %
156 %                                                                             %
157 %                                                                             %
158 %   U n r e g i s t e r X I m a g e                                           %
159 %                                                                             %
160 %                                                                             %
161 %                                                                             %
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 %
164 %  UnregisterXImage() removes format registrations made by the
165 %  X module from the list of supported formats.
166 %
167 %  The format of the UnregisterXImage method is:
168 %
169 %      UnregisterXImage(void)
170 %
171 */
172 ModuleExport void UnregisterXImage(void)
173 {
174   (void) UnregisterMagickInfo("X");
175 }
176 \f
177 /*
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 %                                                                             %
180 %                                                                             %
181 %                                                                             %
182 %   W r i t e X I m a g e                                                     %
183 %                                                                             %
184 %                                                                             %
185 %                                                                             %
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 %
188 %  WriteXImage() writes an image to an X server.
189 %
190 %  The format of the WriteXImage method is:
191 %
192 %      MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image)
193 %
194 %  A description of each parameter follows.
195 %
196 %    o image_info: the image info.
197 %
198 %    o image:  The image.
199 %
200 */
201 static MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image)
202 {
203   return(DisplayImages(image_info,image));
204 }