blob: 92d0e53bd3143416ff4b6f8fb0b8f0b98b5f769f [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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
39/*
40 Include declarations.
41*/
cristy4c08aed2011-07-01 19:47:50 +000042#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"
cristy3ed852e2009-09-05 21:47:34 +000062
63/*
64 Forward declarations.
65*/
66#if defined(MAGICKCORE_X11_DELEGATE)
67static MagickBooleanType
cristy3a37efd2011-08-28 20:31:03 +000068 WriteXImage(const ImageInfo *,Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000069#endif
70
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*/
96static 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);
cristya76607c2010-05-31 16:26:08 +0000109 option=GetImageOption(image_info,"x:silent");
110 if (option != (const char *) NULL)
111 ximage_info.silent=IsMagickTrue(option);
cristy3ed852e2009-09-05 21:47:34 +0000112 return(XImportImage(image_info,&ximage_info));
113}
114#endif
115
116/*
117%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118% %
119% %
120% %
121% R e g i s t e r X I m a g e %
122% %
123% %
124% %
125%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126%
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.
133%
134% The format of the RegisterXImage method is:
135%
cristybb503372010-05-27 20:51:26 +0000136% size_t RegisterXImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000137%
138*/
cristybb503372010-05-27 20:51:26 +0000139ModuleExport size_t RegisterXImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000140{
141 MagickInfo
142 *entry;
143
144 entry=SetMagickInfo("X");
145#if defined(MAGICKCORE_X11_DELEGATE)
146 entry->decoder=(DecodeImageHandler *) ReadXImage;
147 entry->encoder=(EncodeImageHandler *) WriteXImage;
148#endif
cristy009d7392010-07-25 22:08:41 +0000149 entry->format_type=ImplicitFormatType;
cristy3ed852e2009-09-05 21:47:34 +0000150 entry->description=ConstantString("X Image");
151 entry->module=ConstantString("X");
152 (void) RegisterMagickInfo(entry);
153 return(MagickImageCoderSignature);
154}
155
156/*
157%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158% %
159% %
160% %
161% U n r e g i s t e r X I m a g e %
162% %
163% %
164% %
165%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166%
167% UnregisterXImage() removes format registrations made by the
168% X module from the list of supported formats.
169%
170% The format of the UnregisterXImage method is:
171%
172% UnregisterXImage(void)
173%
174*/
175ModuleExport void UnregisterXImage(void)
176{
177 (void) UnregisterMagickInfo("X");
178}
179
180/*
181%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182% %
183% %
184% %
185% W r i t e X I m a g e %
186% %
187% %
188% %
189%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190%
191% WriteXImage() writes an image to an X server.
192%
193% The format of the WriteXImage method is:
194%
cristy3a37efd2011-08-28 20:31:03 +0000195% MagickBooleanType WriteXImage(const ImageInfo *image_info,
196% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000197%
198% A description of each parameter follows.
199%
200% o image_info: the image info.
201%
202% o image: The image.
203%
cristy3a37efd2011-08-28 20:31:03 +0000204% o exception: return any errors or warnings in this structure.
205%
cristy3ed852e2009-09-05 21:47:34 +0000206*/
cristy3a37efd2011-08-28 20:31:03 +0000207static MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image,
208 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000209{
210 return(DisplayImages(image_info,image));
211}