Home | History | Annotate | Download | only in coders
      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 %                                   Cristy                                    %
     17 %                                 July 1992                                   %
     18 %                                                                             %
     19 %                                                                             %
     20 %  Copyright 1999-2016 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 
     39 /*
     41   Include declarations.
     42 */
     43 #include "MagickCore/studio.h"
     44 #include "MagickCore/blob.h"
     45 #include "MagickCore/blob-private.h"
     46 #include "MagickCore/client.h"
     47 #include "MagickCore/display.h"
     48 #include "MagickCore/exception.h"
     49 #include "MagickCore/exception-private.h"
     50 #include "MagickCore/image.h"
     51 #include "MagickCore/image-private.h"
     52 #include "MagickCore/list.h"
     53 #include "MagickCore/magick.h"
     54 #include "MagickCore/memory_.h"
     55 #include "MagickCore/option.h"
     56 #include "MagickCore/quantum-private.h"
     57 #include "MagickCore/static.h"
     58 #include "MagickCore/string_.h"
     59 #include "MagickCore/module.h"
     60 #include "MagickCore/token.h"
     61 #include "MagickCore/utility.h"
     62 #include "MagickCore/xwindow.h"
     63 #include "MagickCore/xwindow-private.h"
     64 
     65 /*
     67   Forward declarations.
     68 */
     69 #if defined(MAGICKCORE_X11_DELEGATE)
     70 static MagickBooleanType
     71   WriteXImage(const ImageInfo *,Image *,ExceptionInfo *);
     72 #endif
     73 
     74 #if defined(MAGICKCORE_X11_DELEGATE)
     76 /*
     77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     78 %                                                                             %
     79 %                                                                             %
     80 %                                                                             %
     81 %   R e a d X I m a g e                                                       %
     82 %                                                                             %
     83 %                                                                             %
     84 %                                                                             %
     85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     86 %
     87 %  ReadXImage() reads an image from an X window.
     88 %
     89 %  The format of the ReadXImage method is:
     90 %
     91 %      Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     92 %
     93 %  A description of each parameter follows:
     94 %
     95 %    o image_info: the image info.
     96 %
     97 %    o exception: return any errors or warnings in this structure.
     98 %
     99 */
    100 static Image *ReadXImage(const ImageInfo *image_info,ExceptionInfo *exception)
    101 {
    102   XImportInfo
    103     ximage_info;
    104 
    105   (void) exception;
    106   XGetImportInfo(&ximage_info);
    107   ximage_info.screen=IsStringTrue(GetImageOption(image_info,"x:screen"));
    108   ximage_info.silent=IsStringTrue(GetImageOption(image_info,"x:silent"));
    109   return(XImportImage(image_info,&ximage_info,exception));
    110 }
    111 #endif
    112 
    113 /*
    115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    116 %                                                                             %
    117 %                                                                             %
    118 %                                                                             %
    119 %   R e g i s t e r X I m a g e                                               %
    120 %                                                                             %
    121 %                                                                             %
    122 %                                                                             %
    123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    124 %
    125 %  RegisterXImage() adds attributes for the X image format to
    126 %  the list of supported formats.  The attributes include the image format
    127 %  tag, a method to read and/or write the format, whether the format
    128 %  supports the saving of more than one frame to the same file or blob,
    129 %  whether the format supports native in-memory I/O, and a brief
    130 %  description of the format.
    131 %
    132 %  The format of the RegisterXImage method is:
    133 %
    134 %      size_t RegisterXImage(void)
    135 %
    136 */
    137 ModuleExport size_t RegisterXImage(void)
    138 {
    139   MagickInfo
    140     *entry;
    141 
    142   entry=AcquireMagickInfo("X","X","X Image");
    143 #if defined(MAGICKCORE_X11_DELEGATE)
    144   entry->decoder=(DecodeImageHandler *) ReadXImage;
    145   entry->encoder=(EncodeImageHandler *) WriteXImage;
    146 #endif
    147   entry->format_type=ImplicitFormatType;
    148   (void) RegisterMagickInfo(entry);
    149   return(MagickImageCoderSignature);
    150 }
    151 
    152 /*
    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 
    177 /*
    179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    180 %                                                                             %
    181 %                                                                             %
    182 %                                                                             %
    183 %   W r i t e X I m a g e                                                     %
    184 %                                                                             %
    185 %                                                                             %
    186 %                                                                             %
    187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    188 %
    189 %  WriteXImage() writes an image to an X server.
    190 %
    191 %  The format of the WriteXImage method is:
    192 %
    193 %      MagickBooleanType WriteXImage(const ImageInfo *image_info,
    194 %        Image *image,ExceptionInfo *exception)
    195 %
    196 %  A description of each parameter follows.
    197 %
    198 %    o image_info: the image info.
    199 %
    200 %    o image:  The image.
    201 %
    202 %    o exception: return any errors or warnings in this structure.
    203 %
    204 */
    205 static MagickBooleanType WriteXImage(const ImageInfo *image_info,Image *image,
    206   ExceptionInfo *exception)
    207 {
    208   return(DisplayImages(image_info,image,exception));
    209 }
    210