blob: a88e86f056b41a894410ae9e787c38dcccb2f4d3 [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 %
cristyde984cd2013-12-01 14:49:27 +000016% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000017% July 1992 %
18% %
19% %
Cristy7ce65e72015-12-12 18:03:16 -050020% Copyright 1999-2016 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"
cristye40005d2012-03-23 12:18:45 +000059#include "MagickCore/token.h"
cristy4c08aed2011-07-01 19:47:50 +000060#include "MagickCore/utility.h"
61#include "MagickCore/xwindow.h"
62#include "MagickCore/xwindow-private.h"
cristy3ed852e2009-09-05 21:47:34 +000063
64/*
65 Forward declarations.
66*/
67#if defined(MAGICKCORE_X11_DELEGATE)
68static MagickBooleanType
cristy3a37efd2011-08-28 20:31:03 +000069 WriteXImage(const ImageInfo *,Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000070#endif
71
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*/
97static Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
98{
cristy3ed852e2009-09-05 21:47:34 +000099 XImportInfo
100 ximage_info;
101
102 (void) exception;
103 XGetImportInfo(&ximage_info);
cristy46ad6272013-04-05 11:22:49 +0000104 ximage_info.screen=IsStringTrue(GetImageOption(image_info,"x:screen"));
105 ximage_info.silent=IsStringTrue(GetImageOption(image_info,"x:silent"));
cristy6710d842011-10-20 23:23:00 +0000106 return(XImportImage(image_info,&ximage_info,exception));
cristy3ed852e2009-09-05 21:47:34 +0000107}
108#endif
109
110/*
111%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112% %
113% %
114% %
115% R e g i s t e r X I m a g e %
116% %
117% %
118% %
119%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120%
121% RegisterXImage() adds attributes for the X image format to
122% the list of supported formats. The attributes include the image format
123% tag, a method to read and/or write the format, whether the format
124% supports the saving of more than one frame to the same file or blob,
125% whether the format supports native in-memory I/O, and a brief
126% description of the format.
127%
128% The format of the RegisterXImage method is:
129%
cristybb503372010-05-27 20:51:26 +0000130% size_t RegisterXImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000131%
132*/
cristybb503372010-05-27 20:51:26 +0000133ModuleExport size_t RegisterXImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000134{
135 MagickInfo
136 *entry;
137
dirkcbab2d12015-04-06 19:14:44 +0000138 entry=AcquireMagickInfo("X","X","X Image");
cristy3ed852e2009-09-05 21:47:34 +0000139#if defined(MAGICKCORE_X11_DELEGATE)
140 entry->decoder=(DecodeImageHandler *) ReadXImage;
141 entry->encoder=(EncodeImageHandler *) WriteXImage;
142#endif
cristy009d7392010-07-25 22:08:41 +0000143 entry->format_type=ImplicitFormatType;
cristy3ed852e2009-09-05 21:47:34 +0000144 (void) RegisterMagickInfo(entry);
145 return(MagickImageCoderSignature);
146}
147
148/*
149%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150% %
151% %
152% %
153% U n r e g i s t e r X I m a g e %
154% %
155% %
156% %
157%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158%
159% UnregisterXImage() removes format registrations made by the
160% X module from the list of supported formats.
161%
162% The format of the UnregisterXImage method is:
163%
164% UnregisterXImage(void)
165%
166*/
167ModuleExport void UnregisterXImage(void)
168{
169 (void) UnregisterMagickInfo("X");
170}
171
172/*
173%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174% %
175% %
176% %
177% W r i t e X I m a g e %
178% %
179% %
180% %
181%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182%
183% WriteXImage() writes an image to an X server.
184%
185% The format of the WriteXImage method is:
186%
cristy3a37efd2011-08-28 20:31:03 +0000187% MagickBooleanType WriteXImage(const ImageInfo *image_info,
188% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000189%
190% A description of each parameter follows.
191%
192% o image_info: the image info.
193%
194% o image: The image.
195%
cristy3a37efd2011-08-28 20:31:03 +0000196% o exception: return any errors or warnings in this structure.
197%
cristy3ed852e2009-09-05 21:47:34 +0000198*/
cristy3a37efd2011-08-28 20:31:03 +0000199static MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image,
200 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000201{
cristy051718b2011-08-28 22:49:25 +0000202 return(DisplayImages(image_info,image,exception));
cristy3ed852e2009-09-05 21:47:34 +0000203}