13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                   X   X                                     %
73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                    X X                                      %
83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                     X                                       %
93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                    X X                                      %
103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                   X   X                                     %
113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                    Read/Write Image from/to X11 Server.                     %
143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                              Software Design                                %
16de984cdc3631106b1cbbb8d3972b76a0fc27e8e8cristy%                                   Cristy                                    %
173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                 July 1992                                   %
183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
207ce65e7125a4e1df1a274ce373c537a9df9c16cdCristy%  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization      %
213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  dedicated to making software imaging solutions freely available.           %
223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  You may not use this file except in compliance with the License.  You may  %
243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  obtain a copy of the License at                                            %
253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    http://www.imagemagick.org/script/license.php                            %
273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  Unless required by applicable law or agreed to in writing, software        %
293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  distributed under the License is distributed on an "AS IS" BASIS,          %
303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  See the License for the specific language governing permissions and        %
323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  limitations under the License.                                             %
333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Include declarations.
413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
424c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/studio.h"
434c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/blob.h"
444c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/blob-private.h"
454c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/client.h"
464c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/display.h"
474c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception.h"
484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception-private.h"
494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image.h"
504c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image-private.h"
514c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/list.h"
524c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magick.h"
534c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/memory_.h"
544c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/option.h"
554c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantum-private.h"
564c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/static.h"
574c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/string_.h"
584c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/module.h"
59e40005d4b3d35ab5844d139731543174539453cfcristy#include "MagickCore/token.h"
604c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/utility.h"
614c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/xwindow.h"
624c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/xwindow-private.h"
633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Forward declarations.
663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_X11_DELEGATE)
683ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType
693a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristy  WriteXImage(const ImageInfo *,Image *,ExceptionInfo *);
703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_X11_DELEGATE)
733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   R e a d X I m a g e                                                       %
793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ReadXImage() reads an image from an X window.
853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ReadXImage method is:
873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
973ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  XImportInfo
1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    ximage_info;
1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) exception;
1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  XGetImportInfo(&ximage_info);
10446ad627e77911bbc8aa27ea65d4a81041808e289cristy  ximage_info.screen=IsStringTrue(GetImageOption(image_info,"x:screen"));
10546ad627e77911bbc8aa27ea65d4a81041808e289cristy  ximage_info.silent=IsStringTrue(GetImageOption(image_info,"x:silent"));
1066710d8414f0ed06e4eaf9346366be72e2b4719efcristy  return(XImportImage(image_info,&ximage_info,exception));
1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
1093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   R e g i s t e r X I m a g e                                               %
1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  RegisterXImage() adds attributes for the X image format to
1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  the list of supported formats.  The attributes include the image format
1233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  tag, a method to read and/or write the format, whether the format
1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  supports the saving of more than one frame to the same file or blob,
1253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  whether the format supports native in-memory I/O, and a brief
1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  description of the format.
1273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the RegisterXImage method is:
1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
130bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t RegisterXImage(void)
1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
133bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristyModuleExport size_t RegisterXImage(void)
1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickInfo
1363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *entry;
1373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
138cbab2d169229a0a8f2509ebff047bb9ada533348dirk  entry=AcquireMagickInfo("X","X","X Image");
1393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_X11_DELEGATE)
1403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  entry->decoder=(DecodeImageHandler *) ReadXImage;
1413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  entry->encoder=(EncodeImageHandler *) WriteXImage;
1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
143009d739511cb808de2f5899fe7e06be7350838e9cristy  entry->format_type=ImplicitFormatType;
1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) RegisterMagickInfo(entry);
1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickImageCoderSignature);
1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   U n r e g i s t e r X I m a g e                                           %
1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  UnregisterXImage() removes format registrations made by the
1603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  X module from the list of supported formats.
1613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the UnregisterXImage method is:
1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%      UnregisterXImage(void)
1653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristyModuleExport void UnregisterXImage(void)
1683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) UnregisterMagickInfo("X");
1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   W r i t e X I m a g e                                                     %
1783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  WriteXImage() writes an image to an X server.
1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the WriteXImage method is:
1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1873a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristy%      MagickBooleanType WriteXImage(const ImageInfo *image_info,
1883a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristy%        Image *image,ExceptionInfo *exception)
1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows.
1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
1933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image:  The image.
1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1963a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristy%    o exception: return any errors or warnings in this structure.
1973a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristy%
1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1993a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristystatic MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image,
2003a37efd7ece979e9c63dc8f2f2d3816bab8b1156cristy  ExceptionInfo *exception)
2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
202051718b74ad68f8584cdac01d0192974ec777f1bcristy  return(DisplayImages(image_info,image,exception));
2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
204