xwindow.c revision 17f11b056210f082a6d0e54ac5d68e6d72fa76b2
13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X X W W IIIII N N DDDD OOO W W % 73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X X W W I NN N D D O O W W % 83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W W I N N N D D O O W W % 93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X X W W W I N NN D D O O W W W % 103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X X W W IIIII N N DDDD OOO W W % 113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickCore X11 Utility Methods % 143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Software Design % 16de984cdc3631106b1cbbb8d3972b76a0fc27e8e8cristy% Cristy % 173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% July 1992 % 183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20b56bb24a985ca4366713bcd8ffdfacbb48a98a2fcristy% Copyright 1999-2015 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/animate.h" 444c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/artifact.h" 454c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/blob.h" 464c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/cache.h" 474c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/client.h" 484c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/color.h" 494c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/color-private.h" 504c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/colormap.h" 514c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/composite.h" 52030436f8fc9854b6bb39f4d7593d9e70ff83a8cacristy#include "MagickCore/constitute.h" 534c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/display.h" 54c53413df5789700e14e1a67e6cc2716d1716a387cristy#include "MagickCore/distort.h" 554c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception.h" 564c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/exception-private.h" 574c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/geometry.h" 584c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/identify.h" 594c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image.h" 604c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/image-private.h" 614c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/list.h" 624c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/locale_.h" 634c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/log.h" 644c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/magick.h" 654c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/memory_.h" 664c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/monitor.h" 672c5fc27ae5b613b7fb9fd69c12a47b99c7d4d471cristy#include "MagickCore/nt-base-private.h" 684c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/option.h" 694c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/pixel-accessor.h" 704c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/PreRvIcccm.h" 714c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantize.h" 724c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantum.h" 734c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/quantum-private.h" 744c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/resource_.h" 754c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/resize.h" 764c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/statistic.h" 774c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/string_.h" 784c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/string-private.h" 794c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/transform.h" 8063a81879d3568083e4ee4f78ebcae2bc831cb764cristy#include "MagickCore/token.h" 814c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/utility.h" 82d1dd6e4fefa0810b9893e6ac9418f79c97c1b39acristy#include "MagickCore/utility-private.h" 834c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/widget.h" 84bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy#include "MagickCore/widget-private.h" 854c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/xwindow.h" 864c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/xwindow-private.h" 874c08aed51c5899665ade97263692328eea4af106cristy#include "MagickCore/version.h" 883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__BEOS__) 893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <OS.h> 903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_X11_DELEGATE) 923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <X11/Xproto.h> 933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <X11/Xlocale.h> 943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICK_HAVE_POLL) 953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include <sys/poll.h> 963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_MACHINE_PARAM_H) 993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy# include <machine/param.h> 1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 1013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <sys/ipc.h> 1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <sys/shm.h> 1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <X11/extensions/XShm.h> 1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 1053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <X11/extensions/shape.h> 1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy X defines. 1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 112ce70c17bb6433add2eb069515a4f3105989e0662cristy#define XBlueGamma(color) ClampToQuantum(blue_gamma == 1.0 ? (double) \ 1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (color) : ((pow(((double) QuantumScale*(color)),1.0/(double) blue_gamma)* \ 1143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantumRange))) 1154c08aed51c5899665ade97263692328eea4af106cristy#define XGammaPacket(map,color) (size_t) (map->base_pixel+ \ 1167e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy ((ScaleQuantumToShort(XRedGamma((color)->red))*map->red_max/65535L)* \ 1177e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy map->red_mult)+ \ 1187e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy ((ScaleQuantumToShort(XGreenGamma((color)->green))*map->green_max/65535L)* \ 1197e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy map->green_mult)+ \ 1207e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy ((ScaleQuantumToShort(XBlueGamma((color)->blue))*map->blue_max/65535L)* \ 1217e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy map->blue_mult)) 1224c08aed51c5899665ade97263692328eea4af106cristy#define XGammaPixel(image,map,color) (size_t) (map->base_pixel+ \ 1234c08aed51c5899665ade97263692328eea4af106cristy ((ScaleQuantumToShort(XRedGamma(GetPixelRed(image,color)))*map->red_max/65535L)* \ 1244c08aed51c5899665ade97263692328eea4af106cristy map->red_mult)+ \ 1254c08aed51c5899665ade97263692328eea4af106cristy ((ScaleQuantumToShort(XGreenGamma(GetPixelGreen(image,color)))*map->green_max/65535L)* \ 1264c08aed51c5899665ade97263692328eea4af106cristy map->green_mult)+ \ 1274c08aed51c5899665ade97263692328eea4af106cristy ((ScaleQuantumToShort(XBlueGamma(GetPixelBlue(image,color)))*map->blue_max/65535L)* \ 1284c08aed51c5899665ade97263692328eea4af106cristy map->blue_mult)) 129ce70c17bb6433add2eb069515a4f3105989e0662cristy#define XGreenGamma(color) ClampToQuantum(green_gamma == 1.0 ? (double) \ 1303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (color) : ((pow(((double) QuantumScale*(color)),1.0/(double) green_gamma)* \ 1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantumRange))) 132ce70c17bb6433add2eb069515a4f3105989e0662cristy#define XRedGamma(color) ClampToQuantum(red_gamma == 1.0 ? (double) \ 1333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (color) : ((pow(((double) QuantumScale*(color)),1.0/(double) red_gamma)* \ 1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantumRange))) 135bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy#define XStandardPixel(map,color) (size_t) (map->base_pixel+ \ 1367e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy (((color)->red*map->red_max/65535L)*map->red_mult)+ \ 1377e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy (((color)->green*map->green_max/65535L)*map->green_mult)+ \ 1387e9f233e6549b1e1856c1aa85b3f4dee8e9493facristy (((color)->blue*map->blue_max/65535L)*map->blue_mult)) 1393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define AccentuateModulate ScaleCharToQuantum(80) 1413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define HighlightModulate ScaleCharToQuantum(125) 1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define ShadowModulate ScaleCharToQuantum(135) 1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define DepthModulate ScaleCharToQuantum(185) 1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define TroughModulate ScaleCharToQuantum(110) 1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define XLIB_ILLEGAL_ACCESS 1 1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef ForgetGravity 1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef NorthWestGravity 1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef NorthGravity 1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef NorthEastGravity 1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef WestGravity 1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef CenterGravity 1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef EastGravity 1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef SouthWestGravity 1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef SouthGravity 1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef SouthEastGravity 1573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef StaticGravity 1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef index 1603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(hpux9) 1613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define XFD_SET int 1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define XFD_SET fd_set 1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 1653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Enumeration declarations. 1683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristytypedef enum 1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef DoRed 1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DoRed = 0x0001, 1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef DoGreen 1743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DoGreen = 0x0002, 1753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#undef DoBlue 1763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DoBlue = 0x0004, 1773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DoMatte = 0x0008 1783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} XColorFlags; 1793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Typedef declarations. 1823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristytypedef struct _DiversityPacket 1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Quantum 1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red, 1873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green, 1883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue; 1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned short 1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index; 1923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 193bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy count; 1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} DiversityPacket; 1963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Constant declaractions. 1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2003ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType 2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xerror_alert = MagickFalse; 2023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 2043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Method prototypes. 2053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2063ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic const char 2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *XVisualClassName(const int); 2083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 209a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristystatic double 2103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma = 1.0, 2113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma = 1.0, 2123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_gamma = 1.0; 2133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2143ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType 2153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakePixmap(Display *,const XResourceInfo *,XWindowInfo *); 2163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2173ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void 2183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeImageLSBFirst(const XResourceInfo *,const XWindowInfo *,Image *, 219e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy XImage *,XImage *,ExceptionInfo *), 2203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeImageMSBFirst(const XResourceInfo *,const XWindowInfo *,Image *, 221e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy XImage *,XImage *,ExceptionInfo *); 2223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2233ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window 2243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSelectWindow(Display *,RectangleInfo *); 2253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 2273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% D e s t r o y X R e s o u r c e s % 2323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 2353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% DestroyXResources() destroys any X resources. 2383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the DestroyXResources method is: 2403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void DestroyXResources() 2423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 2443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2463ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void DestroyXResources(void) 2473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 2493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 2503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 2523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows; 2533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowInfo 2553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *magick_windows[MaxXWindows]; 2563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 2583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 2593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DestroyXWidget(); 2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=XSetWindows((XWindows *) ~0); 2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows == (XWindows *) NULL) || (windows->display == (Display *) NULL)) 2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows=0; 2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->context); 2663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->group_leader); 2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->backdrop); 2683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->icon); 2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->image); 2703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->info); 2713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->magnify); 2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->pan); 2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->command); 2743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->widget); 2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->popup); 2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[number_windows++]=(&windows->context); 2773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_windows; i++) 2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->mapped != MagickFalse) 2803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWithdrawWindow(windows->display,magick_windows[i]->id, 2823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->screen); 2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->mapped=MagickFalse; 2843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->name != (char *) NULL) 2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->name=(char *) 2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(magick_windows[i]->name); 2883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->icon_name != (char *) NULL) 2893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->icon_name=(char *) 2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(magick_windows[i]->icon_name); 2913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->cursor != (Cursor) NULL) 2923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(windows->display,magick_windows[i]->cursor); 2943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->cursor=(Cursor) NULL; 2953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->busy_cursor != (Cursor) NULL) 2973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(windows->display,magick_windows[i]->busy_cursor); 2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->busy_cursor=(Cursor) NULL; 3003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->highlight_stipple != (Pixmap) NULL) 3023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(windows->display, 3043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->highlight_stipple); 3053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->highlight_stipple=(Pixmap) NULL; 3063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->shadow_stipple != (Pixmap) NULL) 3083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(windows->display,magick_windows[i]->shadow_stipple); 3103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->shadow_stipple=(Pixmap) NULL; 3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->ximage != (XImage *) NULL) 3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(magick_windows[i]->ximage); 3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->ximage=(XImage *) NULL; 3163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->pixmap != (Pixmap) NULL) 3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(windows->display,magick_windows[i]->pixmap); 3203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->pixmap=(Pixmap) NULL; 3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->id != (Window) NULL) 3233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDestroyWindow(windows->display,magick_windows[i]->id); 3253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->id=(Window) NULL; 3263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->destroy != MagickFalse) 3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->image != (Image *) NULL) 3303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->image=DestroyImage(magick_windows[i]->image); 3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->image=NewImageList(); 3333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->matte_pixmap != (Pixmap) NULL) 3353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(windows->display, 3373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->matte_pixmap); 3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->matte_pixmap=(Pixmap) NULL; 3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magick_windows[i]->segment_info != (void *) NULL) 3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 3443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 3453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 3463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) magick_windows[i]->segment_info; 3483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info != (XShmSegmentInfo *) NULL) 3493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[0].shmid >= 0) 3503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[0].shmaddr != NULL) 3523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[0].shmaddr); 3533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[0].shmid,IPC_RMID,0); 3543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmaddr=NULL; 3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmid=(-1); 3563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 3583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magick_windows[i]->segment_info=(void *) 3593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(magick_windows[i]->segment_info); 3603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources=(XResourceInfo *) 3633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(windows->icon_resources); 3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->icon_pixel != (XPixelInfo *) NULL) 3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 366f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (windows->icon_pixel->pixels != (unsigned long *) NULL) 367f2faecf9facdbbb14fcba373365f9f691a9658e0cristy windows->icon_pixel->pixels=(unsigned long *) 3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(windows->icon_pixel->pixels); 3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->icon_pixel->annotate_context != (GC) NULL) 3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFreeGC(windows->display,windows->icon_pixel->annotate_context); 3713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_pixel=(XPixelInfo *) 3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(windows->icon_pixel); 3733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->pixel_info != (XPixelInfo *) NULL) 3753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 376f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (windows->pixel_info->pixels != (unsigned long *) NULL) 377f2faecf9facdbbb14fcba373365f9f691a9658e0cristy windows->pixel_info->pixels=(unsigned long *) 3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(windows->pixel_info->pixels); 3793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->pixel_info->annotate_context != (GC) NULL) 3803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFreeGC(windows->display,windows->pixel_info->annotate_context); 3813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->pixel_info->widget_context != (GC) NULL) 3823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFreeGC(windows->display,windows->pixel_info->widget_context); 3833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->pixel_info->highlight_context != (GC) NULL) 3843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFreeGC(windows->display,windows->pixel_info->highlight_context); 3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info=(XPixelInfo *) 3863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(windows->pixel_info); 3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->font_info != (XFontStruct *) NULL) 3893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 3903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFreeFont(windows->display,windows->font_info); 3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->font_info=(XFontStruct *) NULL; 3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->class_hints != (XClassHint *) NULL) 3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 395c9cc4a7b1dd605daff0dd2e0b0e1c42f178871ddcristy if (windows->class_hints->res_name != (char *) NULL) 396c9cc4a7b1dd605daff0dd2e0b0e1c42f178871ddcristy windows->class_hints->res_name=DestroyString( 397c9cc4a7b1dd605daff0dd2e0b0e1c42f178871ddcristy windows->class_hints->res_name); 398c9cc4a7b1dd605daff0dd2e0b0e1c42f178871ddcristy if (windows->class_hints->res_class != (char *) NULL) 399c9cc4a7b1dd605daff0dd2e0b0e1c42f178871ddcristy windows->class_hints->res_class=DestroyString( 400c9cc4a7b1dd605daff0dd2e0b0e1c42f178871ddcristy windows->class_hints->res_class); 4013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFree(windows->class_hints); 4023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->class_hints=(XClassHint *) NULL; 4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->manager_hints != (XWMHints *) NULL) 4053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFree(windows->manager_hints); 4073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->manager_hints=(XWMHints *) NULL; 4083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->map_info != (XStandardColormap *) NULL) 4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFree(windows->map_info); 4123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->map_info=(XStandardColormap *) NULL; 4133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->icon_map != (XStandardColormap *) NULL) 4153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFree(windows->icon_map); 4173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_map=(XStandardColormap *) NULL; 4183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->visual_info != (XVisualInfo *) NULL) 4203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFree(windows->visual_info); 4223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info=(XVisualInfo *) NULL; 4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->icon_visual != (XVisualInfo *) NULL) 4253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFree(windows->icon_visual); 4273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_visual=(XVisualInfo *) NULL; 4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindows((XWindows *) NULL); 4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 4373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X A n n o t a t e I m a g e % 4383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 4413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XAnnotateImage() annotates the image with text. 4443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XAnnotateImage method is: 4463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XAnnotateImage(Display *display, 4487c3af951210f34d3f244b31f06ee291e5be8ecb7cristy% const XPixelInfo *pixel,XAnnotateInfo *annotate_info,Image *image, 4497c3af951210f34d3f244b31f06ee291e5be8ecb7cristy% ExceptionInfo *exception) 4503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 4523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 4543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 4553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 4573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_info: Specifies a pointer to a XAnnotateInfo structure. 4593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 4613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4627c3af951210f34d3f244b31f06ee291e5be8ecb7cristy% o exception: return any errors or warnings in this structure. 4637c3af951210f34d3f244b31f06ee291e5be8ecb7cristy% 4643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 465bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XAnnotateImage(Display *display, 4667c3af951210f34d3f244b31f06ee291e5be8ecb7cristy const XPixelInfo *pixel,XAnnotateInfo *annotate_info,Image *image, 4677c3af951210f34d3f244b31f06ee291e5be8ecb7cristy ExceptionInfo *exception) 4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 469c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 470c57f694b2d04975a0e501613e34368c464708c19cristy *annotate_view; 471c57f694b2d04975a0e501613e34368c464708c19cristy 4723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 4733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_context; 4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_image; 4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 4793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 4803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 4813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 482b0a657e13c4aefba39c51292005427b47277869dcristy PixelTrait 483b0a657e13c4aefba39c51292005427b47277869dcristy alpha_trait; 4843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 4863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_pixmap; 4873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth, 4903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 4913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 4923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 4943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 4973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 4983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 5003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_ximage; 5013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotated image. 5043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 5063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 5073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 5083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_info != (XAnnotateInfo *) NULL); 5093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 5103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotated pixmap. 5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 5143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth=(unsigned int) XDefaultDepth(display,XDefaultScreen(display)); 5153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_pixmap=XCreatePixmap(display,root_window,annotate_info->width, 5163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->height,depth); 5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_pixmap == (Pixmap) NULL) 5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize graphics info. 5213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.background=0; 523bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy context_values.foreground=(size_t) (~0); 5243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.font=annotate_info->font_info->fid; 525c57f694b2d04975a0e501613e34368c464708c19cristy annotate_context=XCreateGC(display,root_window,(unsigned long) 526c57f694b2d04975a0e501613e34368c464708c19cristy (GCBackground | GCFont | GCForeground),&context_values); 5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_context == (GC) NULL) 5283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Draw text to pixmap. 5313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,annotate_pixmap,annotate_context,0, 5333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) annotate_info->font_info->ascent,annotate_info->text, 5343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) strlen(annotate_info->text)); 5353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,annotate_context); 5363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotated X image. 5383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_ximage=XGetImage(display,annotate_pixmap,0,0,annotate_info->width, 5403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->height,AllPlanes,ZPixmap); 5413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_ximage == (XImage *) NULL) 5423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 5433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,annotate_pixmap); 5443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotated image. 5463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5476710d8414f0ed06e4eaf9346366be72e2b4719efcristy annotate_image=AcquireImage((ImageInfo *) NULL,exception); 5483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_image == (Image *) NULL) 5493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 5503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image->columns=annotate_info->width; 5513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image->rows=annotate_info->height; 5523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Transfer annotated X image to image. 5543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) image->columns; 5563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) image->rows; 5573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 5583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(annotate_info->geometry,&x,&y,&width,&height); 560f05d4947caf1bc27fbec041eb37c474a80c83c0bcristy (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,(ssize_t) x, 561f05d4947caf1bc27fbec041eb37c474a80c83c0bcristy (ssize_t) y,&annotate_image->background_color,exception); 5623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_info->stencil == ForegroundStencil) 5638a46d827a124555f0c48fb2368ec1bba8e079ab6cristy annotate_image->alpha_trait=BlendPixelTrait; 5646f5395df39e037392db46729f9aab05f2a9a428fcristy annotate_view=AcquireAuthenticCacheView(annotate_image,exception); 5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) annotate_image->rows; y++) 5663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 567c57f694b2d04975a0e501613e34368c464708c19cristy register int 5683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5704c08aed51c5899665ade97263692328eea4af106cristy register Quantum 571c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 5723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 573c57f694b2d04975a0e501613e34368c464708c19cristy q=GetCacheViewAuthenticPixels(annotate_view,0,(ssize_t) y, 574c57f694b2d04975a0e501613e34368c464708c19cristy annotate_image->columns,1,exception); 575acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 577c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) annotate_image->columns; x++) 5783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5794c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(annotate_image,OpaqueAlpha,q); 5803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetPixel(annotate_ximage,x,y) == 0) 5813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set this pixel to the background color. 5843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 5854c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(annotate_image,ScaleShortToQuantum( 5864c08aed51c5899665ade97263692328eea4af106cristy pixel->box_color.red),q); 5874c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(annotate_image,ScaleShortToQuantum( 5884c08aed51c5899665ade97263692328eea4af106cristy pixel->box_color.green),q); 5894c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(annotate_image,ScaleShortToQuantum( 5904c08aed51c5899665ade97263692328eea4af106cristy pixel->box_color.blue),q); 5913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((annotate_info->stencil == ForegroundStencil) || 5923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (annotate_info->stencil == OpaqueStencil)) 5934c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(annotate_image,TransparentAlpha,q); 5943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 5963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 5983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set this pixel to the pen color. 5993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6004c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(annotate_image,ScaleShortToQuantum( 6014c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.red),q); 6024c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(annotate_image,ScaleShortToQuantum( 6034c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.green),q); 6044c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(annotate_image,ScaleShortToQuantum( 6054c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.blue),q); 6063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_info->stencil == BackgroundStencil) 6074c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(annotate_image,TransparentAlpha,q); 6083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 609ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(annotate_image); 6103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 611c57f694b2d04975a0e501613e34368c464708c19cristy if (SyncCacheViewAuthenticPixels(annotate_view,exception) == MagickFalse) 6123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 614c57f694b2d04975a0e501613e34368c464708c19cristy annotate_view=DestroyCacheView(annotate_view); 6153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(annotate_ximage); 6163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine annotate geometry. 6183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(annotate_info->geometry,&x,&y,&width,&height); 6203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((width != (unsigned int) annotate_image->columns) || 6213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (height != (unsigned int) annotate_image->rows)) 6223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 6243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_geometry[MaxTextExtent]; 6253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Scale image. 6283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 629b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(image_geometry,MaxTextExtent,"%ux%u", 6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width,height); 631e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) TransformImage(&annotate_image,(char *) NULL,image_geometry, 632e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy exception); 6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_info->degrees != 0.0) 6353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 6373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *rotate_image; 6383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotations; 6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 642a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy double 6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees; 6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate image. 6473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6486710d8414f0ed06e4eaf9346366be72e2b4719efcristy rotate_image=RotateImage(annotate_image,annotate_info->degrees,exception); 6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (rotate_image == (Image *) NULL) 6503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 6513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image=DestroyImage(annotate_image); 6523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image=rotate_image; 6533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Annotation is relative to the degree of rotation. 6553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees=annotate_info->degrees; 6573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (normalized_degrees < -45.0) 6583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees+=360.0; 6593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (rotations=0; normalized_degrees > 45.0; rotations++) 6603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees-=90.0; 6613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (rotations % 4) 6623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 6653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 90 degrees. 6703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x-=(int) annotate_image->columns/2; 6723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y+=(int) annotate_image->columns/2; 6733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 6763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 180 degrees. 6793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) annotate_image->columns; 6813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 6843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 270 degrees. 6873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) annotate_image->columns/2; 6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y-(int) (annotate_image->rows-(annotate_image->columns/2)); 6903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Composite text onto the image. 6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(annotate_info->geometry,&x,&y,&width,&height); 698b0a657e13c4aefba39c51292005427b47277869dcristy alpha_trait=image->alpha_trait; 699feb3e9695150978a5d2372d3fe2f60466a7c8066cristy (void) CompositeImage(image,annotate_image, 70017f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy annotate_image->alpha_trait != UndefinedPixelTrait ? OverCompositeOp : 701b0a657e13c4aefba39c51292005427b47277869dcristy CopyCompositeOp,MagickTrue,(ssize_t) x,(ssize_t) y,exception); 702b0a657e13c4aefba39c51292005427b47277869dcristy image->alpha_trait=alpha_trait; 7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image=DestroyImage(annotate_image); 7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 7053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t F o n t % 7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestFont() returns the "best" font. "Best" is defined as a font specified 7193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% in the X resource database or a font such that the text width displayed 7203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with the font does not exceed the specified maximum width. 7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestFont method is: 7233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XFontStruct *XBestFont(Display *display, 7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XResourceInfo *resource_info,const MagickBooleanType text_font) 7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 7283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o font: XBestFont returns a pointer to a XFontStruct structure. 7303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 7353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o text_font: True is font should be mono-spaced (typewriter style). 7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic char **FontToList(char *font) 7413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **fontlist; 7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 7463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p, 7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 7513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fonts; 7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font == (char *) NULL) 7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char **) NULL); 7573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 7583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert string to an ASCII list. 7593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fonts=1U; 7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=font; *p != '\0'; p++) 7623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((*p == ':') || (*p == ';') || (*p == ',')) 7633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fonts++; 7643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist=(char **) AcquireQuantumMemory((size_t) fonts+1UL,sizeof(*fontlist)); 7653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (fontlist == (char **) NULL) 7663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 767c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed",font); 7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char **) NULL); 7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=font; 7713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) fonts; i++) 7723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (q=p; *q != '\0'; q++) 7743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((*q == ':') || (*q == ';') || (*q == ',')) 7753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 7763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist[i]=(char *) AcquireQuantumMemory((size_t) (q-p)+1UL, 7773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*fontlist[i])); 7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (fontlist[i] == (char *) NULL) 7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 780c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed",font); 7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char **) NULL); 7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(fontlist[i],p,(size_t) (q-p+1)); 7843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=q+1; 7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist[i]=(char *) NULL; 7873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(fontlist); 7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 790bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XFontStruct *XBestFont(Display *display, 7913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,const MagickBooleanType text_font) 7923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const char 7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *Fonts[]= 7953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-1", 7973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-arial-medium-r-normal--12-*-*-*-*-*-iso8859-1", 7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-15", 7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-arial-medium-r-normal--12-*-*-*-*-*-iso8859-15", 8003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*", 8013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-arial-medium-r-normal--12-*-*-*-*-*-*-*", 8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "variable", 8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "fixed", 8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL 8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 8063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *TextFonts[]= 8073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1", 8093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-15", 8103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-fixed-medium-r-normal-*-12-*-*-*-*-*-*-*", 8113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "fixed", 8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL 8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 8143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 8163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *font_name; 8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register const char 8193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **p; 8203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFontStruct 8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *font_info; 8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=(XFontStruct *) NULL; 8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_name=resource_info->font; 8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (text_font != MagickFalse) 8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_name=resource_info->text_font; 8283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((font_name != (char *) NULL) && (*font_name != '\0')) 8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 8313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **fontlist; 8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 8343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Load preferred font specified in the X resource database. 8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist=FontToList(font_name); 8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (fontlist != (char **) NULL) 8413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; fontlist[i] != (char *) NULL; i++) 8433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info == (XFontStruct *) NULL) 8453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=XLoadQueryFont(display,fontlist[i]); 8463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist[i]=DestroyString(fontlist[i]); 8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist=(char **) RelinquishMagickMemory(fontlist); 8493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info == (XFontStruct *) NULL) 851c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToLoadFont",font_name); 8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 8543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Load fonts from list of fonts until one is found. 8553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=Fonts; 8573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (text_font != MagickFalse) 8583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=TextFonts; 8593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XDisplayHeight(display,XDefaultScreen(display)) >= 748) 8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 8613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (*p != (char *) NULL) 8623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info != (XFontStruct *) NULL) 8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=XLoadQueryFont(display,(char *) *p); 8663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 8673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(font_info); 8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t I c o n S i z e % 8773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestIconSize() returns the "best" icon size. "Best" is defined as an icon 8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% size that maintains the aspect ratio of the image. If the window manager 8843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% has preferred icon sizes, one of the preferred sizes is used. 8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestIconSize method is: 8873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XBestIconSize(Display *display,XWindowInfo *window,Image *image) 8893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 8943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 8963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 898bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XBestIconSize(Display *display,XWindowInfo *window, 8993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image *image) 9003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 9023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 9033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_sizes; 9043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 905a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy double 9063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scale_factor; 9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 9093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 9103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_height, 9113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_width, 9123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 9133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 9153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 9163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XIconSize 9183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *icon_size, 9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *size_list; 9203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine if the window manager has specified preferred icon sizes. 9233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 9253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 9263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 9273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 9283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width=MaxIconSize; 9293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height=MaxIconSize; 9303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size=(XIconSize *) NULL; 9313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_sizes=0; 9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,window->screen); 9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetIconSizes(display,root_window,&size_list,&number_sizes) != 0) 9343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_sizes > 0) && (size_list != (XIconSize *) NULL)) 9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size=size_list; 9363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_size == (XIconSize *) NULL) 9373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window manager does not restrict icon size. 9403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size=XAllocIconSize(); 9423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_size == (XIconSize *) NULL) 9433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 944c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 945c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy image->filename); 9463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->min_width=1; 9493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->max_width=MaxIconSize; 9503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->min_height=1; 9513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->max_height=MaxIconSize; 9523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->width_inc=1; 9533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->height_inc=1; 9543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine aspect ratio of image. 9573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) image->columns; 9593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) image->rows; 9603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 9613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->crop_geometry) 9623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(window->crop_geometry,&i,&i,&width,&height); 9633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Look for an icon size that maintains the aspect ratio of image. 9653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 966a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy scale_factor=(double) icon_size->max_width/width; 967a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy if (scale_factor > ((double) icon_size->max_height/height)) 968a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy scale_factor=(double) icon_size->max_height/height; 9693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_width=(unsigned int) icon_size->min_width; 9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((int) icon_width < icon_size->max_width) 9713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_width >= (unsigned int) (scale_factor*width+0.5)) 9733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_width+=icon_size->width_inc; 9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_height=(unsigned int) icon_size->min_height; 9773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((int) icon_height < icon_size->max_height) 9783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_height >= (unsigned int) (scale_factor*height+0.5)) 9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 9813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_height+=icon_size->height_inc; 9823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) icon_size); 9843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width=icon_width; 9853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height=icon_height; 9863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 9873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 9893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t P i x e l % 9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestPixel() returns a pixel from an array of pixels that is closest to the 10003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% requested color. If the color array is NULL, the colors are obtained from 10013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the X server. 10023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestPixel method is: 10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XBestPixel(Display *display,const Colormap colormap,XColor *colors, 10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% unsigned int number_colors,XColor *color) 10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: XBestPixel returns the pixel value closest to the requested 10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% color. 10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 10143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 10153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colormap: Specifies the ID of the X server colormap. 10173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colors: Specifies an array of XColor structures. 10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o number_colors: Specifies the number of XColor structures in the 10213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% color definition array. 10223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o color: Specifies the desired RGB value to find in the colors array. 10243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1026bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XBestPixel(Display *display,const Colormap colormap, 10273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor *colors,unsigned int number_colors,XColor *color) 10283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 10293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 10303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy query_server; 10313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10324c08aed51c5899665ade97263692328eea4af106cristy PixelInfo 10333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 10343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1035a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy double 10363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy min_distance; 10373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1038a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy register double 10393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance; 10403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 10423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 10433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j; 10443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 10463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 10473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 10493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Find closest representation for the requested RGB color. 10503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 10513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 10523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 10533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(color != (XColor *) NULL); 10543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XAllocColor(display,colormap,color); 10553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 10563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 10573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy query_server=colors == (XColor *) NULL ? MagickTrue : MagickFalse; 10583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (query_server != MagickFalse) 10593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 10613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Read X server colormap. 10623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 10633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory(number_colors,sizeof(*colors)); 10643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 10653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1066c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 1067c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy "..."); 10683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 10693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 1071bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy colors[i].pixel=(size_t) i; 10723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_colors > 256) 10733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=256; 10743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display,colormap,colors,(int) number_colors); 10753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 1076a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy min_distance=3.0*((double) QuantumRange+1.0)*((double) 10773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantumRange+1.0); 10783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=0; 10793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 10803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1081a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel.red=colors[i].red-(double) color->red; 10823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance=pixel.red*pixel.red; 10833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (distance > min_distance) 10843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 1085a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel.green=colors[i].green-(double) color->green; 10863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance+=pixel.green*pixel.green; 10873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (distance > min_distance) 10883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 1089a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel.blue=colors[i].blue-(double) color->blue; 10903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance+=pixel.blue*pixel.blue; 10913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (distance > min_distance) 10923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 10933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy min_distance=distance; 10943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->pixel=colors[i].pixel; 10953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=i; 10963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&colors[j]); 10983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (query_server != MagickFalse) 10993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) RelinquishMagickMemory(colors); 11003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 11013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 11033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t V i s u a l I n f o % 11083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestVisualInfo() returns visual information for a visual that is the "best" 11143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the server supports. "Best" is defined as: 11153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1. Restrict the visual list to those supported by the default screen. 11173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2. If a visual type is specified, restrict the visual list to those of 11193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% that type. 11203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 3. If a map type is specified, choose the visual that matches the id 11223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified by the Standard Colormap. 11233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4 From the list of visuals, choose one that can display the most 11253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% simultaneous colors. If more than one visual can display the same 11263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% number of simultaneous colors, one is chosen based on a rank. 11273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestVisualInfo method is: 11293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XVisualInfo *XBestVisualInfo(Display *display, 11313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info,XResourceInfo *resource_info) 11323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 11343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: XBestVisualInfo returns a pointer to a X11 XVisualInfo 11363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% structure. 11373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 11393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 11403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 11423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 11433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 11453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 11473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11483ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic inline int MagickMax(const int x,const int y) 11493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 11503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x > y) 11513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(x); 11523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(y); 11533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 11543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1155bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic inline size_t MagickMin(const unsigned int x, 11563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const unsigned int y) 11573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 11583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < y) 11593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(x); 11603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(y); 11613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 11623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1163bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XVisualInfo *XBestVisualInfo(Display *display, 11643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap *map_info,XResourceInfo *resource_info) 11653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 11663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define MaxStandardColormaps 7 11673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define XVisualColormapSize(visual_info) MagickMin((unsigned int) (\ 11683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass == TrueColor) || (visual_info->klass == DirectColor) ? \ 11693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->red_mask | visual_info->green_mask | visual_info->blue_mask : \ 11703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) visual_info->colormap_size),1U << visual_info->depth) 11713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 11733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_type, 11743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_type; 11753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1176c57f694b2d04975a0e501613e34368c464708c19cristy int 1177c57f694b2d04975a0e501613e34368c464708c19cristy visual_mask; 1178c57f694b2d04975a0e501613e34368c464708c19cristy 11793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 11803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 11813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11828891f9ce489d3e61399b60436ea6c62f5ed9b887cristy size_t 11838891f9ce489d3e61399b60436ea6c62f5ed9b887cristy one; 11848891f9ce489d3e61399b60436ea6c62f5ed9b887cristy 11853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static int 11863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_visuals; 11873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XVisualInfo 11893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template; 11903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualInfo 11923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_info, 11933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_list; 11943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 11963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restrict visual search by screen number. 11973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 11983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 11993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 12003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 12013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 12023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_type=resource_info->map_type; 12033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_type=resource_info->visual_type; 12043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask=VisualScreenMask; 12053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.screen=XDefaultScreen(display); 12063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.depth=XDefaultDepth(display,XDefaultScreen(display)); 12078891f9ce489d3e61399b60436ea6c62f5ed9b887cristy one=1; 12083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((resource_info->immutable != MagickFalse) && (resource_info->colors != 0)) 12098891f9ce489d3e61399b60436ea6c62f5ed9b887cristy if (resource_info->colors <= (one << (size_t) visual_template.depth)) 12103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualDepthMask; 12113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_type != (char *) NULL) 12123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restrict visual search by class or visual id. 12153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("staticgray",visual_type) == 0) 12173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=StaticGray; 12203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("grayscale",visual_type) == 0) 12233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=GrayScale; 12263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("staticcolor",visual_type) == 0) 12293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=StaticColor; 12323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("pseudocolor",visual_type) == 0) 12353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=PseudoColor; 12383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("truecolor",visual_type) == 0) 12413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=TrueColor; 12443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("directcolor",visual_type) == 0) 12473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=DirectColor; 12503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("default",visual_type) == 0) 12533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualIDMask; 12553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual( 12563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultVisual(display,XDefaultScreen(display))); 12573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (isdigit((int) ((unsigned char) *visual_type)) != 0) 12603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualIDMask; 12623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid= 12633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol(visual_type,(char **) NULL,0); 12643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 1266c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError, 12673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnrecognizedVisualSpecifier",visual_type); 12683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get all visuals that meet our criteria so far. 12713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_visuals=0; 12733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_list=XGetVisualInfo(display,visual_mask,&visual_template, 12743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_visuals); 12753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask=VisualScreenMask | VisualIDMask; 12763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_visuals == 0) || (visual_list == (XVisualInfo *) NULL)) 12773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Failed to get visual; try using the default visual. 12803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 1281c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerWarning,"UnableToGetVisual",visual_type); 12823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual(XDefaultVisual(display, 12833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultScreen(display))); 12843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_list=XGetVisualInfo(display,visual_mask,&visual_template, 12853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_visuals); 12863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_visuals == 0) || (visual_list == (XVisualInfo *) NULL)) 12873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 1288c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerWarning,"UsingDefaultVisual", 12893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualClassName(visual_list->klass)); 12903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->color_recovery=MagickFalse; 12923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((map_info != (XStandardColormap *) NULL) && (map_type != (char *) NULL)) 12933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 12953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property; 12963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 12973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 12983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_name[MaxTextExtent]; 12993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 13013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 13023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_maps; 13033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 13053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 13063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 13083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 13093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap 13113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_list; 13123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Choose a visual associated with a standard colormap. 13153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 13173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=False; 131853365c26d309f8817b58f203983b63333cc04029cristy number_maps=0; 13193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(map_type,"list") != 0) 13203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy User specified Standard Colormap. 13233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 1324b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString((char *) map_name,MaxTextExtent, 13253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_%s_MAP",map_type); 13263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy LocaleUpper(map_name); 13273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property=XInternAtom(display,(char *) map_name,MagickTrue); 13283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_property != (Atom) NULL) 13293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetRGBColormaps(display,root_window,&map_list,&number_maps, 13303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property); 13313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 13333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const char 13353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colormap[MaxStandardColormaps]= 13363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "_HP_RGB_SMOOTH_MAP_LIST", 13383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_BEST_MAP", 13393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_DEFAULT_MAP", 13403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_GRAY_MAP", 13413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_RED_MAP", 13423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_GREEN_MAP", 13433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_BLUE_MAP", 13443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 13453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Choose a standard colormap from a list. 13483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxStandardColormaps; i++) 13503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property=XInternAtom(display,(char *) colormap[i],MagickTrue); 13523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_property == (Atom) NULL) 13533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 13543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetRGBColormaps(display,root_window,&map_list,&number_maps, 13553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property); 13563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 13573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->color_recovery=i == 0 ? MagickTrue : MagickFalse; 13603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 13623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1363c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToGetStandardColormap", 13643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_type); 13653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 13663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search all Standard Colormaps and visuals for ids that match. 13693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info=map_list[0]; 13713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(PRE_R4_ICCCM) 13723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual(visual_list[0].visual); 13733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < number_maps; i++) 13743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < number_visuals; j++) 13753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_list[i].visualid == 13763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualIDFromVisual(visual_list[j].visual)) 13773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info=map_list[i]; 13793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual( 13803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_list[j].visual); 13813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->visualid != visual_template.visualid) 13843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1385c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError, 13863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToMatchVisualToStandardColormap",map_type); 13873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 13883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 13903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->colormap == (Colormap) NULL) 13913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1392c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"StandardColormapIsNotInitialized", 1393c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy map_type); 13943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 13953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) map_list); 13973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 13993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const unsigned int 14013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rank[]= 14023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StaticGray, 14043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GrayScale, 14053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StaticColor, 14063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DirectColor, 14073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TrueColor, 14083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PseudoColor 14093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 14103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualInfo 14123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 14133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 14153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pick one visual that displays the most simultaneous colors. 14163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=visual_list; 14183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=visual_list; 14193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=1; i < number_visuals; i++) 14203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 14223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XVisualColormapSize(p) > XVisualColormapSize(visual_info)) 14233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=p; 14243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 14253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XVisualColormapSize(p) == XVisualColormapSize(visual_info)) 14263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (rank[p->klass] > rank[visual_info->klass]) 14273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=p; 14283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual(visual_info->visual); 14303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) visual_list); 14323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 14333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Retrieve only one visual by its screen & id number. 14343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=XGetVisualInfo(display,visual_mask,&visual_template, 14363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_visuals); 14373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_visuals == 0) || (visual_info == (XVisualInfo *) NULL)) 14383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 14393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(visual_info); 14403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C h e c k D e f i n e C u r s o r % 14483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCheckDefineCursor() prevents cursor changes on the root window. 14543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XXCheckDefineCursor method is: 14563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCheckDefineCursor(display,window,cursor) 14583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 14603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 14623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 14633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: the window. 14653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o cursor: the cursor. 14673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1469bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate int XCheckDefineCursor(Display *display,Window window, 14703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cursor cursor) 14713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 14723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 14733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 14743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window == XRootWindow(display,XDefaultScreen(display))) 14753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 14763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(XDefineCursor(display,window,cursor)); 14773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C h e c k R e f r e s h W i n d o w s % 14853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCheckRefreshWindows() checks the X server for exposure events for a 14913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% particular window and updates the areassociated with the exposure event. 14923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XCheckRefreshWindows method is: 14943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XCheckRefreshWindows(Display *display,XWindows *windows) 14963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 14983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 15003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 15013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 15033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1505bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XCheckRefreshWindows(Display *display,XWindows *windows) 15063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 15073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 15083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id; 15093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 15113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event; 15123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 15143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 15153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 15163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDelay(display,SuspendTime); 15173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->command.id; 15183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCommandWidget(display,windows,(char const **) NULL,&event); 15203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->image.id; 15213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRefreshWindow(display,&windows->image,&event); 15233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDelay(display,SuspendTime << 1); 15243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->command.id; 15253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCommandWidget(display,windows,(char const **) NULL,&event); 15273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->image.id; 15283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRefreshWindow(display,&windows->image,&event); 15303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 15333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C l i e n t M e s s a g e % 15383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClientMessage() sends a reason to a window with XSendEvent. The reason is 15443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% initialized with a particular protocol type and atom. 15453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XClientMessage function is: 15473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClientMessage(display,window,protocol,reason,timestamp) 15493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 15513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 15533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 15543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 15563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o protocol: Specifies an atom value. 15583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o reason: Specifies an atom value which is the reason to send. 15603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o timestamp: Specifies a value of type Time. 15623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1564bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XClientMessage(Display *display,const Window window, 15653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const Atom protocol,const Atom reason,const Time timestamp) 15663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 15673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XClientMessageEvent 15683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event; 15693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 15713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.type=ClientMessage; 15723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.window=window; 15733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.message_type=protocol; 15743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.format=32; 1575c57f694b2d04975a0e501613e34368c464708c19cristy client_event.data.l[0]=(long) reason; 1576c57f694b2d04975a0e501613e34368c464708c19cristy client_event.data.l[1]=(long) timestamp; 15773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSendEvent(display,window,MagickFalse,NoEventMask,(XEvent *) &client_event); 15783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 15813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X C l i e n t W i n d o w % 15863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClientWindow() finds a window, at or below the specified window, which has 15923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% a WM_STATE property. If such a window is found, it is returned, otherwise 15933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the argument window is returned. 15943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XClientWindow function is: 15963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% client_window=XClientWindow(display,target_window) 15983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 16003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_window: XClientWindow returns a window, at or below the specified 16023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window, which has a WM_STATE property otherwise the argument 16033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% target_window is returned. 16043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 16063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 16073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o target_window: Specifies the window to find a WM_STATE property. 16093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 16113ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window XClientWindow(Display *display,Window target_window) 16123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 16133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 16143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy state, 16153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type; 16163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 16183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 16193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 16213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 16223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 16243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *data; 16253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1626f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 16273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy after, 16283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_items; 16293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 16313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window; 16323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 16343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 16353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy state=XInternAtom(display,"WM_STATE",MagickTrue); 16363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (state == (Atom) NULL) 16373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 16383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type=(Atom) NULL; 16393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowProperty(display,target_window,state,0L,0L,MagickFalse, 16403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (Atom) AnyPropertyType,&type,&format,&number_items,&after,&data); 16413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == Success) && (type != (Atom) NULL)) 16423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 16433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window=XWindowByProperty(display,target_window,state); 16443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (client_window == (Window) NULL) 16453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 16463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(client_window); 16473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 16483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 16503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1654f34a145c545cb86152ad42a787f6d5fffea6b77ccristy+ X C o m p o n e n t T e r m i n u s % 1655f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1656f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1657f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1658f34a145c545cb86152ad42a787f6d5fffea6b77ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1659f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1660f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% XComponentTerminus() destroys the module component. 1661f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1662f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% The format of the XComponentTerminus method is: 1663f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1664f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% XComponentTerminus(void) 1665f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1666f34a145c545cb86152ad42a787f6d5fffea6b77ccristy*/ 16675ff4eaf57b3cd47d0371f204f865cbba614674a0cristyMagickPrivate void XComponentTerminus(void) 1668f34a145c545cb86152ad42a787f6d5fffea6b77ccristy{ 1669f34a145c545cb86152ad42a787f6d5fffea6b77ccristy DestroyXResources(); 1670f34a145c545cb86152ad42a787f6d5fffea6b77ccristy} 1671f34a145c545cb86152ad42a787f6d5fffea6b77ccristy 1672f34a145c545cb86152ad42a787f6d5fffea6b77ccristy/* 1673f34a145c545cb86152ad42a787f6d5fffea6b77ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1674f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1675f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1676f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 16773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C o n f i g u r e I m a g e C o l o r m a p % 16783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XConfigureImageColormap() creates a new X colormap. 16843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XConfigureImageColormap method is: 16863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XConfigureImageColormap(Display *display, 16886710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XResourceInfo *resource_info,XWindows *windows,Image *image, 16896710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 16903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 16923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 16943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 16953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 16973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 16993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 17013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17026710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 17036710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 17043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1705bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XConfigureImageColormap(Display *display, 17066710d8414f0ed06e4eaf9346366be72e2b4719efcristy XResourceInfo *resource_info,XWindows *windows,Image *image, 17076710d8414f0ed06e4eaf9346366be72e2b4719efcristy ExceptionInfo *exception) 17083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 17093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 17103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 17113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 17133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Make standard colormap. 17143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 17153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetCursorState(display,windows,MagickTrue); 17163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XCheckRefreshWindows(display,windows); 17173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeStandardColormap(display,windows->visual_info,resource_info,image, 17186710d8414f0ed06e4eaf9346366be72e2b4719efcristy windows->map_info,windows->pixel_info,exception); 17193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=windows->map_info->colormap; 17203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->image.id,colormap); 17213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->command.id,colormap); 17223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->widget.id,colormap); 17233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->magnify.mapped != MagickFalse) 17243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->magnify.id,colormap); 17253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->pan.mapped != MagickFalse) 17263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->pan.id,colormap); 17273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetCursorState(display,windows,MagickFalse); 17283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XClientMessage(display,windows->image.id,windows->im_protocols, 17293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_update_colormap,CurrentTime); 17303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 17313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 17333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C o n s t r a i n W i n d o w P o s i t i o n % 17383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XConstrainWindowPosition() assures a window is positioned within the X 17443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% server boundaries. 17453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XConstrainWindowPosition method is: 17473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XConstrainWindowPosition(Display *display,XWindowInfo *window_info) 17493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 17513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 17533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 17543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window_info: Specifies a pointer to a XWindowInfo structure. 17563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1758bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XConstrainWindowPosition(Display *display, 17593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowInfo *window_info) 17603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 17613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 17623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy limit; 17633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 17653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 17663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window_info != (XWindowInfo *) NULL); 17673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy limit=XDisplayWidth(display,window_info->screen)-window_info->width; 17683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->x < 0) 17693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->x=0; 17703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 17713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->x > (int) limit) 17723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->x=(int) limit; 17733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy limit=XDisplayHeight(display,window_info->screen)-window_info->height; 17743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->y < 0) 17753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->y=0; 17763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 17773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->y > limit) 17783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->y=limit; 17793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 17803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 17823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D e l a y % 17873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDelay() suspends program execution for the number of milliseconds 17933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified. 17943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the Delay method is: 17963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1797bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy% void XDelay(Display *display,const size_t milliseconds) 17983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 18023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 18033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o milliseconds: Specifies the number of milliseconds to delay before 18053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returning. 18063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1808bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XDelay(Display *display,const size_t milliseconds) 18093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 18113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 1812a21afdefe277667f7821fa90decc1f15a167eacfcristy MagickDelay(milliseconds); 18133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 18143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 18163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D e s t r o y R e s o u r c e I n f o % 18213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDestroyResourceInfo() frees memory associated with the XResourceInfo 18273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% structure. 18283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDestroyResourceInfo method is: 18303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XDestroyResourceInfo(XResourceInfo *resource_info) 18323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 18363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 18383ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XDestroyResourceInfo(XResourceInfo *resource_info) 18393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->image_geometry != (char *) NULL) 18413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_geometry=(char *) 18423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(resource_info->image_geometry); 18433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->quantize_info != (QuantizeInfo *) NULL) 18443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info=DestroyQuantizeInfo( 18453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info); 18463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->client_name != (char *) NULL) 18473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->client_name=(char *) 18483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(resource_info->client_name); 18493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->name != (char *) NULL) 18503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->name=DestroyString(resource_info->name); 18513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(resource_info,0,sizeof(*resource_info)); 18523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 18533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 18553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D e s t r o y W i n d o w C o l o r s % 18603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDestroyWindowColors() frees X11 color resources previously saved on a 18663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window by XRetainWindowColors or programs like xsetroot. 18673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDestroyWindowColors method is: 18693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XDestroyWindowColors(Display *display,Window window) 18713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 18753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 18763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 18783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1880bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XDestroyWindowColors(Display *display,Window window) 18813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 18833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property, 18843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type; 18853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 18873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 18883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 18903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 18913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 18933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *data; 18943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1895f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 18963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy after, 18973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length; 18983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy If there are previous resources on the root window, destroy them. 19013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 19033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 19043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property=XInternAtom(display,"_XSETROOT_ID",MagickFalse); 19053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (property == (Atom) NULL) 19063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 1907c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToCreateProperty", 19083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "_XSETROOT_ID"); 19093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 19103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowProperty(display,window,property,0L,1L,MagickTrue, 19123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (Atom) AnyPropertyType,&type,&format,&length,&after,&data); 19133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != Success) 19143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 19153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((type == XA_PIXMAP) && (format == 32) && (length == 1) && (after == 0)) 19163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XKillClient(display,(XID) (*((Pixmap *) data))); 19183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDeleteProperty(display,window,property); 19193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type != None) 19213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) data); 19223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 19233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 19253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D i s p l a y I m a g e I n f o % 19303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDisplayImageInfo() displays information about an X image. 19363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDisplayImageInfo method is: 19383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XDisplayImageInfo(Display *display, 19403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XResourceInfo *resource_info,XWindows *windows,Image *undo_image, 19416710d8414f0ed06e4eaf9346366be72e2b4719efcristy% Image *image,ExceptionInfo *exception) 19423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 19443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 19463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 19473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 19493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 19513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o undo_image: the undo image. 19533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 19553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19566710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 19576710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 19583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1959bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XDisplayImageInfo(Display *display, 19603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,XWindows *windows,Image *undo_image, 19616710d8414f0ed06e4eaf9346366be72e2b4719efcristy Image *image,ExceptionInfo *exception) 19623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 19633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 19643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent], 19653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *text, 19663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **textlist; 19673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FILE 19693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *file; 19703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 19723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unique_file; 19733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1974bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 19753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 19763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1977bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 19783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_pixels; 19793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19809d314ff2c17a77996c05413c2013880387e50f0ecristy ssize_t 19819d314ff2c17a77996c05413c2013880387e50f0ecristy bytes; 19829d314ff2c17a77996c05413c2013880387e50f0ecristy 19839d314ff2c17a77996c05413c2013880387e50f0ecristy unsigned int 19849d314ff2c17a77996c05413c2013880387e50f0ecristy levels; 19859d314ff2c17a77996c05413c2013880387e50f0ecristy 19863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the X server to a file. 19883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 19903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 19913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 19923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 19933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug) 19943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 19953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy file=(FILE *) NULL; 19963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unique_file=AcquireUniqueFileResource(filename); 19973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (unique_file != -1) 19983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy file=fdopen(unique_file,"w"); 19993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((unique_file == -1) || (file == (FILE *) NULL)) 20003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XNoticeWidget(display,windows,"Unable to display image info",filename); 20023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 20033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->gamma_correct != MagickFalse) 20053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->display_gamma != (char *) NULL) 2006b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Display\n gamma: %s\n\n", 20073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->display_gamma); 20083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the X image to a file. 20103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2011b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"X\n visual: %s\n", 20123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualClassName((int) windows->image.storage_class)); 2013b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," depth: %d\n",windows->image.ximage->depth); 20143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->visual_info->colormap_size != 0) 2015b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," colormap size: %d\n", 20163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->colormap_size); 20173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->colormap== SharedColormap) 2018b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," colormap type: Shared\n"); 20193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2020b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," colormap type: Private\n"); 20211e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file," geometry: %dx%d\n", 20221e604812fad85bb96f757a2393015ae3d061c39acristy windows->image.ximage->width,windows->image.ximage->height); 20233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.crop_geometry != (char *) NULL) 20241e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file," crop geometry: %s\n", 20251e604812fad85bb96f757a2393015ae3d061c39acristy windows->image.crop_geometry); 20263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.pixmap == (Pixmap) NULL) 2027b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," type: X Image\n"); 20283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2029b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," type: Pixmap\n"); 20303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.shape != MagickFalse) 2031b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," non-rectangular shape: True\n"); 20323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2033b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," non-rectangular shape: False\n"); 20343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.shared_memory != MagickFalse) 2035b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," shared memory: True\n"); 20363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2037b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," shared memory: False\n"); 2038b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"\n"); 20393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->font != (char *) NULL) 2040b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Font: %s\n\n",resource_info->font); 20413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->text_font != (char *) NULL) 2042b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Text font: %s\n\n",resource_info->text_font); 20433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the undo cache to a file. 20453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes=0; 20473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (levels=0; undo_image != (Image *) NULL; levels++) 20483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_pixels=undo_image->list->columns*undo_image->list->rows; 2050101ab708b0574518ac5715da4d3915400e9df79acristy bytes+=number_pixels*sizeof(PixelInfo); 20513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undo_image=GetPreviousImageInList(undo_image); 20523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2053b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Undo Edit Cache\n levels: %u\n",levels); 20541e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file," bytes: %.20gmb\n",(double) 20551e604812fad85bb96f757a2393015ae3d061c39acristy ((bytes+(1 << 19)) >> 20)); 2056b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," limit: %.20gmb\n\n",(double) 2057f2faecf9facdbbb14fcba373365f9f691a9658e0cristy resource_info->undo_cache); 20583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the image to a file. 20603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20616710d8414f0ed06e4eaf9346366be72e2b4719efcristy (void) IdentifyImage(image,file,MagickTrue,exception); 20623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fclose(file); 20633a5987c75c361dde2b38579f05ca961927d842fecristy text=FileToString(filename,~0UL,exception); 20643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RelinquishUniqueFileResource(filename); 20653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (text == (char *) NULL) 20663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XNoticeWidget(display,windows,"MemoryAllocationFailed", 20683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToDisplayImageInfo"); 20693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 20703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=StringToList(text); 20723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (textlist != (char **) NULL) 20733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 20753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy title[MaxTextExtent]; 20763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 20773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Display information about the image in the Text View widget. 20793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); 2081b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(title,MaxTextExtent,"Image Info: %s", 20823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 20833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextViewWidget(display,resource_info,windows,MagickTrue,title, 20843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char const **) textlist); 20853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; textlist[i] != (char *) NULL; i++) 20863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist[i]=DestroyString(textlist[i]); 20873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=(char **) RelinquishMagickMemory(textlist); 20883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy text=DestroyString(text); 20903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 20913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 20923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 20933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X D i t h e r I m a g e % 20983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 21003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 21013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDitherImage() dithers the reference image as required by the HP Color 21043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Recovery algorithm. The color values are quantized to 3 bits of red and 21053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% green, and 2 bits of blue (3/3/2) and can be used as indices into a 8-bit X 21063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% standard colormap. 21073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDitherImage method is: 21093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21106710d8414f0ed06e4eaf9346366be72e2b4719efcristy% void XDitherImage(Image *image,XImage *ximage,ExceptionInfo *exception) 21113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 21133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 21153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage: Specifies a pointer to a XImage structure; returned from 21173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 21183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21196710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 21206710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 21213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 21226710d8414f0ed06e4eaf9346366be72e2b4719efcristystatic void XDitherImage(Image *image,XImage *ximage,ExceptionInfo *exception) 21233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 21243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const short int 21253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy dither_red[2][16]= 21263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {-16, 4, -1, 11,-14, 6, -3, 9,-15, 5, -2, 10,-13, 7, -4, 8}, 21283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 15, -5, 0,-12, 13, -7, 2,-10, 14, -6, 1,-11, 12, -8, 3, -9} 21293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 21303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy dither_green[2][16]= 21313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11,-15, 7, -3, 8,-14, 4, -2, 10,-16, 6, -4, 9,-13, 5, -1}, 21333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {-12, 14, -8, 2, -9, 13, -5, 1,-11, 15, -7, 3,-10, 12, -6, 0} 21343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 21353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy dither_blue[2][16]= 21363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { -3, 9,-13, 7, -1, 11,-15, 5, -4, 8,-14, 6, -2, 10,-16, 4}, 21383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2,-10, 12, -8, 0,-12, 14, -6, 3, -9, 13, -7, 1,-11, 15, -5} 21393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 21403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2141c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 2142c57f694b2d04975a0e501613e34368c464708c19cristy *image_view; 21433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 2145c57f694b2d04975a0e501613e34368c464708c19cristy value, 21463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 21473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2148101ab708b0574518ac5715da4d3915400e9df79acristy PixelInfo 2149c57f694b2d04975a0e501613e34368c464708c19cristy color; 21503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 21523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 21533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21544c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 21553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 21563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 21583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 21593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 21603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 21613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 21633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad; 21643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2165bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register size_t 21663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 21673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 21693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *blue_map[2][16], 21703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *green_map[2][16], 21713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *red_map[2][16]; 21723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 21743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate and initialize dither maps. 21753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 21763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < 2; i++) 21773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < 16; j++) 21783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_map[i][j]=(unsigned char *) AcquireQuantumMemory(256UL, 21803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*red_map)); 21813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_map[i][j]=(unsigned char *) AcquireQuantumMemory(256UL, 21823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*green_map)); 21833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_map[i][j]=(unsigned char *) AcquireQuantumMemory(256UL, 21843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*blue_map)); 21853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_map[i][j] == (unsigned char *) NULL) || 21863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (green_map[i][j] == (unsigned char *) NULL) || 21873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_map[i][j] == (unsigned char *) NULL)) 21883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2189c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 2190c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy image->filename); 21913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 21923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 21933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 21943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 21953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize dither tables. 21963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 21973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < 2; i++) 21983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < 16; j++) 21993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < 256; x++) 22003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 22013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x-16; 22023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 48) 22033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x/2+8; 22043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value+=dither_red[i][j]; 22053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_map[i][j][x]=(unsigned char) 22063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((value < 0) ? 0 : (value > 255) ? 255 : value); 22073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x-16; 22083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 48) 22093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x/2+8; 22103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value+=dither_green[i][j]; 22113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_map[i][j][x]=(unsigned char) 22123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((value < 0) ? 0 : (value > 255) ? 255 : value); 22133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x-32; 22143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 112) 22153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x/2+24; 2216bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy value+=((size_t) dither_blue[i][j] << 1); 22173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_map[i][j][x]=(unsigned char) 22183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((value < 0) ? 0 : (value > 255) ? 255 : value); 22193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 22203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 22213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Dither image. 22223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 22233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (ximage->bytes_per_line- 2224bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ((size_t) (ximage->width*ximage->bits_per_pixel) >> 3)); 22253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 22263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=0; 22273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=ximage->data; 222846ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy image_view=AcquireVirtualCacheView(image,exception); 22293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) image->rows; y++) 22303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2231c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) y,image->columns,1, 22326710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 22334c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 22343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 22353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) image->columns; x++) 22363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2237ada285ba46bd3b79ab9321bbd1e617c6551b1e33cristy color.red=(double) ClampToQuantum((double) (red_map[i][j][ 2238e42f658533644aecb733785ffd91b286d6778deacristy (int) ScaleQuantumToChar(GetPixelRed(image,p))] << 8)); 2239ada285ba46bd3b79ab9321bbd1e617c6551b1e33cristy color.green=(double) ClampToQuantum((double) (green_map[i][j][ 2240e42f658533644aecb733785ffd91b286d6778deacristy (int) ScaleQuantumToChar(GetPixelGreen(image,p))] << 8)); 2241ada285ba46bd3b79ab9321bbd1e617c6551b1e33cristy color.blue=(double) ClampToQuantum((double) (blue_map[i][j][ 2242e42f658533644aecb733785ffd91b286d6778deacristy (int) ScaleQuantumToChar(GetPixelBlue(image,p))] << 8)); 2243bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy pixel=(size_t) (((size_t) color.red & 0xe0) | 2244bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (((size_t) color.green & 0xe0) >> 3) | 2245bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (((size_t) color.blue & 0xc0) >> 6)); 22463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(char) pixel; 2247ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(image); 22483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j++; 22493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (j == 16) 22503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=0; 22513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 22523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 22533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i++; 22543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (i == 2) 22553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 22563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2257c57f694b2d04975a0e501613e34368c464708c19cristy image_view=DestroyCacheView(image_view); 22583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 22593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free allocated memory. 22603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 22613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < 2; i++) 22623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < 16; j++) 22633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 22643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_map[i][j]=(unsigned char *) RelinquishMagickMemory(green_map[i][j]); 22653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_map[i][j]=(unsigned char *) RelinquishMagickMemory(blue_map[i][j]); 22663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_map[i][j]=(unsigned char *) RelinquishMagickMemory(red_map[i][j]); 22673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 22683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 22693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 22703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 22713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D r a w I m a g e % 22763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDrawImage() draws a line on the image. 22823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDrawImage method is: 22843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22856710d8414f0ed06e4eaf9346366be72e2b4719efcristy% MagickBooleanType XDrawImage(Display *display,const XPixelInfo *pixel, 22866710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XDrawInfo *draw_info,Image *image,ExceptionInfo *exception) 22873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 22893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 22913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 22923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 22943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: Specifies a pointer to a XDrawInfo structure. 22963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 22983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22996710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 23006710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 23013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2302bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XDrawImage(Display *display, 23036710d8414f0ed06e4eaf9346366be72e2b4719efcristy const XPixelInfo *pixel,XDrawInfo *draw_info,Image *image, 23046710d8414f0ed06e4eaf9346366be72e2b4719efcristy ExceptionInfo *exception) 23053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2306c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 2307c57f694b2d04975a0e501613e34368c464708c19cristy *draw_view; 2308c57f694b2d04975a0e501613e34368c464708c19cristy 23093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 23103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_context; 23113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 23133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *draw_image; 23143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 23163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 23173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 23183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2319b0a657e13c4aefba39c51292005427b47277869dcristy PixelTrait 2320b0a657e13c4aefba39c51292005427b47277869dcristy alpha_trait; 23213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 23233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_pixmap; 23243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 23263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth, 23273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 23283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 23293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 23313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 23323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 23343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 23353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 23373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *draw_ximage; 23383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize drawd image. 23413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 23433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 23443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info != (XDrawInfo *) NULL); 23453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 23463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 23473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 23483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize drawd pixmap. 23503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 23523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth=(unsigned int) XDefaultDepth(display,XDefaultScreen(display)); 23533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_pixmap=XCreatePixmap(display,root_window,draw_info->width, 23543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->height,depth); 23553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_pixmap == (Pixmap) NULL) 23563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 23573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize graphics info. 23593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2360bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy context_values.background=(size_t) (~0); 23613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.foreground=0; 23623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.line_width=(int) draw_info->line_width; 2363bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy draw_context=XCreateGC(display,root_window,(size_t) 23643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (GCBackground | GCForeground | GCLineWidth),&context_values); 23653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_context == (GC) NULL) 23663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 23673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Clear pixmap. 23693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillRectangle(display,draw_pixmap,draw_context,0,0,draw_info->width, 23713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->height); 23723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Draw line to pixmap. 23743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetBackground(display,draw_context,0); 2376bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (void) XSetForeground(display,draw_context,(size_t) (~0)); 2377dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy if (draw_info->stipple != (Pixmap) NULL) 2378dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy { 2379dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy (void) XSetFillStyle(display,draw_context,FillOpaqueStippled); 2380dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy (void) XSetStipple(display,draw_context,draw_info->stipple); 2381dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy } 23823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (draw_info->element) 23833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 23843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PointElement: 23853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 23863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 23873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLines(display,draw_pixmap,draw_context, 23883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->coordinate_info,(int) draw_info->number_coordinates, 23893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CoordModeOrigin); 23903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 23913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 23923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case LineElement: 23933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 23943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLine(display,draw_pixmap,draw_context,draw_info->line_info.x1, 23953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->line_info.y1,draw_info->line_info.x2, 23963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->line_info.y2); 23973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 23983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 23993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case RectangleElement: 24003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,draw_pixmap,draw_context, 24023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height); 24053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillRectangleElement: 24083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillRectangle(display,draw_pixmap,draw_context, 24103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height); 24133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case CircleElement: 24163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case EllipseElement: 24173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawArc(display,draw_pixmap,draw_context, 24193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height,0,360*64); 24223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillCircleElement: 24253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillEllipseElement: 24263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillArc(display,draw_pixmap,draw_context, 24283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height,0,360*64); 24313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PolygonElement: 24343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPoint 24363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *coordinate_info; 24373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 24383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info=draw_info->coordinate_info; 24393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLines(display,draw_pixmap,draw_context,coordinate_info, 24403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->number_coordinates,CoordModeOrigin); 24413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLine(display,draw_pixmap,draw_context, 24423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info[draw_info->number_coordinates-1].x, 24433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info[draw_info->number_coordinates-1].y, 24443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info[0].x,coordinate_info[0].y); 24453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillPolygonElement: 24483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillPolygon(display,draw_pixmap,draw_context, 24503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->coordinate_info,(int) draw_info->number_coordinates,Complex, 24513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CoordModeOrigin); 24523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,draw_context); 24563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 24573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize X image. 24583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 24593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_ximage=XGetImage(display,draw_pixmap,0,0,draw_info->width, 24603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->height,AllPlanes,ZPixmap); 24613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_ximage == (XImage *) NULL) 24623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 24633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,draw_pixmap); 24643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 24653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize draw image. 24663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 24676710d8414f0ed06e4eaf9346366be72e2b4719efcristy draw_image=AcquireImage((ImageInfo *) NULL,exception); 24683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_image == (Image *) NULL) 24693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 24703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image->columns=draw_info->width; 24713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image->rows=draw_info->height; 24723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 24733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Transfer drawn X image to image. 24743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 24753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) image->columns; 24763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) image->rows; 24773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 24783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 24793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height); 2480f05d4947caf1bc27fbec041eb37c474a80c83c0bcristy (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,(ssize_t) x, 2481f05d4947caf1bc27fbec041eb37c474a80c83c0bcristy (ssize_t) y,&draw_image->background_color,exception); 24826710d8414f0ed06e4eaf9346366be72e2b4719efcristy if (SetImageStorageClass(draw_image,DirectClass,exception) == MagickFalse) 24833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 24848a46d827a124555f0c48fb2368ec1bba8e079ab6cristy draw_image->alpha_trait=BlendPixelTrait; 24856f5395df39e037392db46729f9aab05f2a9a428fcristy draw_view=AcquireAuthenticCacheView(draw_image,exception); 24863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) draw_image->rows; y++) 24873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2488c57f694b2d04975a0e501613e34368c464708c19cristy register int 24893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 24903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 24914c08aed51c5899665ade97263692328eea4af106cristy register Quantum 2492c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 24933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2494c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(draw_view,0,(ssize_t) y,draw_image->columns, 2495c57f694b2d04975a0e501613e34368c464708c19cristy 1,exception); 2496acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 24973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 2498c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) draw_image->columns; x++) 24993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetPixel(draw_ximage,x,y) == 0) 25013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set this pixel to the background color. 25043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2505803640d20a6a664315eddfff6f8531d0c5e0871dcristy SetPixelInfoPixel(draw_image,&draw_image->background_color,q); 25067676158e6c207e287beb252c9837d565863c3328cristy SetPixelAlpha(draw_image,(Quantum) (draw_info->stencil == 25074c08aed51c5899665ade97263692328eea4af106cristy OpaqueStencil ? TransparentAlpha : OpaqueAlpha),q); 25083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 25103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set this pixel to the pen color. 25133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25144c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(draw_image,ScaleShortToQuantum( 25154c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.red),q); 25164c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(draw_image,ScaleShortToQuantum( 25174c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.green),q); 25184c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(draw_image,ScaleShortToQuantum( 25194c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.blue),q); 25204c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(draw_image,(Quantum) (draw_info->stencil == 25214c08aed51c5899665ade97263692328eea4af106cristy OpaqueStencil ? OpaqueAlpha : TransparentAlpha),q); 25223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2523ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(draw_image); 25243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2525c57f694b2d04975a0e501613e34368c464708c19cristy if (SyncCacheViewAuthenticPixels(draw_view,exception) == MagickFalse) 25263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2528c57f694b2d04975a0e501613e34368c464708c19cristy draw_view=DestroyCacheView(draw_view); 25293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(draw_ximage); 25303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine draw geometry. 25323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height); 25343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((width != (unsigned int) draw_image->columns) || 25353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (height != (unsigned int) draw_image->rows)) 25363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 25383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_geometry[MaxTextExtent]; 25393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Scale image. 25423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2543b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(image_geometry,MaxTextExtent,"%ux%u", 25443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width,height); 2545e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) TransformImage(&draw_image,(char *) NULL,image_geometry, 2546e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy exception); 25473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->degrees != 0.0) 25493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 25513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *rotate_image; 25523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 25543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotations; 25553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2556a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy double 25573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees; 25583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate image. 25613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25626710d8414f0ed06e4eaf9346366be72e2b4719efcristy rotate_image=RotateImage(draw_image,draw_info->degrees,exception); 25633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (rotate_image == (Image *) NULL) 25643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 25653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image=DestroyImage(draw_image); 25663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image=rotate_image; 25673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Annotation is relative to the degree of rotation. 25693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees=draw_info->degrees; 25713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (normalized_degrees < -45.0) 25723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees+=360.0; 25733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (rotations=0; normalized_degrees > 45.0; rotations++) 25743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees-=90.0; 25753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (rotations % 4) 25763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 25783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 25793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 25813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 90 degrees. 25843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) draw_image->columns/2; 25863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y+(int) draw_image->columns/2; 25873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 25903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 180 degrees. 25933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) draw_image->columns; 25953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 25983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 26003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 270 degrees. 26013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 26023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) draw_image->columns/2; 26033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y-(int) (draw_image->rows-(draw_image->columns/2)); 26043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 26053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 26093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Composite text onto the image. 26103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 26116f5395df39e037392db46729f9aab05f2a9a428fcristy draw_view=AcquireAuthenticCacheView(draw_image,exception); 26123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) draw_image->rows; y++) 26133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2614c57f694b2d04975a0e501613e34368c464708c19cristy register int 26153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 26163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26174c08aed51c5899665ade97263692328eea4af106cristy register Quantum 2618c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 26193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2620c57f694b2d04975a0e501613e34368c464708c19cristy q=GetCacheViewAuthenticPixels(draw_view,0,(ssize_t) y,draw_image->columns,1, 2621c57f694b2d04975a0e501613e34368c464708c19cristy exception); 2622acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 26233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 2624c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) draw_image->columns; x++) 26253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26264c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelAlpha(image,q) != TransparentAlpha) 26274c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(draw_image,OpaqueAlpha,q); 2628ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(draw_image); 26293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2630c57f694b2d04975a0e501613e34368c464708c19cristy if (SyncCacheViewAuthenticPixels(draw_view,exception) == MagickFalse) 26313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 26323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2633c57f694b2d04975a0e501613e34368c464708c19cristy draw_view=DestroyCacheView(draw_view); 26343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height); 26353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->stencil == TransparentStencil) 263639172408bad7ef2ef00a815fa9abf9979e7857cbcristy (void) CompositeImage(image,draw_image,CopyAlphaCompositeOp,MagickTrue, 2637feb3e9695150978a5d2372d3fe2f60466a7c8066cristy (ssize_t) x,(ssize_t) y,exception); 26383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 26393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2640b0a657e13c4aefba39c51292005427b47277869dcristy alpha_trait=image->alpha_trait; 264139172408bad7ef2ef00a815fa9abf9979e7857cbcristy (void) CompositeImage(image,draw_image,OverCompositeOp,MagickTrue, 2642feb3e9695150978a5d2372d3fe2f60466a7c8066cristy (ssize_t) x,(ssize_t) y,exception); 2643b0a657e13c4aefba39c51292005427b47277869dcristy image->alpha_trait=alpha_trait; 26443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image=DestroyImage(draw_image); 26463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 26473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 26483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 26503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X E r r o r % 26553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XError() ignores BadWindow errors for XQueryTree and XGetWindowAttributes, 26613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% and ignores BadDrawable errors for XGetGeometry, and ignores BadValue errors 2662bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy% for XQueryColor. It returns MagickFalse in those cases. Otherwise it 2663bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy% returns True. 26643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XError function is: 26663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2667bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy% int XError(display,error) 26683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 26703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 26723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 26733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o error: Specifies the error event. 26753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 26773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 26793ed852eea50f9d4cd633efb8c2b054b8e33c253cristyextern "C" { 26803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 26813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26823ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport int XError(Display *display,XErrorEvent *error) 26833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 26843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 26853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 26863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(error != (XErrorEvent *) NULL); 26873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xerror_alert=MagickTrue; 26883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (error->request_code) 26893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_GetGeometry: 26913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) error->error_code == BadDrawable) 26933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 26943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 26953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_GetWindowAttributes: 26973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_QueryTree: 26983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) error->error_code == BadWindow) 27003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 27013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 27023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_QueryColors: 27043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) error->error_code == BadValue) 27063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 27073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 27083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 27113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 27123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 27133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 27143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 27153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 27163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 27173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 27183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X F r e e R e s o u r c e s % 27233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XFreeResources() frees X11 resources. 27293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XFreeResources method is: 27313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XFreeResources(Display *display,XVisualInfo *visual_info, 27333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 27343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info,XWindowInfo *window_info) 27353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource_info,window_info) 27363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 27383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 27403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 27413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 27433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 27443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 27463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 27473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 27493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o font_info: Specifies a pointer to a XFontStruct structure. 27513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 27533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window_info: Specifies a pointer to a X11 XWindowInfo structure. 27553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2757bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XFreeResources(Display *display,XVisualInfo *visual_info, 27583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 27593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XResourceInfo *resource_info,XWindowInfo *window_info) 27603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 27613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 27623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 27633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 27643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info != (XWindowInfo *) NULL) 27653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 27673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free X image. 27683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 27693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->ximage != (XImage *) NULL) 27703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(window_info->ximage); 27713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id != (Window) NULL) 27723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 27743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free destroy window and free cursors. 27753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 27763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id != XRootWindow(display,visual_info->screen)) 27773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDestroyWindow(display,window_info->id); 27783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->annotate_context != (GC) NULL) 27793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,window_info->annotate_context); 27803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->highlight_context != (GC) NULL) 27813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,window_info->highlight_context); 27823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->widget_context != (GC) NULL) 27833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,window_info->widget_context); 27843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->cursor != (Cursor) NULL) 27853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window_info->cursor); 27863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->cursor=(Cursor) NULL; 27873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->busy_cursor != (Cursor) NULL) 27883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window_info->busy_cursor); 27893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->busy_cursor=(Cursor) NULL; 27903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 27933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free font. 27943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 27953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info != (XFontStruct *) NULL) 2796aafc19213cef0b96cd237edb693a33fd1a2466eacristy { 2797aafc19213cef0b96cd237edb693a33fd1a2466eacristy (void) XFreeFont(display,font_info); 2798aafc19213cef0b96cd237edb693a33fd1a2466eacristy font_info=(XFontStruct *) NULL; 2799aafc19213cef0b96cd237edb693a33fd1a2466eacristy } 28003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info != (XStandardColormap *) NULL) 28013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 28023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 28033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free X Standard Colormap. 28043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 28053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->map_type == (char *) NULL) 28063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeStandardColormap(display,visual_info,map_info,pixel); 28073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) map_info); 28083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 28093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 28103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free X visual info. 28113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 28123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info != (XVisualInfo *) NULL) 28133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) visual_info); 28143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->close_server != MagickFalse) 28153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCloseDisplay(display); 28163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 28173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 28183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 28193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X F r e e S t a n d a r d C o l o r m a p % 28243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XFreeStandardColormap() frees an X11 colormap. 28303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XFreeStandardColormap method is: 28323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XFreeStandardColormap(Display *display, 28343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XVisualInfo *visual_info,XStandardColormap *map_info, 28353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XPixelInfo *pixel) 28363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 28383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 28403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 28413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 28433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 28443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 28463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 28473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 28493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2851bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XFreeStandardColormap(Display *display, 28523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XVisualInfo *visual_info,XStandardColormap *map_info,XPixelInfo *pixel) 28533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 28543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 28553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free colormap. 28563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 28573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 28583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 28593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 28603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 28613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 28623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->colormap != (Colormap) NULL) 28633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 28643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->colormap != XDefaultColormap(display,visual_info->screen)) 28653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeColormap(display,map_info->colormap); 28663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 28673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel != (XPixelInfo *) NULL) 28683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass != TrueColor) && 28693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass != DirectColor)) 28703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeColors(display,map_info->colormap,pixel->pixels, 28713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) pixel->colors,0); 28723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 28733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=(Colormap) NULL; 28743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel != (XPixelInfo *) NULL) 28753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2876f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (pixel->pixels != (unsigned long *) NULL) 2877f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels); 2878f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) NULL; 28793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 28803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 28813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 28823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 28833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t A n n o t a t e I n f o % 28883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetAnnotateInfo() initializes the AnnotateInfo structure. 28943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetAnnotateInfo method is: 28963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetAnnotateInfo(XAnnotateInfo *annotate_info) 28983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 29003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_info: Specifies a pointer to a XAnnotateInfo structure. 29023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2904bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetAnnotateInfo(XAnnotateInfo *annotate_info) 29053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 29063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 29073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotate structure. 29083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 29093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 29103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_info != (XAnnotateInfo *) NULL); 29113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->x=0; 29123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->y=0; 29133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->width=0; 29143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->height=0; 29153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->stencil=ForegroundStencil; 29163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->degrees=0.0; 29173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->font_info=(XFontStruct *) NULL; 29183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->text=(char *) NULL; 29193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info->geometry='\0'; 29203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->previous=(XAnnotateInfo *) NULL; 29213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->next=(XAnnotateInfo *) NULL; 29223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSupportsLocale(); 29233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetLocaleModifiers(""); 29243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 29253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 29263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 29273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t M a p I n f o % 29323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetMapInfo() initializes the XStandardColormap structure. 29383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XStandardColormap method is: 29403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetMapInfo(const XVisualInfo *visual_info,const Colormap colormap, 29423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info) 29433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 29453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colormap: Specifies the ID of the X server colormap. 29473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 29493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 29503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: Specifies a pointer to a X11 XStandardColormap structure. 29523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2954bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetMapInfo(const XVisualInfo *visual_info, 29553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const Colormap colormap,XStandardColormap *map_info) 29563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 29573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 29583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize map info. 29593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 29603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 29613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 29623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 29633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=colormap; 29643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->red_max=visual_info->red_mask; 2965bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy map_info->red_mult=(size_t) (map_info->red_max != 0 ? 1 : 0); 29663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->red_max != 0) 29673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((map_info->red_max & 0x01) == 0) 29683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 29693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->red_max>>=1; 29703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->red_mult<<=1; 29713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 29723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max=visual_info->green_mask; 2973bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy map_info->green_mult=(size_t) (map_info->green_max != 0 ? 1 : 0); 29743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->green_max != 0) 29753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((map_info->green_max & 0x01) == 0) 29763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 29773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max>>=1; 29783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_mult<<=1; 29793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 29803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->blue_max=visual_info->blue_mask; 2981bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy map_info->blue_mult=(size_t) (map_info->blue_max != 0 ? 1 : 0); 29823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 29833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((map_info->blue_max & 0x01) == 0) 29843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 29853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->blue_max>>=1; 29863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->blue_mult<<=1; 29873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 29883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->base_pixel=0; 29893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 29903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 29913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 29923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t P i x e l I n f o % 29973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 30003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 3002101ab708b0574518ac5715da4d3915400e9df79acristy% XGetPixelInfo() initializes the PixelInfo structure. 30033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30044c08aed51c5899665ade97263692328eea4af106cristy% The format of the XGetPixelInfo method is: 30053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30064c08aed51c5899665ade97263692328eea4af106cristy% void XGetPixelInfo(Display *display,const XVisualInfo *visual_info, 30073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XStandardColormap *map_info,const XResourceInfo *resource_info, 30083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Image *image,XPixelInfo *pixel) 30093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pixel) 30103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 30123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 30143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 30153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 30173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 30183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 30203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 30213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 30233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 30253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 30273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 3029bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetPixelInfo(Display *display, 30303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XVisualInfo *visual_info,const XStandardColormap *map_info, 30313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,Image *image,XPixelInfo *pixel) 30323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 30333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const char 30343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *PenColors[MaxNumberPens]= 30353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 30363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#000000000000", /* black */ 30373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#00000000ffff", /* blue */ 30383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#0000ffffffff", /* cyan */ 30393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#0000ffff0000", /* green */ 30403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#bdbdbdbdbdbd", /* gray */ 30413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffff00000000", /* red */ 30423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffff0000ffff", /* magenta */ 30433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffffffff0000", /* yellow */ 30443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffffffffffff", /* white */ 30453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#bdbdbdbdbdbd", /* gray */ 30463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#bdbdbdbdbdbd" /* gray */ 30473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 30483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 30503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 30513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3052bcdf567d7dc3c69162ca349e41d43741faed2043cristy extern const char 3053bcdf567d7dc3c69162ca349e41d43741faed2043cristy BorderColor[], 3054bcdf567d7dc3c69162ca349e41d43741faed2043cristy ForegroundColor[]; 3055bcdf567d7dc3c69162ca349e41d43741faed2043cristy 3056bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 30573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 30583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 30603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 30613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 30633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy packets; 30643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 30663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize pixel info. 30673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 30683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 30693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 30703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 30713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 30723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 30733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 30743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->colors=0; 30753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image != (Image *) NULL) 30763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->storage_class == PseudoClass) 3077c57f694b2d04975a0e501613e34368c464708c19cristy pixel->colors=(ssize_t) image->colors; 30783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy packets=(unsigned int) 30793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickMax((int) pixel->colors,visual_info->colormap_size)+MaxNumberPens; 3080f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (pixel->pixels != (unsigned long *) NULL) 3081f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels); 3082f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) AcquireQuantumMemory(packets, 30833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(pixel->pixels)); 3084f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (pixel->pixels == (unsigned long *) NULL) 30853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError,"UnableToGetPixelInfo", 30863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 30873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 30883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set foreground color. 30893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 30903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=map_info->colormap; 30913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,(char *) ForegroundColor, 30923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->foreground_color); 30933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->foreground_color, 30943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->foreground_color); 30953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 3096c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer", 30973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->foreground_color); 30983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->foreground_color.pixel= 30993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardPixel(map_info,&pixel->foreground_color); 31003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->foreground_color.flags=(char) (DoRed | DoGreen | DoBlue); 31013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set background color. 31033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,"#d6d6d6d6d6d6",&pixel->background_color); 31053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->background_color, 31063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->background_color); 31073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 3108c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer", 31093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->background_color); 31103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.pixel= 31113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardPixel(map_info,&pixel->background_color); 31123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.flags=(char) (DoRed | DoGreen | DoBlue); 31133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set border color. 31153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,(char *) BorderColor, 31173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->border_color); 31183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->border_color, 31193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->border_color); 31203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 3121c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer", 31223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->border_color); 31233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->border_color.pixel=XStandardPixel(map_info,&pixel->border_color); 31243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->border_color.flags=(char) (DoRed | DoGreen | DoBlue); 31253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set matte color. 31273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color=pixel->background_color; 31293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->matte_color != (char *) NULL) 31303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 31313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Matte color is specified as a X resource or command line argument. 31333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->matte_color, 31353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->matte_color); 31363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 3137c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer", 31383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->matte_color); 31393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.pixel=XStandardPixel(map_info,&pixel->matte_color); 31403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.flags=(char) (DoRed | DoGreen | DoBlue); 31413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 31423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set highlight color. 31443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31455467fcf6dfee9d372efee47bb4eb1fb8f3e118b4cristy pixel->highlight_color.red=(unsigned short) (((double) 31463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(HighlightModulate))/65535L+ 31473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ScaleQuantumToShort((Quantum) (QuantumRange-HighlightModulate)))); 31485467fcf6dfee9d372efee47bb4eb1fb8f3e118b4cristy pixel->highlight_color.green=(unsigned short) (((double) 31493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(HighlightModulate))/65535L+ 31503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ScaleQuantumToShort((Quantum) (QuantumRange-HighlightModulate)))); 31515467fcf6dfee9d372efee47bb4eb1fb8f3e118b4cristy pixel->highlight_color.blue=(unsigned short) (((double) 31523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(HighlightModulate))/65535L+ 31533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ScaleQuantumToShort((Quantum) (QuantumRange-HighlightModulate)))); 31545467fcf6dfee9d372efee47bb4eb1fb8f3e118b4cristy pixel->highlight_color.pixel=XStandardPixel(map_info,&pixel->highlight_color); 31553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->highlight_color.flags=(char) (DoRed | DoGreen | DoBlue); 31563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set shadow color. 31583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3159a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->shadow_color.red=(unsigned short) (((double) 31603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(ShadowModulate))/65535L); 3161a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->shadow_color.green=(unsigned short) (((double) 31623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(ShadowModulate))/65535L); 3163a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->shadow_color.blue=(unsigned short) (((double) 31643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(ShadowModulate))/65535L); 31653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.pixel=XStandardPixel(map_info,&pixel->shadow_color); 31663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.flags=(char) (DoRed | DoGreen | DoBlue); 31673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set depth color. 31693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3170a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->depth_color.red=(unsigned short) (((double) 31713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(DepthModulate))/65535L); 3172a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->depth_color.green=(unsigned short) (((double) 31733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(DepthModulate))/65535L); 3174a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->depth_color.blue=(unsigned short) (((double) 31753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(DepthModulate))/65535L); 31763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.pixel=XStandardPixel(map_info,&pixel->depth_color); 31773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.flags=(char) (DoRed | DoGreen | DoBlue); 31783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set trough color. 31803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3181a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->trough_color.red=(unsigned short) (((double) 31823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(TroughModulate))/65535L); 3183a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->trough_color.green=(unsigned short) (((double) 31843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(TroughModulate))/65535L); 3185a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy pixel->trough_color.blue=(unsigned short) (((double) 31863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(TroughModulate))/65535L); 31873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.pixel=XStandardPixel(map_info,&pixel->trough_color); 31883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.flags=(char) (DoRed | DoGreen | DoBlue); 31893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set pen color. 31913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 31933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 31943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,(char *) PenColors[i], 31953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->pen_colors[i]); 31963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->pen_colors[i], 31973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->pen_colors[i]); 31983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 3199c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer", 32003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[i]); 32013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_colors[i].pixel=XStandardPixel(map_info,&pixel->pen_colors[i]); 32023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_colors[i].flags=(char) (DoRed | DoGreen | DoBlue); 32033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->box_color=pixel->background_color; 32053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_color=pixel->foreground_color; 32063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->box_index=0; 32073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_index=1; 32083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image != (Image *) NULL) 32093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 32103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((resource_info->gamma_correct != MagickFalse) && 32113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (image->gamma != 0.0)) 32123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 32133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GeometryInfo 32143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry_info; 32153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickStatusType 32173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 32183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 32203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize map relative to display and image gamma. 32213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 32223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=ParseGeometry(resource_info->display_gamma,&geometry_info); 32233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_gamma=geometry_info.rho; 32243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma=geometry_info.sigma; 32253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & SigmaValue) == 0) 32263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma=red_gamma; 32273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma=geometry_info.xi; 32283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & XiValue) == 0) 32293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma=red_gamma; 32303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_gamma*=image->gamma; 32313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma*=image->gamma; 32323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma*=image->gamma; 32333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->storage_class == PseudoClass) 32353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 32363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 32373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize pixel array for images of type PseudoClass. 32383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3239bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 32404c08aed51c5899665ade97263692328eea4af106cristy pixel->pixels[i]=XGammaPacket(map_info,image->colormap+i); 32413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 32423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[image->colors+i]=pixel->pen_colors[i].pixel; 32433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->colors+=MaxNumberPens; 32443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 32473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 32493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e C l a s s % 32543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceClass() queries the X server for the specified resource name or 32603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% class. If the resource name or class is not defined in the database, the 32613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% supplied default value is returned. 32623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceClass method is: 32643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XGetResourceClass(XrmDatabase database,const char *client_name, 32663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *keyword,char *resource_default) 32673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 32693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: Specifies a resource database; returned from 32713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmGetStringDatabase. 32723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve resource 32743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% info from the X server database. 32753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o keyword: Specifies the keyword of the value being retrieved. 32773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_default: Specifies the default value to return if the query 32793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% fails to find the specified keyword/class. 32803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 32823ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *XGetResourceClass(XrmDatabase database, 32833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *client_name,const char *keyword,char *resource_default) 32843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 32853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 32863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_class[MaxTextExtent], 32873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_name[MaxTextExtent]; 32883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static char 32903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_type; 32913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 32933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 32943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmValue 32963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value; 32973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (database == (XrmDatabase) NULL) 32993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_default); 33003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_name='\0'; 33013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_class='\0'; 33023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (keyword != (char *) NULL) 33033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 33043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 33053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c, 33063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 33073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 33093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize resource keyword and class. 33103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3311b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(resource_name,MaxTextExtent,"%s.%s", 33123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name,keyword); 33133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=(int) (*client_name); 33143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_a) && (c <= XK_z)) 33153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_a-XK_A); 33163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_agrave) && (c <= XK_odiaeresis)) 33183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_agrave-XK_Agrave); 33193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_oslash) && (c <= XK_thorn)) 33213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_oslash-XK_Ooblique); 33223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k=(int) (*keyword); 33233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((k >= XK_a) && (k <= XK_z)) 33243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k-=(XK_a-XK_A); 33253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((k >= XK_agrave) && (k <= XK_odiaeresis)) 33273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k-=(XK_agrave-XK_Agrave); 33283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((k >= XK_oslash) && (k <= XK_thorn)) 33303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k-=(XK_oslash-XK_Ooblique); 3331b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(resource_class,MaxTextExtent,"%c%s.%c%s",c, 33323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name+1,k,keyword+1); 33333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 33343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XrmGetResource(database,resource_name,resource_class,&resource_type, 33353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &resource_value); 33363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 33373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_default); 33383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_value.addr); 33393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 33403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 33423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e D a t a b a s e % 33473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceDatabase() creates a new resource database and initializes it. 33533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceDatabase method is: 33553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmDatabase XGetResourceDatabase(Display *display, 33573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *client_name) 33583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 33603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: XGetResourceDatabase() returns the database after it is 33623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% initialized. 33633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 33653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 33663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve resource 33683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% info from the X server database. 33693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 33713ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport XrmDatabase XGetResourceDatabase(Display *display, 33723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *client_name) 33733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 33743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 33753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent]; 33763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 33783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c; 33793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register const char 33813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 33823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmDatabase 33843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_database, 33853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_database; 33863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 33883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XrmDatabase) NULL); 33893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(client_name != (char *) NULL); 33903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 33913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize resource database. 33923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 33933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmInitialize(); 33943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XGetDefault(display,(char *) client_name,"dummy"); 33953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_database=XrmGetDatabase(display); 33963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 33973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Combine application database. 33983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 33993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (client_name != (char *) NULL) 34003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 34013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get basename of client. 34033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=client_name+(strlen(client_name)-1); 34053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((p > client_name) && (*p != '/')) 34063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p--; 34073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*p == '/') 34083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name=p+1; 34093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 34103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=(int) (*client_name); 34113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_a) && (c <= XK_z)) 34123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_a-XK_A); 34133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 34143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_agrave) && (c <= XK_odiaeresis)) 34153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_agrave-XK_Agrave); 34163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 34173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_oslash) && (c <= XK_thorn)) 34183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_oslash-XK_Ooblique); 34193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(X11_APPLICATION_PATH) 3420b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(filename,MaxTextExtent,"%s%c%s", 34213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy X11_APPLICATION_PATH,c,client_name+1); 34223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XrmCombineFileDatabase(filename,&resource_database,MagickFalse); 34233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 34243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XResourceManagerString(display) != (char *) NULL) 34253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 34263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Combine server database. 34283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_database=XrmGetStringDatabase(XResourceManagerString(display)); 34303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmCombineDatabase(server_database,&resource_database,MagickFalse); 34313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 34323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Merge user preferences database. 34343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(X11_PREFERENCES_PATH) 3436b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(filename,MaxTextExtent,"%s%src", 34373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy X11_PREFERENCES_PATH,client_name); 34383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandFilename(filename); 34393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XrmCombineFileDatabase(filename,&resource_database,MagickFalse); 34403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 34413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_database); 34423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 34433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 34443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 34453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e I n f o % 34503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceInfo(image_info,) initializes the ResourceInfo structure. 34563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceInfo method is: 34583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetResourceInfo(const ImageInfo *image_info,XrmDatabase database, 34603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *client_name,XResourceInfo *resource_info) 34613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 34633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: the image info. 34653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: Specifies a resource database; returned from 34673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmGetStringDatabase. 34683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve 34703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource info from the X server database. 34713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 34733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 34753ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XGetResourceInfo(const ImageInfo *image_info, 34763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmDatabase database,const char *client_name,XResourceInfo *resource_info) 34773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 34783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 347900976d8abcff7a3bc7b986b8105dde8d091dee61cristy *directory, 34803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_value; 34813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3482bcdf567d7dc3c69162ca349e41d43741faed2043cristy extern const char 3483bcdf567d7dc3c69162ca349e41d43741faed2043cristy BorderColor[], 3484bcdf567d7dc3c69162ca349e41d43741faed2043cristy ForegroundColor[]; 3485bcdf567d7dc3c69162ca349e41d43741faed2043cristy 34863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize resource info fields. 34883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 34903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 34913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(resource_info,0,sizeof(*resource_info)); 34923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->resource_database=database; 34933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info=(ImageInfo *) image_info; 34943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SetImageInfoProgressMonitor(resource_info->image_info, 34953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMagickProgressMonitor,(void *) NULL); 34963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL); 34973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->close_server=MagickTrue; 34983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->client_name=AcquireString(client_name); 34993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"backdrop", 35003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35016f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->backdrop=IsStringTrue(resource_value); 35023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->background_color=XGetResourceInstance(database,client_name, 35033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "background",(char *) "#d6d6d6d6d6d6"); 35043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->border_color=XGetResourceInstance(database,client_name, 35053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "borderColor",BorderColor); 35063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"borderWidth", 35073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "2"); 350800976d8abcff7a3bc7b986b8105dde8d091dee61cristy resource_info->border_width=(unsigned int) StringToUnsignedLong( 350900976d8abcff7a3bc7b986b8105dde8d091dee61cristy resource_value); 35103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"colormap", 35113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "shared"); 35123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->colormap=UndefinedColormap; 35133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("private",resource_value) == 0) 35143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->colormap=PrivateColormap; 35153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("shared",resource_value) == 0) 35163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->colormap=SharedColormap; 35173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->colormap == UndefinedColormap) 3518c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(OptionError,"UnrecognizedColormapType", 35193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value); 35203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name, 35213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "colorRecovery",(char *) "False"); 35226f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->color_recovery=IsStringTrue(resource_value); 35233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"confirmExit", 35243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35256f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->confirm_exit=IsStringTrue(resource_value); 35263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"confirmEdit", 35273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35286f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->confirm_edit=IsStringTrue(resource_value); 3529ba0c32599a8e592fffab86dd9b8ee367ca573c22cristy resource_value=XGetResourceClass(database,client_name,"delay",(char *) "1"); 3530e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->delay=(unsigned int) StringToUnsignedLong(resource_value); 35313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->display_gamma=XGetResourceClass(database,client_name, 35323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "displayGamma",(char *) "2.2"); 35333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"displayWarnings", 35343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 35356f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->display_warnings=IsStringTrue(resource_value); 35363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font=XGetResourceClass(database,client_name,"font", 35373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 35383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font=XGetResourceClass(database,client_name,"fontList", 35393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font); 35403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[0]=XGetResourceClass(database,client_name,"font1", 35413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "fixed"); 35423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[1]=XGetResourceClass(database,client_name,"font2", 35433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "variable"); 35443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[2]=XGetResourceClass(database,client_name,"font3", 35453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "5x8"); 35463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[3]=XGetResourceClass(database,client_name,"font4", 35473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "6x10"); 35483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[4]=XGetResourceClass(database,client_name,"font5", 35493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "7x13bold"); 35503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[5]=XGetResourceClass(database,client_name,"font6", 35513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "8x13bold"); 35523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[6]=XGetResourceClass(database,client_name,"font7", 35533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "9x15bold"); 35543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[7]=XGetResourceClass(database,client_name,"font8", 35553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "10x20"); 35563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[8]=XGetResourceClass(database,client_name,"font9", 35573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "12x24"); 35583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[9]=XGetResourceClass(database,client_name,"font0", 35593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "fixed"); 35603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[10]=XGetResourceClass(database,client_name,"font0", 35613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "fixed"); 35623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->foreground_color=XGetResourceInstance(database,client_name, 35633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "foreground",ForegroundColor); 35643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"gammaCorrect", 35658bc259be59a7cde483c27474125272a7d65c5744cristy (char *) "False"); 35666f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->gamma_correct=IsStringTrue(resource_value); 35673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_geometry=ConstantString(XGetResourceClass(database, 35683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name,"geometry",(char *) NULL)); 35693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"gravity", 35703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "Center"); 3571042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy resource_info->gravity=(GravityType) ParseCommandOption(MagickGravityOptions, 35723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickFalse,resource_value); 357300976d8abcff7a3bc7b986b8105dde8d091dee61cristy directory=getcwd(resource_info->home_directory,MaxTextExtent); 357400976d8abcff7a3bc7b986b8105dde8d091dee61cristy (void) directory; 35753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->icon_geometry=XGetResourceClass(database,client_name, 35763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "iconGeometry",(char *) NULL); 35773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"iconic", 35783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35796f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->iconic=IsStringTrue(resource_value); 35803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"immutable", 35813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy LocaleCompare(client_name,"PerlMagick") == 0 ? (char *) "True" : 35823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35836f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->immutable=IsStringTrue(resource_value); 35843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"magnify", 35853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "3"); 3586e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->magnify=(unsigned int) StringToUnsignedLong(resource_value); 35873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->map_type=XGetResourceClass(database,client_name,"map", 35883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 35893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->matte_color=XGetResourceInstance(database,client_name, 35903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "mattecolor",(char *) NULL); 35913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->name=ConstantString(XGetResourceClass(database,client_name, 35923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "name",(char *) NULL)); 35933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[0]=XGetResourceClass(database,client_name,"pen1", 35943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "black"); 35953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[1]=XGetResourceClass(database,client_name,"pen2", 35963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "blue"); 35973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[2]=XGetResourceClass(database,client_name,"pen3", 35983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "cyan"); 35993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[3]=XGetResourceClass(database,client_name,"pen4", 36003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "green"); 36013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[4]=XGetResourceClass(database,client_name,"pen5", 36023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "gray"); 36033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[5]=XGetResourceClass(database,client_name,"pen6", 36043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "red"); 36053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[6]=XGetResourceClass(database,client_name,"pen7", 36063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "magenta"); 36073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[7]=XGetResourceClass(database,client_name,"pen8", 36083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "yellow"); 36093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[8]=XGetResourceClass(database,client_name,"pen9", 36103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "white"); 36113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[9]=XGetResourceClass(database,client_name,"pen0", 36123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "gray"); 36133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[10]=XGetResourceClass(database,client_name,"pen0", 36143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "gray"); 36153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"pause",(char *) "0"); 3616e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->pause=(unsigned int) StringToUnsignedLong(resource_value); 36173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"quantum",(char *) "1"); 3618f2f2727f17ecbb23d902f70bb98f81faabc92dbdcristy resource_info->quantum=StringToLong(resource_value); 36193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->text_font=XGetResourceClass(database,client_name,(char *) 36203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "font",(char *) "fixed"); 36213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->text_font=XGetResourceClass(database,client_name, 36223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "textFontList",resource_info->text_font); 36233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->title=XGetResourceClass(database,client_name,"title", 36243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 36253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"undoCache", 362692befbd6a0f0f642bd44c58fdd32e3e073f6f141cristy (char *) "256"); 3627e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->undo_cache=(unsigned int) StringToUnsignedLong(resource_value); 36283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"update", 36293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 36306f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->update=IsStringTrue(resource_value); 36313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"usePixmap", 36323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 36336f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->use_pixmap=IsStringTrue(resource_value); 36343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"sharedMemory", 36353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 36366f2013165d72f7d8ef5f66bb9453126d88113809anthony resource_info->use_shared_memory=IsStringTrue(resource_value); 36373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->visual_type=XGetResourceClass(database,client_name,"visual", 36383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 36393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->window_group=XGetResourceClass(database,client_name, 36403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "windowGroup",(char *) NULL); 36413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->window_id=XGetResourceClass(database,client_name,"window", 36423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 36433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->write_filename=XGetResourceClass(database,client_name, 36443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "writeFilename",(char *) NULL); 36453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 36463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 36483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e I n s t a n c e % 36533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceInstance() queries the X server for the specified resource name. 36593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% If the resource name is not defined in the database, the supplied default 36603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% value is returned. 36613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceInstance method is: 36633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XGetResourceInstance(XrmDatabase database,const char *client_name, 36653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *keyword,const char *resource_default) 36663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 36683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: Specifies a resource database; returned from 36703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmGetStringDatabase. 36713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve 36733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource info from the X server database. 36743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o keyword: Specifies the keyword of the value being retrieved. 36763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_default: Specifies the default value to return if the query 36783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% fails to find the specified keyword/class. 36793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 36813ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *XGetResourceInstance(XrmDatabase database, 36823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *client_name,const char *keyword,const char *resource_default) 36833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 36843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 36853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_type, 36863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_name[MaxTextExtent]; 36873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 36893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 36903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmValue 36923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value; 36933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (database == (XrmDatabase) NULL) 36953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char *) resource_default); 36963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_name='\0'; 36973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (keyword != (char *) NULL) 3698b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(resource_name,MaxTextExtent,"%s.%s",client_name, 36993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy keyword); 37003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XrmGetResource(database,resource_name,"ImageMagick",&resource_type, 37013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &resource_value); 37023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 37033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char *) resource_default); 37043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_value.addr); 37053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 37063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 37083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t S c r e e n D e n s i t y % 37133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetScreenDensity() returns the density of the X server screen in 37193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% dots-per-inch. 37203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetScreenDensity method is: 37223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XGetScreenDensity(Display *display) 37243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 37263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o density: XGetScreenDensity() returns the density of the X screen in 37283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% dots-per-inch. 37293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 37313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 37323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 37343ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *XGetScreenDensity(Display *display) 37353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 37363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 37373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy density[MaxTextExtent]; 37383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy double 37403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_density, 37413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_density; 37423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 37443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set density as determined by screen size. 37453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 37463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_density=((((double) DisplayWidth(display,XDefaultScreen(display)))*25.4)/ 37473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((double) DisplayWidthMM(display,XDefaultScreen(display)))); 37483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_density=((((double) DisplayHeight(display,XDefaultScreen(display)))*25.4)/ 37493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((double) DisplayHeightMM(display,XDefaultScreen(display)))); 3750b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",x_density, 37518cd5b3193212b4aebce08c4e7afbb66b09778029cristy y_density); 37523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(GetPageGeometry(density)); 37533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 37543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 37563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X G e t S u b w i n d o w % 37613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetSubwindow() returns the subwindow of a window chosen the user with the 37673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pointer and a button press. 37683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetSubwindow method is: 37703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Window XGetSubwindow(Display *display,Window window,int x,int y) 37723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 37743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o subwindow: XGetSubwindow() returns NULL if no subwindow is found 37763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% otherwise the subwindow is returned. 37773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 37793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 37803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window. 37823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o x: the x coordinate of the pointer relative to the origin of the 37843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 37853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o y: the y coordinate of the pointer relative to the origin of the 37873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 37883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 37903ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window XGetSubwindow(Display *display,Window window,int x,int y) 37913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 37923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 37933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset, 37943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset; 37953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 37973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 37983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 38003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source_window, 38013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window; 38023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 38043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source_window=XRootWindow(display,XDefaultScreen(display)); 38053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window == (Window) NULL) 38063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(source_window); 38073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=window; 38083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for ( ; ; ) 38093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 38103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XTranslateCoordinates(display,source_window,window,x,y, 38113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &x_offset,&y_offset,&target_window); 38123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != True) 38133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 38143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 38153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 38163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source_window=window; 38173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=target_window; 38183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x_offset; 38193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y_offset; 38203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 38213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 38223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=window; 38233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 38243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 38253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 38273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t W i n d o w C o l o r % 38323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowColor() returns the color of a pixel interactively chosen from the 38383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X server. 38393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetWindowColor method is: 38413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XGetWindowColor(Display *display,XWindows *windows, 38436710d8414f0ed06e4eaf9346366be72e2b4719efcristy% char *name,ExceptionInfo *exception) 38443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 38463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 38483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 38493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 38513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o name: the name of the color if found in the X Color Database is 38533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned in this character string. 38543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38556710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 38566710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 38573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 3858bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XGetWindowColor(Display *display, 38596710d8414f0ed06e4eaf9346366be72e2b4719efcristy XWindows *windows,char *name,ExceptionInfo *exception) 38603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 38613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 38623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 38633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 38643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3865101ab708b0574518ac5715da4d3915400e9df79acristy PixelInfo 38663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 38673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 38693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 38703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 38723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 38733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 38753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 38763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window, 38773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window, 38783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window; 38793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 38813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color; 38823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 38843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 38853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowAttributes 38873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_attributes; 38883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 38903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Choose a pixel from the X server. 38913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 38923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 38933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(name != (char *) NULL); 38943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name); 38953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *name='\0'; 38963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=XSelectWindow(display,&crop_info); 38973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 38983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 38993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 39003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window=target_window; 39013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window != root_window) 39023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 39033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 39043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy d; 39053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get client window. 39083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetGeometry(display,target_window,&root_window,&x,&x,&d,&d,&d,&d); 39103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 39113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 39123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window=XClientWindow(display,target_window); 39133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=client_window; 39143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 39153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 39163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Verify window is viewable. 39183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowAttributes(display,target_window,&window_attributes); 39203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (window_attributes.map_state != IsViewable)) 39213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 39223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get window X image. 39243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,root_window,target_window, 39263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) crop_info.x,(int) crop_info.y,&x,&y,&child); 39273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XGetImage(display,target_window,x,y,1,1,AllPlanes,ZPixmap); 39283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 39293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 39303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=XGetPixel(ximage,0,0); 39313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 39323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Match color against the color database. 39343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColor(display,window_attributes.colormap,&color); 3936e42f658533644aecb733785ffd91b286d6778deacristy pixel.red=(double) ScaleShortToQuantum(color.red); 3937e42f658533644aecb733785ffd91b286d6778deacristy pixel.green=(double) ScaleShortToQuantum(color.green); 3938e42f658533644aecb733785ffd91b286d6778deacristy pixel.blue=(double) ScaleShortToQuantum(color.blue); 39394c08aed51c5899665ade97263692328eea4af106cristy pixel.alpha=OpaqueAlpha; 39403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) QueryColorname(windows->image.image,&pixel,X11Compliance,name, 39416710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 39423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 39433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 39443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 39463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 39473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X G e t W i n d o w I m a g e % 39513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 39553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowImage() reads an image from the target X window and returns it. 39573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowImage() optionally descends the window hierarchy and overlays the 39583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% target image with each child image in an optimized fashion. Any child 39593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window that have the same visual, colormap, and are contained by its parent 39603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% are exempted. 39613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetWindowImage method is: 39633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Image *XGetWindowImage(Display *display,const Window window, 39656710d8414f0ed06e4eaf9346366be72e2b4719efcristy% const unsigned int borders,const unsigned int level, 39666710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 39673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 39693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 39713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 39723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies the window to obtain the image from. 39743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o borders: Specifies whether borders pixels are to be saved with 39763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the image. 39773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o level: Specifies an unsigned integer representing the level of 39793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% decent in the window hierarchy. This value must be zero or one on 39803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the initial call to XGetWindowImage. A value of zero returns after 39813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% one call. A value of one causes the function to descend the window 39823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% hierarchy and overlay the target image with each subwindow image. 39833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39846710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 39856710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 39863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 39873ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *XGetWindowImage(Display *display,const Window window, 39886710d8414f0ed06e4eaf9346366be72e2b4719efcristy const unsigned int borders,const unsigned int level,ExceptionInfo *exception) 39893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 39903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct _ColormapInfo 39913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 39923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 39933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 39943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 39963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colors; 39973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy struct _ColormapInfo 39993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *next; 40003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } ColormapInfo; 40013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct _WindowInfo 40033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 40053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window, 40063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy parent; 40073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Visual 40093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual; 40103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 40123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 40133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSegment 40153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bounds; 40163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 40183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 40193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WindowInfo; 40203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 40223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_height, 40233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_width, 40243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id, 40253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset, 40263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset; 40273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40284c08aed51c5899665ade97263692328eea4af106cristy Quantum 40294c08aed51c5899665ade97263692328eea4af106cristy index; 40304c08aed51c5899665ade97263692328eea4af106cristy 40313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 40323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 40333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 40353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 40363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static ColormapInfo 40383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colormap_info = (ColormapInfo *) NULL; 40393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static int 40413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows = 0, 40423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows = 0; 40433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static WindowInfo 40453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *window_info; 40463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 40483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 40493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 40513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 40523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 40533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowAttributes 40553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_attributes; 40563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Verify window is viewable. 40593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 40603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 40613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 40623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowAttributes(display,window,&window_attributes); 40633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (window_attributes.map_state != IsViewable)) 40643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 40653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cropping rectangle is relative to root window. 40673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 40683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 40693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,window,root_window,0,0,&x_offset, 40703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &y_offset,&child); 4071bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.x=(ssize_t) x_offset; 4072bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.y=(ssize_t) y_offset; 4073bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width=(size_t) window_attributes.width; 4074bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) window_attributes.height; 40753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (borders != MagickFalse) 40763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Include border in image. 40793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 4080bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.x-=(ssize_t) window_attributes.border_width; 4081bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.y-=(ssize_t) window_attributes.border_width; 4082bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width+=(size_t) (window_attributes.border_width << 1); 4083bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height+=(size_t) (window_attributes.border_width << 1); 40843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 40853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Crop to root window. 40873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 40883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_info.x < 0) 40893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.width+=crop_info.x; 40913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x=0; 40923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 40933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_info.y < 0) 40943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.height+=crop_info.y; 40963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y=0; 40973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 40983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_width=XDisplayWidth(display,XDefaultScreen(display)); 40993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) (crop_info.x+crop_info.width) > display_width) 4100bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width=(size_t) (display_width-crop_info.x); 41013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_height=XDisplayHeight(display,XDefaultScreen(display)); 41023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) (crop_info.y+crop_info.height) > display_height) 4103bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) (display_height-crop_info.y); 41043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize window info attributes. 41063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_windows >= max_windows) 41083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate or resize window info buffer. 41113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows+=1024; 41133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info == (WindowInfo *) NULL) 41143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info=(WindowInfo *) AcquireQuantumMemory((size_t) max_windows, 41153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*window_info)); 41163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 41173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info=(WindowInfo *) ResizeQuantumMemory(window_info,(size_t) 41183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows,sizeof(*window_info)); 41193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info == (WindowInfo *) NULL) 41213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4122c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed","..."); 41233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 41243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=number_windows++; 41263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].window=window; 41273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].visual=window_attributes.visual; 41283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].colormap=window_attributes.colormap; 41293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.x1=(short) crop_info.x; 41303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.y1=(short) crop_info.y; 41313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.x2=(short) (crop_info.x+(int) crop_info.width-1); 41323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.y2=(short) (crop_info.y+(int) crop_info.height-1); 41333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x-=x_offset; 41343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y-=y_offset; 41353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].crop_info=crop_info; 41363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (level != 0) 41373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 41393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 41403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 41423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children; 41433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Descend the window hierarchy. 41463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,window,&root_window,&window_info[id].parent, 41483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &children,&number_children); 41493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < id; i++) 41503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[i].window == window_info[id].parent) && 41513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[i].visual == window_info[id].visual) && 41523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[i].colormap == window_info[id].colormap)) 41533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 415464057b049640be82cf952fa3e01282917270850ecristy if ((window_info[id].bounds.x1 < window_info[i].bounds.x1) || 415564057b049640be82cf952fa3e01282917270850ecristy (window_info[id].bounds.x2 > window_info[i].bounds.x2) || 415664057b049640be82cf952fa3e01282917270850ecristy (window_info[id].bounds.y1 < window_info[i].bounds.y1) || 415764057b049640be82cf952fa3e01282917270850ecristy (window_info[id].bounds.y2 > window_info[i].bounds.y2)) 41583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Eliminate windows not circumscribed by their parent. 41613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows--; 41633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 41643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == True) && (number_children != 0)) 41673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_children; i++) 41696710d8414f0ed06e4eaf9346366be72e2b4719efcristy (void) XGetWindowImage(display,children[i],MagickFalse,level+1, 41706710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 41713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 41723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (level <= 1) 41753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4176c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 4177c57f694b2d04975a0e501613e34368c464708c19cristy *composite_view; 4178c57f694b2d04975a0e501613e34368c464708c19cristy 41793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ColormapInfo 41803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *next; 41813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 41833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *composite_image, 41843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image; 41853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 41873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 41883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 41903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy import; 41913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 41933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 41943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 41953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41964c08aed51c5899665ade97263692328eea4af106cristy register Quantum 4197c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 41983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4199bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register size_t 42003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 42013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 42033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors; 42043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 42063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colors; 42073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 42093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 42103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get X image for each window in the list. 42133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=NewImageList(); 42153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (id=0; id < number_windows; id++) 42163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Does target window intersect top level window? 42193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 4220088af958c834f0ccc50ea4d6f8746b30df77ab12cristy import=((window_info[id].bounds.x2 >= window_info[0].bounds.x1) && 42213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.x1 <= window_info[0].bounds.x2) && 42223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y2 >= window_info[0].bounds.y1) && 42233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 <= window_info[0].bounds.y2)) ? 42243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickTrue : MagickFalse; 42253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Is target window contained by another window with the same colormap? 42273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < id; j++) 42293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual == window_info[j].visual) && 42303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].colormap == window_info[j].colormap)) 42313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 423264057b049640be82cf952fa3e01282917270850ecristy if ((window_info[id].bounds.x1 >= window_info[j].bounds.x1) && 423364057b049640be82cf952fa3e01282917270850ecristy (window_info[id].bounds.x2 <= window_info[j].bounds.x2) && 423464057b049640be82cf952fa3e01282917270850ecristy (window_info[id].bounds.y1 >= window_info[j].bounds.y1) && 423564057b049640be82cf952fa3e01282917270850ecristy (window_info[id].bounds.y2 <= window_info[j].bounds.y2)) 4236088af958c834f0ccc50ea4d6f8746b30df77ab12cristy import=MagickFalse; 42373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (import == MagickFalse) 42393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 42403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get X image. 42423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XGetImage(display,window_info[id].window,(int) 42443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].crop_info.x,(int) window_info[id].crop_info.y, 42453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) window_info[id].crop_info.width,(unsigned int) 42463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].crop_info.height,AllPlanes,ZPixmap); 42473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 42483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 42493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize window colormap. 42513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=0; 42533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) NULL; 42543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info[id].colormap != (Colormap) NULL) 42553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ColormapInfo 42573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 42583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search colormap list for window colormap. 42613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=(unsigned int) window_info[id].visual->map_entries; 42633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=colormap_info; p != (ColormapInfo *) NULL; p=p->next) 42643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p->colormap == window_info[id].colormap) 42653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 42663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p == (ColormapInfo *) NULL) 42673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get the window colormap. 42703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory(number_colors, 42723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*colors)); 42733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 42743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 42763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 42773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual->klass != DirectColor) && 42793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].visual->klass != TrueColor)) 42803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 42813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4282bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy colors[i].pixel=(size_t) i; 42833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors[i].pad='\0'; 42843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 42863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4287bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 42883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue, 42893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_bit, 42903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green, 42913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_bit, 42923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red, 42933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_bit; 42943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DirectColor or TrueColor visual. 42973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red=0; 42993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green=0; 43003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue=0; 43013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_bit=window_info[id].visual->red_mask & 43023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~(window_info[id].visual->red_mask)+1); 43033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_bit=window_info[id].visual->green_mask & 43043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~(window_info[id].visual->green_mask)+1); 43053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_bit=window_info[id].visual->blue_mask & 43063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~(window_info[id].visual->blue_mask)+1); 43073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 43083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43098891f9ce489d3e61399b60436ea6c62f5ed9b887cristy colors[i].pixel=(unsigned long) (red | green | blue); 43103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors[i].pad='\0'; 43113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red+=red_bit; 43123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (red > window_info[id].visual->red_mask) 43133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red=0; 43143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green+=green_bit; 43153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (green > window_info[id].visual->green_mask) 43163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green=0; 43173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue+=blue_bit; 43183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (blue > window_info[id].visual->blue_mask) 43193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue=0; 43203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display,window_info[id].colormap,colors, 43233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) number_colors); 43243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Append colormap to colormap list. 43263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 432773bd4a51b419e914565bdf204bf1540dc4c8ee26cristy p=(ColormapInfo *) AcquireMagickMemory(sizeof(*p)); 43283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p == (ColormapInfo *) NULL) 43293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 43303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->colormap=window_info[id].colormap; 43313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->colors=colors; 43323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->next=colormap_info; 43333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=p; 43343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=p->colors; 43363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate image structure. 43393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43406710d8414f0ed06e4eaf9346366be72e2b4719efcristy composite_image=AcquireImage((ImageInfo *) NULL,exception); 43413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (composite_image == (Image *) NULL) 43423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 43443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 43453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert X image to MIFF format. 43483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual->klass != TrueColor) && 43503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].visual->klass != DirectColor)) 43513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image->storage_class=PseudoClass; 4352bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy composite_image->columns=(size_t) ximage->width; 4353bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy composite_image->rows=(size_t) ximage->height; 435446ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy composite_view=AcquireAuthenticCacheView(composite_image,exception); 43553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (composite_image->storage_class) 43563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case DirectClass: 43583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 43593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4360bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register size_t 43613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color, 43623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index; 43633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4364bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 43653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_mask, 43663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_shift, 43673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_mask, 43683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_shift, 43693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_mask, 43703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_shift; 43713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 43723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine shift and mask for red, green, and blue. 43743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_mask=window_info[id].visual->red_mask; 43763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_shift=0; 43773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((red_mask != 0) && ((red_mask & 0x01) == 0)) 43783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_mask>>=1; 43803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_shift++; 43813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_mask=window_info[id].visual->green_mask; 43833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_shift=0; 43843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((green_mask != 0) && ((green_mask & 0x01) == 0)) 43853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_mask>>=1; 43873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_shift++; 43883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_mask=window_info[id].visual->blue_mask; 43903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_shift=0; 43913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((blue_mask != 0) && ((blue_mask & 0x01) == 0)) 43923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_mask>>=1; 43943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_shift++; 43953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert X image to DirectClass packets. 43983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_colors != 0) && 44003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].visual->klass == DirectColor)) 44013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) composite_image->rows; y++) 44023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4403c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(composite_view,0,(ssize_t) y, 44043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image->columns,1,exception); 4405acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 44063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) composite_image->columns; x++) 44083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel=XGetPixel(ximage,x,y); 44103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=(pixel >> red_shift) & red_mask; 44114c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(composite_image, 44124c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum(colors[index].red),q); 44133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=(pixel >> green_shift) & green_mask; 44144c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(composite_image, 44154c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum(colors[index].green),q); 44163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=(pixel >> blue_shift) & blue_mask; 44174c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(composite_image, 44184c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum(colors[index].blue),q); 4419ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(composite_image); 44203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44210b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=SyncCacheViewAuthenticPixels(composite_view,exception); 44220b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 44263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) composite_image->rows; y++) 44273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4428c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(composite_view,0,(ssize_t) y, 44293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image->columns,1,exception); 4430acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 44313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) composite_image->columns; x++) 44333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel=XGetPixel(ximage,x,y); 44353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(pixel >> red_shift) & red_mask; 44369a7df36bb436fe340138d7eea39c974b45c9344ccristy if (red_mask != 0) 44379a7df36bb436fe340138d7eea39c974b45c9344ccristy color=(65535UL*color)/red_mask; 44389a7df36bb436fe340138d7eea39c974b45c9344ccristy SetPixelRed(composite_image,ScaleShortToQuantum( 44399a7df36bb436fe340138d7eea39c974b45c9344ccristy (unsigned short) color),q); 44403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(pixel >> green_shift) & green_mask; 44419a7df36bb436fe340138d7eea39c974b45c9344ccristy if (green_mask != 0) 44429a7df36bb436fe340138d7eea39c974b45c9344ccristy color=(65535UL*color)/green_mask; 44439a7df36bb436fe340138d7eea39c974b45c9344ccristy SetPixelGreen(composite_image,ScaleShortToQuantum( 44449a7df36bb436fe340138d7eea39c974b45c9344ccristy (unsigned short) color),q); 44453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(pixel >> blue_shift) & blue_mask; 44469a7df36bb436fe340138d7eea39c974b45c9344ccristy if (blue_mask != 0) 44479a7df36bb436fe340138d7eea39c974b45c9344ccristy color=(65535UL*color)/blue_mask; 44489a7df36bb436fe340138d7eea39c974b45c9344ccristy SetPixelBlue(composite_image,ScaleShortToQuantum( 44499a7df36bb436fe340138d7eea39c974b45c9344ccristy (unsigned short) color),q); 4450ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(composite_image); 44513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44520b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=SyncCacheViewAuthenticPixels(composite_view,exception); 44530b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PseudoClass: 44593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 44613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create colormap. 44623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 44630b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=AcquireImageColormap(composite_image,number_colors, 44640b1a797184d12984eb55d950fb5f532298d9fd0fcristy exception); 44650b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 44683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image=DestroyImage(composite_image); 44693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 44703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) composite_image->colors; i++) 44723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4473e42f658533644aecb733785ffd91b286d6778deacristy composite_image->colormap[colors[i].pixel].red=(double) 44743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleShortToQuantum(colors[i].red); 4475e42f658533644aecb733785ffd91b286d6778deacristy composite_image->colormap[colors[i].pixel].green=(double) 44763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleShortToQuantum(colors[i].green); 4477e42f658533644aecb733785ffd91b286d6778deacristy composite_image->colormap[colors[i].pixel].blue=(double) 44783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleShortToQuantum(colors[i].blue); 44793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 44813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert X image to PseudoClass packets. 44823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 44833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) composite_image->rows; y++) 44843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4485c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(composite_view,0,(ssize_t) y, 4486c57f694b2d04975a0e501613e34368c464708c19cristy composite_image->columns,1,exception); 4487acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 44883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) composite_image->columns; x++) 44903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44914c08aed51c5899665ade97263692328eea4af106cristy index=(Quantum) XGetPixel(ximage,x,y); 44924c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(composite_image,index,q); 4493803640d20a6a664315eddfff6f8531d0c5e0871dcristy SetPixelInfoPixel(composite_image, 44944c08aed51c5899665ade97263692328eea4af106cristy composite_image->colormap+(ssize_t) index,q); 4495ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(composite_image); 44963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44970b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=SyncCacheViewAuthenticPixels(composite_view,exception); 44980b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 45003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 45023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4504c57f694b2d04975a0e501613e34368c464708c19cristy composite_view=DestroyCacheView(composite_view); 45053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 45063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image == (Image *) NULL) 45073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 45083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=composite_image; 45093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 45103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Composite any children in back-to-front order. 45133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,window_info[id].window,window,0,0, 45153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &x_offset,&y_offset,&child); 45163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset-=(int) crop_info.x; 45173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x_offset < 0) 45183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset=0; 45193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset-=(int) crop_info.y; 45203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y_offset < 0) 45213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset=0; 452239172408bad7ef2ef00a815fa9abf9979e7857cbcristy (void) CompositeImage(image,composite_image,CopyCompositeOp,MagickTrue, 4523feb3e9695150978a5d2372d3fe2f60466a7c8066cristy (ssize_t) x_offset,(ssize_t) y_offset,exception); 45245f257b2f02bdd982d9bbfe612f5bb1711608590ccristy composite_image=DestroyImage(composite_image); 45253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources. 45283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (colormap_info != (ColormapInfo *) NULL) 45303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 45313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy next=colormap_info->next; 4532e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy colormap_info->colors=(XColor *) RelinquishMagickMemory( 4533e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy colormap_info->colors); 45343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=(ColormapInfo *) RelinquishMagickMemory(colormap_info); 45353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=next; 45363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources and restore initial state. 45393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info=(WindowInfo *) RelinquishMagickMemory(window_info); 45413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows=0; 45423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows=0; 45433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=(ColormapInfo *) NULL; 45443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 45453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 45473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 45483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 45493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 45503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t W i n d o w I n f o % 45553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowInfo() initializes the XWindowInfo structure. 45613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetWindowInfo method is: 45633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetWindowInfo(Display *display,XVisualInfo *visual_info, 45653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 45663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info,XWindowInfo *window) 45673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource_info,window) 45683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 45703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 45723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 45733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 45753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 45763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 45783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 45793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 45813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o font_info: Specifies a pointer to a XFontStruct structure. 45833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 45853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4587bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetWindowInfo(Display *display,XVisualInfo *visual_info, 45883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 45893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XResourceInfo *resource_info,XWindowInfo *window) 45903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 45913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize window info. 45933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 45953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 45963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 45973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 45983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 45993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 46003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 46013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->id != (Window) NULL) 46023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 46033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->cursor != (Cursor) NULL) 46043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window->cursor); 46053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->busy_cursor != (Cursor) NULL) 46063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window->busy_cursor); 46073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->highlight_stipple != (Pixmap) NULL) 46083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->highlight_stipple); 46093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shadow_stipple != (Pixmap) NULL) 46103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->shadow_stipple); 46113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->name == (char *) NULL) 46123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->name=AcquireString(""); 46133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->icon_name == (char *) NULL) 46143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->icon_name=AcquireString(""); 46153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 46163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 46173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 46183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 46193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize these attributes just once. 46203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 46213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->id=(Window) NULL; 46223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->name == (char *) NULL) 46233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->name=AcquireString(""); 46243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->icon_name == (char *) NULL) 46253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->icon_name=AcquireString(""); 46263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->x=XDisplayWidth(display,visual_info->screen) >> 1; 46273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->y=XDisplayWidth(display,visual_info->screen) >> 1; 46283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage=(XImage *) NULL; 46293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image=(XImage *) NULL; 46303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixmap=(Pixmap) NULL; 46313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap=(Pixmap) NULL; 46323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->mapped=MagickFalse; 46333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->stasis=MagickFalse; 46343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickTrue; 46353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->segment_info=(void *) NULL; 46363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 46373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 46383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 46393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 46403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 46413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->segment_info == (void *) NULL) 46423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->segment_info=AcquireQuantumMemory(2,sizeof(*segment_info)); 46433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 46443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmid=(-1); 46453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmaddr=(char *) NULL; 46463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 46473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 46483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 46493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 46503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 46513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 46523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize these attributes every time function is called. 46533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 46543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->screen=visual_info->screen; 46553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->root=XRootWindow(display,visual_info->screen); 46563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->visual=visual_info->visual; 46573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->storage_class=(unsigned int) visual_info->klass; 46583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->depth=(unsigned int) visual_info->depth; 46593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->visual_info=visual_info; 46603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->map_info=map_info; 46613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixel_info=pixel; 46623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->font_info=font_info; 46633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->cursor=XCreateFontCursor(display,XC_left_ptr); 46643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->busy_cursor=XCreateFontCursor(display,XC_watch); 46653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->geometry=(char *) NULL; 46663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->icon_geometry=(char *) NULL; 46673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->icon_geometry != (char *) NULL) 46683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&window->icon_geometry,resource_info->icon_geometry); 46693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->crop_geometry=(char *) NULL; 4670bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy window->flags=(size_t) PSize; 46713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width=1; 46723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height=1; 46733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->min_width=1; 46743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->min_height=1; 46753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width_inc=1; 46763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height_inc=1; 46773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->border_width=resource_info->border_width; 46783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->annotate_context=pixel->annotate_context; 46793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->highlight_context=pixel->highlight_context; 46803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->widget_context=pixel->widget_context; 46813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shadow_stipple=(Pixmap) NULL; 46823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->highlight_stipple=(Pixmap) NULL; 46833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->use_pixmap=MagickTrue; 46843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->immutable=MagickFalse; 46853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shape=MagickFalse; 46863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->data=0; 4687c57f694b2d04975a0e501613e34368c464708c19cristy window->mask=(int) (CWBackingStore | CWBackPixel | CWBackPixmap | 46883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWDontPropagate | 46893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CWEventMask | CWOverrideRedirect | CWSaveUnder | CWWinGravity); 46903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.background_pixel=pixel->background_color.pixel; 46913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.background_pixmap=(Pixmap) NULL; 46923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.bit_gravity=ForgetGravity; 46933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.backing_store=WhenMapped; 46943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.save_under=MagickTrue; 46953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.border_pixel=pixel->border_color.pixel; 46963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.colormap=map_info->colormap; 46973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.cursor=window->cursor; 46983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.do_not_propagate_mask=NoEventMask; 46993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.event_mask=NoEventMask; 47003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.override_redirect=MagickFalse; 47013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.win_gravity=NorthWestGravity; 47023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->orphan=MagickFalse; 47033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 47043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 47053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 47063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X H i g h l i g h t E l l i p s e % 47113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XHighlightEllipse() puts a border on the X server around a region defined by 47173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% highlight_info. 47183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XHighlightEllipse method is: 47203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XHighlightEllipse(Display *display,Window window, 47223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% GC annotate_context,const RectangleInfo *highlight_info) 47233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 47253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 47273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 47283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 47303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_context: Specifies a pointer to a GC structure. 47323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o highlight_info: Specifies a pointer to a RectangleInfo structure. It 47343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any highlighting rectangle. 47353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4737bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XHighlightEllipse(Display *display,Window window, 47383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC annotate_context,const RectangleInfo *highlight_info) 47393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 47403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 47413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 47423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 47433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_context != (GC) NULL); 47443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(highlight_info != (RectangleInfo *) NULL); 47453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((highlight_info->width < 4) || (highlight_info->height < 4)) 47463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 47473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawArc(display,window,annotate_context,(int) highlight_info->x, 47483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info->y,(unsigned int) highlight_info->width-1, 47493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-1,0,360*64); 47503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawArc(display,window,annotate_context,(int) highlight_info->x+1, 47513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info->y+1,(unsigned int) highlight_info->width-3, 47523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-3,0,360*64); 47533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 47543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 47553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 47563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X H i g h l i g h t L i n e % 47613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XHighlightLine() puts a border on the X server around a region defined by 47673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% highlight_info. 47683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XHighlightLine method is: 47703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XHighlightLine(Display *display,Window window,GC annotate_context, 47723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XSegment *highlight_info) 47733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 47753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 47773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 47783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 47803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_context: Specifies a pointer to a GC structure. 47823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o highlight_info: Specifies a pointer to a RectangleInfo structure. It 47843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any highlighting rectangle. 47853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4787bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XHighlightLine(Display *display,Window window, 47883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC annotate_context,const XSegment *highlight_info) 47893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 47903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 47913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 47923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 47933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_context != (GC) NULL); 47943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(highlight_info != (XSegment *) NULL); 47953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLine(display,window,annotate_context,highlight_info->x1, 47963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info->y1,highlight_info->x2,highlight_info->y2); 47973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 47983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 47993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 48003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X H i g h l i g h t R e c t a n g l e % 48053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XHighlightRectangle() puts a border on the X server around a region defined 48113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% by highlight_info. 48123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XHighlightRectangle method is: 48143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XHighlightRectangle(Display *display,Window window, 48163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% GC annotate_context,const RectangleInfo *highlight_info) 48173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 48193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 48213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 48223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 48243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_context: Specifies a pointer to a GC structure. 48263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o highlight_info: Specifies a pointer to a RectangleInfo structure. It 48283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any highlighting rectangle. 48293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4831bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XHighlightRectangle(Display *display,Window window, 48323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC annotate_context,const RectangleInfo *highlight_info) 48333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 48343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 48353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 48363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 48373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_context != (GC) NULL); 48383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(highlight_info != (RectangleInfo *) NULL); 48393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((highlight_info->width < 4) || (highlight_info->height < 4)) 48403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 48413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,window,annotate_context,(int) highlight_info->x, 48423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info->y,(unsigned int) highlight_info->width-1, 48433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-1); 48443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,window,annotate_context,(int) highlight_info->x+ 48453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1,(int) highlight_info->y+1,(unsigned int) highlight_info->width-3, 48463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-3); 48473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 48483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 48503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X I m p o r t I m a g e % 48553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XImportImage() reads an image from an X window. 48613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XImportImage method is: 48633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48646710d8414f0ed06e4eaf9346366be72e2b4719efcristy% Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info, 48656710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 48663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 48683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: the image info. 48703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage_info: Specifies a pointer to an XImportInfo structure. 48723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48736710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 48746710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 48753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 48763ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport Image *XImportImage(const ImageInfo *image_info, 48776710d8414f0ed06e4eaf9346366be72e2b4719efcristy XImportInfo *ximage_info,ExceptionInfo *exception) 48783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 48793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 48803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colormaps; 48813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Display 48833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *display; 48843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 48863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image; 48873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 48893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colormaps, 48903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows, 48913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 48923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 48943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 48953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 48973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 48983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 49003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 49013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client, 49023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy prior_target, 49033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root, 49043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target; 49053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextProperty 49073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 49083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Open X server connection. 49113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info != (const ImageInfo *) NULL); 49133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info->signature == MagickSignature); 49143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image_info->debug != MagickFalse) 49153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 49163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename); 49173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(ximage_info != (XImportInfo *) NULL); 49183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay(image_info->server_name); 49193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 49203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4921c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToOpenXServer", 49223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDisplayName(image_info->server_name)); 49233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 49243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set our forgiving exception handler. 49273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetErrorHandler(XError); 49293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select target window. 49313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x=0; 49333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y=0; 49343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.width=0; 49353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.height=0; 49363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root=XRootWindow(display,XDefaultScreen(display)); 49373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=(Window) NULL; 49386f008fdcea6389206e36baf0f05c8999c7366f7bcristy if (*image_info->filename != '\0') 49393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(image_info->filename,"root") == 0) 49413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=root; 49423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 49433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select window by ID or name. 49463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 494702e64f85ab79992a87dd6979d4948488fec02817cristy if (isdigit((int) ((unsigned char) *image_info->filename)) != 0) 49483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=XWindowByID(display,root,(Window) 49493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol(image_info->filename,(char **) NULL,0)); 49503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 49513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=XWindowByName(display,root,image_info->filename); 49523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 4953c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"NoWindowWithSpecifiedIDExists", 4954c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy image_info->filename); 49553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy If target window is not defined, interactively select one. 49593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy prior_target=target; 49613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 49623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=XSelectWindow(display,&crop_info); 49633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 4964c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToReadXWindowImage", 49653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename); 49663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client=target; /* obsolete */ 49673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target != root) 49683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 49703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy d; 49713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetGeometry(display,target,&root,&x,&x,&d,&d,&d,&d); 49733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 49743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for ( ; ; ) 49763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 49783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy parent; 49793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Find window manager frame. 49823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,target,&root,&parent,&children,&d); 49843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status != False) && (children != (Window *) NULL)) 49853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((char *) children); 49863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (parent == (Window) NULL) || 49873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (parent == root)) 49883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 49893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=parent; 49903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get client window. 49933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client=XClientWindow(display,target); 49953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->frame == MagickFalse) 49963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=client; 49973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage_info->frame == MagickFalse) && 49983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (prior_target != MagickFalse)) 49993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=prior_target; 50003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->screen) 50033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 50053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 50063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 50083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child; 50093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowAttributes 50113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_attributes; 50123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Obtain window image directly from screen. 50153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowAttributes(display,target,&window_attributes); 50173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 50183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5019c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToReadXWindowAttributes", 5020c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy image_info->filename); 50213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCloseDisplay(display); 50223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 50233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,target,root,0,0,&x,&y,&child); 5025c57f694b2d04975a0e501613e34368c464708c19cristy crop_info.x=(ssize_t) x; 5026c57f694b2d04975a0e501613e34368c464708c19cristy crop_info.y=(ssize_t) y; 5027bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width=(size_t) window_attributes.width; 5028bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) window_attributes.height; 5029553743c2f2d6c29405dcfab6390a1c505c79fececristy if (ximage_info->borders != 0) 50303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Include border in image. 50333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x-=window_attributes.border_width; 50353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y-=window_attributes.border_width; 50363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.width+=window_attributes.border_width << 1; 50373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.height+=window_attributes.border_width << 1; 50383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=root; 50403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy If WM_COLORMAP_WINDOWS property is set or multiple colormaps, descend. 50433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows=0; 50453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWMColormapWindows(display,target,&children,&number_windows); 50463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == True) && (number_windows > 0)) 50473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->descend=MagickTrue; 50493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree ((char *) children); 50503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormaps=XListInstalledColormaps(display,target,&number_colormaps); 50523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_colormaps > 0) 50533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_colormaps > 1) 50553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->descend=MagickTrue; 50563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((char *) colormaps); 50573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Alert the user not to alter the screen. 50603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->silent == MagickFalse) 50623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XBell(display,0); 50633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get image by window id. 50653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XGrabServer(display); 50673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=XGetWindowImage(display,target,ximage_info->borders, 50686710d8414f0ed06e4eaf9346366be72e2b4719efcristy ximage_info->descend ? 1U : 0U,exception); 50693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XUngrabServer(display); 50703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image == (Image *) NULL) 5071c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToReadXWindowImage", 50723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename) 50733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 50743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image->filename,image_info->filename, 50763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MaxTextExtent); 50773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info.width != 0) && (crop_info.height != 0)) 50783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 50803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *clone_image, 50813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *crop_image; 50823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Crop image as defined by the cropping rectangle. 50853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50866710d8414f0ed06e4eaf9346366be72e2b4719efcristy clone_image=CloneImage(image,0,0,MagickTrue,exception); 50873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (clone_image != (Image *) NULL) 50883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50896710d8414f0ed06e4eaf9346366be72e2b4719efcristy crop_image=CropImage(clone_image,&crop_info,exception); 50903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_image != (Image *) NULL) 50913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=DestroyImage(image); 50933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=crop_image; 50943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWMName(display,target,&window_name); 50983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == True) 50993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51008418c7e51974060a1c724e25d700d72fb437174bcristy if (*image_info->filename == '\0') 51013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image->filename,(char *) window_name.value, 51023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (size_t) window_name.nitems+1); 51033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) window_name.value); 51043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->silent == MagickFalse) 51073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 51093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Alert the user we're done. 51103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 51113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XBell(display,0); 51123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XBell(display,0); 51133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCloseDisplay(display); 51153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 51163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 51173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 51183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 51193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 51203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X I n i t i a l i z e W i n d o w s % 51243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 51283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XInitializeWindows() initializes the XWindows structure. 51303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XInitializeWindows method is: 51323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindows *XInitializeWindows(Display *display, 51343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info) 51353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 51373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: XInitializeWindows returns a pointer to a XWindows structure. 51393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 51413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 51423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 51443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 5146bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XWindows *XInitializeWindows(Display *display, 51473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XResourceInfo *resource_info) 51483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 51493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 51503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 51513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 51523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 51533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 51543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 51553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 51563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate windows structure. 51573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 515873bd4a51b419e914565bdf204bf1540dc4c8ee26cristy windows=(XWindows *) AcquireMagickMemory(sizeof(*windows)); 51593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows == (XWindows *) NULL) 51603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"MemoryAllocationFailed", 51623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "..."); 51633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XWindows *) NULL); 51643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(windows,0,sizeof(*windows)); 51663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info=(XPixelInfo *) AcquireMagickMemory( 51673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*windows->pixel_info)); 51683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_pixel=(XPixelInfo *) AcquireMagickMemory( 51693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*windows->icon_pixel)); 51703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources=(XResourceInfo *) AcquireMagickMemory( 51713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*windows->icon_resources)); 51723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->pixel_info == (XPixelInfo *) NULL) || 51733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_pixel == (XPixelInfo *) NULL) || 51743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_resources == (XResourceInfo *) NULL)) 51753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"MemoryAllocationFailed", 51773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "..."); 51783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XWindows *) NULL); 51793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 51813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize windows structure. 51823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 51833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->display=display; 51843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_protocols=XInternAtom(display,"WM_PROTOCOLS",MagickFalse); 51853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_delete_window=XInternAtom(display,"WM_DELETE_WINDOW",MagickFalse); 51863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_take_focus=XInternAtom(display,"WM_TAKE_FOCUS",MagickFalse); 51873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_protocols=XInternAtom(display,"IM_PROTOCOLS",MagickFalse); 51883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_remote_command= 51893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XInternAtom(display,"IM_REMOTE_COMMAND",MagickFalse); 51903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_update_widget=XInternAtom(display,"IM_UPDATE_WIDGET",MagickFalse); 51913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_update_colormap= 51923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XInternAtom(display,"IM_UPDATE_COLORMAP",MagickFalse); 51933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_former_image=XInternAtom(display,"IM_FORMER_IMAGE",MagickFalse); 51943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_next_image=XInternAtom(display,"IM_NEXT_IMAGE",MagickFalse); 51953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_retain_colors=XInternAtom(display,"IM_RETAIN_COLORS",MagickFalse); 51963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_exit=XInternAtom(display,"IM_EXIT",MagickFalse); 51973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->dnd_protocols=XInternAtom(display,"DndProtocol",MagickFalse); 51980157aeadef2fce908277168097a160a8f15a6952cristy#if defined(MAGICKCORE_WINDOWS_SUPPORT) 51993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSynchronize(display,IsWindows95()); 52003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 52013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 52023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 52033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSynchronize(display,MagickTrue); 52043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Version: %s", 5205bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy GetMagickVersion((size_t *) NULL)); 52063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Protocols:"); 52073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " Window Manager: 0x%lx",windows->wm_protocols); 52093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " delete window: 0x%lx",windows->wm_delete_window); 52113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," take focus: 0x%lx", 52123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_take_focus); 52133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," ImageMagick: 0x%lx", 52143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_protocols); 52153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " remote command: 0x%lx",windows->im_remote_command); 52173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " update widget: 0x%lx",windows->im_update_widget); 52193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " update colormap: 0x%lx",windows->im_update_colormap); 52213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " former image: 0x%lx",windows->im_former_image); 52233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," next image: 0x%lx", 52243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_next_image); 52253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " retain colors: 0x%lx",windows->im_retain_colors); 52273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," exit: 0x%lx", 52283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_exit); 52293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," Drag and Drop: 0x%lx", 52303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->dnd_protocols); 52313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 52323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate standard colormap. 52343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->map_info=XAllocStandardColormap(); 52363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_map=XAllocStandardColormap(); 52373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->map_info == (XStandardColormap *) NULL) || 52383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_map == (XStandardColormap *) NULL)) 5239c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", 5240c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy "..."); 52413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->map_info->colormap=(Colormap) NULL; 52423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_map->colormap=(Colormap) NULL; 5243f2faecf9facdbbb14fcba373365f9f691a9658e0cristy windows->pixel_info->pixels=(unsigned long *) NULL; 52443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info->annotate_context=(GC) NULL; 52453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info->highlight_context=(GC) NULL; 52463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info->widget_context=(GC) NULL; 52473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->font_info=(XFontStruct *) NULL; 52483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_pixel->annotate_context=(GC) NULL; 5249f2faecf9facdbbb14fcba373365f9f691a9658e0cristy windows->icon_pixel->pixels=(unsigned long *) NULL; 52503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate visual. 52523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows->icon_resources=(*resource_info); 52543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources->visual_type=(char *) "default"; 52553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources->colormap=SharedColormap; 52563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info= 52573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestVisualInfo(display,windows->map_info,resource_info); 52583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_visual= 52593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestVisualInfo(display,windows->icon_map,windows->icon_resources); 52603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->visual_info == (XVisualInfo *) NULL) || 52613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_visual == (XVisualInfo *) NULL)) 52623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToGetVisual", 52633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->visual_type); 52643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 52653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 52663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Visual:"); 52673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," visual id: 0x%lx", 52683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->visualid); 52693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," class: %s", 52703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualClassName(windows->visual_info->klass)); 52713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," depth: %d planes", 52723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->depth); 52733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " size of colormap: %d entries",windows->visual_info->colormap_size); 52753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue masks: 0x%lx 0x%lx 0x%lx", 52773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->red_mask,windows->visual_info->green_mask, 52783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->blue_mask); 52793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " significant bits in color: %d bits", 52813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->bits_per_rgb); 52823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 52833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate class and manager hints. 52853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->class_hints=XAllocClassHint(); 52873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->manager_hints=XAllocWMHints(); 52883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->class_hints == (XClassHint *) NULL) || 52893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->manager_hints == (XWMHints *) NULL)) 5290c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", 5291c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy "..."); 52923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine group leader if we have one. 52943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,windows->visual_info->screen); 52963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->group_leader.id=(Window) NULL; 52973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->window_group != (char *) NULL) 52983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 529902e64f85ab79992a87dd6979d4948488fec02817cristy if (isdigit((int) ((unsigned char) *resource_info->window_group)) != 0) 53003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->group_leader.id=XWindowByID(display,root_window,(Window) 53013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol((char *) resource_info->window_group,(char **) NULL,0)); 53023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->group_leader.id == (Window) NULL) 53033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->group_leader.id= 53043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowByName(display,root_window,resource_info->window_group); 53053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 53063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(windows); 53073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 53083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 53103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e C u r s o r % 53153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeCursor() creates a crosshairs X11 cursor. 53213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeCursor method is: 53233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Cursor XMakeCursor(Display *display,Window window,Colormap colormap, 53253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *background_color,char *foreground_color) 53263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 53283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 53303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 53313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies the ID of the window for which the cursor is 53333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% assigned. 53343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colormap: Specifies the ID of the colormap from which the background 53363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% and foreground color will be retrieved. 53373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o background_color: Specifies the color to use for the cursor background. 53393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o foreground_color: Specifies the color to use for the cursor foreground. 53413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 5343bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Cursor XMakeCursor(Display *display,Window window, 53443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap colormap,char *background_color,char *foreground_color) 53453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 53463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_height 17 53473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_x_hot 8 53483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_y_hot 8 53493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_width 17 53503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const unsigned char 53523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_bits[] = 53533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 53543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x80, 0x03, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 53553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x7f, 53563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xfc, 0x01, 0x01, 0x00, 0x01, 0x7f, 0xfc, 0x01, 0x80, 0x02, 0x00, 53573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 53583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0x80, 0x02, 0x00, 0x80, 0x03, 0x00 53593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 53603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_mask_bits[] = 53613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 53623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xc0, 0x07, 0x00, 0xc0, 0x07, 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 53633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 0x00, 0xff, 0xfe, 0x01, 0x7f, 53643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xfc, 0x01, 0x03, 0x80, 0x01, 0x7f, 0xfc, 0x01, 0xff, 0xfe, 0x01, 53653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xc0, 0x06, 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 53663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0xc0, 0x07, 0x00, 0xc0, 0x07, 0x00 53673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 53683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cursor 53703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cursor; 53713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 53733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask, 53743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source; 53753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 53773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 53783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground; 53793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 53813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 53823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(colormap != (Colormap) NULL); 53833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(background_color != (char *) NULL); 53843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(foreground_color != (char *) NULL); 53853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",background_color); 53863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source=XCreateBitmapFromData(display,window,(char *) scope_bits,scope_width, 53873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_height); 53883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask=XCreateBitmapFromData(display,window,(char *) scope_mask_bits, 53893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_width,scope_height); 53903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((source == (Pixmap) NULL) || (mask == (Pixmap) NULL)) 53913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5392c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToCreatePixmap","..."); 53933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Cursor) NULL); 53943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 53953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,background_color,&background); 53963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,foreground_color,&foreground); 53973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cursor=XCreatePixmapCursor(display,source,mask,&foreground,&background, 53983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_x_hot,scope_y_hot); 53993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,source); 54003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,mask); 54013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(cursor); 54023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 54033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 54053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e I m a g e % 54103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeImage() creates an X11 image. If the image size differs from the X11 54163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% image size, the image is first resized. 54173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeImage method is: 54193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XMakeImage(Display *display, 54213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XResourceInfo *resource_info,XWindowInfo *window,Image *image, 5422051718b74ad68f8584cdac01d0192974ec777f1bcristy% unsigned int width,unsigned int height,ExceptionInfo *exception) 54233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 54253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 54273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 54283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 54303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 54323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 54343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o width: Specifies the width in pixels of the rectangular area to 54363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% display. 54373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o height: Specifies the height in pixels of the rectangular area to 54393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% display. 54403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5441051718b74ad68f8584cdac01d0192974ec777f1bcristy% o exception: return any errors or warnings in this structure. 5442051718b74ad68f8584cdac01d0192974ec777f1bcristy% 54433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 5444bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XMakeImage(Display *display, 54453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,XWindowInfo *window,Image *image, 5446051718b74ad68f8584cdac01d0192974ec777f1bcristy unsigned int width,unsigned int height,ExceptionInfo *exception) 54473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 54483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define CheckOverflowException(length,width,height) \ 54493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (((height) != 0) && ((length)/((size_t) height) != ((size_t) width))) 54503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 54523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth, 54533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 54543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 54563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length; 54573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 54593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *matte_image, 54603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 54613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 54633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 54643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 54653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 54663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(width != 0); 54673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(height != 0); 54683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->width == 0) || (window->height == 0)) 54693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 54703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 54713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Apply user transforms to the image. 54723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 54733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->busy_cursor); 54743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 54753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth=(int) window->depth; 54763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->destroy) 54773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=DestroyImage(window->image); 54783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=image; 54793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->destroy=MagickFalse; 54803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != (Image *) NULL) 54813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 54823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->crop_geometry != (char *) NULL) 54833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 54843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 54853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *crop_image; 54863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 54883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 54893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 54913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Crop image. 54923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 54933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image->page.x=0; 54943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image->page.y=0; 54953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ParsePageGeometry(window->image,window->crop_geometry, 54966710d8414f0ed06e4eaf9346366be72e2b4719efcristy &crop_info,exception); 54976710d8414f0ed06e4eaf9346366be72e2b4719efcristy crop_image=CropImage(window->image,&crop_info,exception); 54983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_image != (Image *) NULL) 54993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != image) 55013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=DestroyImage(window->image); 55023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=crop_image; 55033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->destroy=MagickTrue; 55043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((width != (unsigned int) window->image->columns) || 55073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (height != (unsigned int) window->image->rows)) 55083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 55103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resize_image; 55113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 55123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 55133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Resize image. 55143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 55153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resize_image=NewImageList(); 5516865489bb885f6a74ebe640b3d61720fd4ea96d6acristy if ((window->pixel_info->colors == 0) && 5517865489bb885f6a74ebe640b3d61720fd4ea96d6acristy (window->image->rows > (unsigned long) XDisplayHeight(display,window->screen)) && 5518865489bb885f6a74ebe640b3d61720fd4ea96d6acristy (window->image->columns > (unsigned long) XDisplayWidth(display,window->screen))) 5519865489bb885f6a74ebe640b3d61720fd4ea96d6acristy resize_image=ResizeImage(window->image,width,height, 5520865489bb885f6a74ebe640b3d61720fd4ea96d6acristy image->filter,exception); 55213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 5522865489bb885f6a74ebe640b3d61720fd4ea96d6acristy { 5523865489bb885f6a74ebe640b3d61720fd4ea96d6acristy if (window->image->storage_class == PseudoClass) 5524865489bb885f6a74ebe640b3d61720fd4ea96d6acristy resize_image=SampleImage(window->image,width,height, 5525865489bb885f6a74ebe640b3d61720fd4ea96d6acristy exception); 5526865489bb885f6a74ebe640b3d61720fd4ea96d6acristy else 5527865489bb885f6a74ebe640b3d61720fd4ea96d6acristy resize_image=ThumbnailImage(window->image,width,height, 5528865489bb885f6a74ebe640b3d61720fd4ea96d6acristy exception); 5529865489bb885f6a74ebe640b3d61720fd4ea96d6acristy } 55303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resize_image != (Image *) NULL) 55313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != image) 55333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=DestroyImage(window->image); 55343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=resize_image; 55353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->destroy=MagickTrue; 55363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) window->image->columns; 5539bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy assert((size_t) width == window->image->columns); 55403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) window->image->rows; 5541bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy assert((size_t) height == window->image->rows); 55423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 55443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create X image. 55453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 55463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 55473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format=(depth == 1) ? XYBitmap : ZPixmap; 55483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 55493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 55523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 55533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 55543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 55553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 55563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 55573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XShmCreateImage(display,window->visual,(unsigned int) depth,format, 55583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,&segment_info[1],width,height); 55593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 55603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 55619c5171c13c7186088b10ec322e199f60e455a7e1cristy else 55629c5171c13c7186088b10ec322e199f60e455a7e1cristy { 55639c5171c13c7186088b10ec322e199f60e455a7e1cristy length=(size_t) ximage->bytes_per_line*ximage->height; 55649c5171c13c7186088b10ec322e199f60e455a7e1cristy if (CheckOverflowException(length,ximage->bytes_per_line,ximage->height)) 55659c5171c13c7186088b10ec322e199f60e455a7e1cristy window->shared_memory=MagickFalse; 55669c5171c13c7186088b10ec322e199f60e455a7e1cristy } 55673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=shmget(IPC_PRIVATE,length,IPC_CREAT | 0777); 55693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) shmat(segment_info[1].shmid,0,0); 55713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmid < 0) 55723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 55733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[1].shmid,IPC_RMID,0); 55753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 55763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage != (XImage *) NULL) 55783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 55793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 55803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmaddr) 55813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[1].shmaddr); 55833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 55843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmid >= 0) 55863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[1].shmid,IPC_RMID,0); 55883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 55893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 55933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 55943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate X image pixel data. 55953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 55963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 55973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory) 55983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 56003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 56013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 56023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 56033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 56043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 56053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 56063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xerror_alert=MagickFalse; 56073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 56083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->data=segment_info[1].shmaddr; 56093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].readOnly=MagickFalse; 56103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XShmAttach(display,&segment_info[1]); 56113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 56123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 56133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (xerror_alert != MagickFalse)) 56143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 56163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 56173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmDetach(display,&segment_info[1]); 5618fa18e626bfb0f8953c8393f3252cbc3f0e07c80ccristy ximage->data=NULL; 5619fa18e626bfb0f8953c8393f3252cbc3f0e07c80ccristy XDestroyImage(ximage); 5620fa18e626bfb0f8953c8393f3252cbc3f0e07c80ccristy ximage=(XImage *) NULL; 56213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmid >= 0) 56223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmaddr != NULL) 56243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[1].shmaddr); 56253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[1].shmid,IPC_RMID,0); 56263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 56273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 56283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 56323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 56333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XCreateImage(display,window->visual,(unsigned int) depth,format,0, 56343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,width,height,XBitmapPad(display),0); 56353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 56363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 56383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Unable to create X image. 56393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 56403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 56413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 56423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=(size_t) ximage->bytes_per_line*ximage->height; 56443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 56453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"XImage:"); 56473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," width, height: %dx%d", 56483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->width,ximage->height); 56493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," format: %d", 56503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->format); 56513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," byte order: %d", 56523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->byte_order); 56533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 56543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " bitmap unit, bit order, pad: %d %d %d",ximage->bitmap_unit, 56553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bitmap_bit_order,ximage->bitmap_pad); 56563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," depth: %d", 56573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->depth); 56583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," bytes per line: %d", 56593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bytes_per_line); 56603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," bits per pixel: %d", 56613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bits_per_pixel); 56623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 56633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue masks: 0x%lx 0x%lx 0x%lx",ximage->red_mask, 56643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->green_mask,ximage->blue_mask); 56653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 56673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format != XYBitmap) 56699aecad6d644546db4165f5b6838d6e2b9d3433cfcristy ximage->data=(char *) malloc((size_t) ximage->bytes_per_line* 56709aecad6d644546db4165f5b6838d6e2b9d3433cfcristy ximage->height); 56713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 56729aecad6d644546db4165f5b6838d6e2b9d3433cfcristy ximage->data=(char *) malloc((size_t) ximage->bytes_per_line* 56739aecad6d644546db4165f5b6838d6e2b9d3433cfcristy ximage->depth*ximage->height); 56743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->data == (char *) NULL) 56763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 56783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Unable to allocate pixel data. 56793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 56803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 56813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 56823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 56833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 56843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage != (XImage *) NULL) 56863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 56883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Destroy previous X image. 56893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 56903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=(size_t) window->ximage->bytes_per_line*window->ximage->height; 56913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 56923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->segment_info != (XShmSegmentInfo *) NULL) 56933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 56953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 56963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 56973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 56983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[0].shmid >= 0) 56993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 57013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XShmDetach(display,&segment_info[0]); 57023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 57033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[0].shmaddr != (char *) NULL) 57043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[0].shmaddr); 57053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[0].shmid,IPC_RMID,0); 57063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmid=(-1); 57073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmaddr=(char *) NULL; 57083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage->data=(char *) NULL; 57093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 57123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage->data != (char *) NULL) 57133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy free(window->ximage->data); 57143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage->data=(char *) NULL; 57153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(window->ximage); 57163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage=(XImage *) NULL; 57173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 57193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->segment_info != (XShmSegmentInfo *) NULL) 57203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 57223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 57233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 57243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 57253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0]=segment_info[1]; 57263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 57283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage=ximage; 57293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image=(XImage *) NULL; 57303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->shape != MagickFalse) && (window->image != (Image *) NULL)) 573117f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy if ((window->image->alpha_trait != UndefinedPixelTrait) && 5732c57f694b2d04975a0e501613e34368c464708c19cristy ((int) width <= XDisplayWidth(display,window->screen)) && 5733c57f694b2d04975a0e501613e34368c464708c19cristy ((int) height <= XDisplayHeight(display,window->screen))) 57343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create matte image. 57373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image=XCreateImage(display,window->visual,1,XYBitmap,0, 57393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,width,height,XBitmapPad(display),0); 57403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 57413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Matte Image:"); 57433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 57443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " width, height: %dx%d",matte_image->width,matte_image->height); 57453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image != (XImage *) NULL) 57473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate matte image pixel data. 57503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57519aecad6d644546db4165f5b6838d6e2b9d3433cfcristy matte_image->data=(char *) malloc((size_t) 57529aecad6d644546db4165f5b6838d6e2b9d3433cfcristy matte_image->bytes_per_line*matte_image->depth* 57539aecad6d644546db4165f5b6838d6e2b9d3433cfcristy matte_image->height); 57543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image->data == (char *) NULL) 57553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(matte_image); 57573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image=(XImage *) NULL; 57583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_image != (XImage *) NULL) 57623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free matte image. 57653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_image->data != (char *) NULL) 57673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy free(window->matte_image->data); 57683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image->data=(char *) NULL; 57693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(window->matte_image); 57703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image=(XImage *) NULL; 57713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image=matte_image; 57733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 57743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->matte_pixmap); 57763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap=(Pixmap) NULL; 57773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 57783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shape != MagickFalse) 57793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShapeCombineMask(display,window->id,ShapeBounding,0,0,None,ShapeSet); 57803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 57813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->stasis=MagickFalse; 57833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert pixels to X image data. 57853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != (Image *) NULL) 57873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->byte_order == LSBFirst) || ((ximage->format == XYBitmap) && 57893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ximage->bitmap_bit_order == LSBFirst))) 57903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeImageLSBFirst(resource_info,window,window->image,ximage, 5791e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy matte_image,exception); 57923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 57933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeImageMSBFirst(resource_info,window,window->image,ximage, 5794e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy matte_image,exception); 57953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_image != (XImage *) NULL) 57973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create matte pixmap. 58003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 58013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap=XCreatePixmap(display,window->id,width,height,1); 58023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 58033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 58043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 58053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy graphics_context; 58063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 58083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 58093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 58113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Copy matte image to matte pixmap. 58123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 58134c08aed51c5899665ade97263692328eea4af106cristy context_values.background=0; 58144c08aed51c5899665ade97263692328eea4af106cristy context_values.foreground=1; 58153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy graphics_context=XCreateGC(display,window->matte_pixmap, 5816bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (size_t) (GCBackground | GCForeground),&context_values); 58173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,window->matte_pixmap,graphics_context, 58183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image,0,0,0,0,width,height); 58193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,graphics_context); 58203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 58213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shape != MagickFalse) 58223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShapeCombineMask(display,window->id,ShapeBounding,0,0, 58233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap,ShapeSet); 58243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 58253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 58263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 58273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XMakePixmap(display,resource_info,window); 58283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 58293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restore cursor. 58303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 58313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 58323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 58333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 58343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 58363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 58373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X M a k e I m a g e L S B F i r s t % 58413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 58453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeImageLSBFirst() initializes the pixel data of an X11 Image. The X image 58473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pixels are copied in least-significant bit and byte first order. The 58483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% server's scanline pad is respected. Rather than using one or two general 58493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% cases, many special cases are found here to help speed up the image 58503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% conversion. 58513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeImageLSBFirst method is: 58533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5854e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% void XMakeImageLSBFirst(Display *display,XWindows *windows, 5855e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% ExceptionInfo *exception) 58563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 58583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 58603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 58623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 58643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage: Specifies a pointer to a XImage structure; returned from 58663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 58673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o matte_image: Specifies a pointer to a XImage structure; returned from 58693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 58703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5871e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% o exception: return any errors or warnings in this structure. 5872e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% 58733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 58743ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void XMakeImageLSBFirst(const XResourceInfo *resource_info, 5875e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy const XWindowInfo *window,Image *image,XImage *ximage,XImage *matte_image, 5876e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy ExceptionInfo *exception) 58773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 5878c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 5879c57f694b2d04975a0e501613e34368c464708c19cristy *canvas_view; 5880c57f694b2d04975a0e501613e34368c464708c19cristy 58813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 58823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *canvas; 58833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 58853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 58863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58874c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 58883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 58893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 58913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 58923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 58943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 58953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 58973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit, 58983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte; 58993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 59013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad; 59023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5903f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 59043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel, 59053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pixels; 59063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap 59083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info; 59093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 59113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 59123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 59133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 59143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 59153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=image; 5916bab87c3357f708174fd2d8ab87a0d7dbb3f70e31cristy if ((window->immutable == MagickFalse) && 591717f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy (image->storage_class == DirectClass) && (image->alpha_trait != UndefinedPixelTrait)) 59183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 59203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size[MaxTextExtent]; 59213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 59233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pattern; 59243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 59263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image_info; 59273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=AcquireImageInfo(); 59293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image_info->filename, 59303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture != (char *) NULL ? 59313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture : "pattern:checkerboard", 59323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MaxTextExtent); 5933b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",(double) 5934e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy image->columns,(double) image->rows); 59353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->size=ConstantString(size); 59366710d8414f0ed06e4eaf9346366be72e2b4719efcristy pattern=ReadImage(image_info,exception); 59373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=DestroyImageInfo(image_info); 59383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pattern != (Image *) NULL) 59393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59406710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas=CloneImage(image,0,0,MagickTrue,exception); 59413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != (Image *) NULL) 594239172408bad7ef2ef00a815fa9abf9979e7857cbcristy (void) CompositeImage(canvas,pattern,DstOverCompositeOp,MagickTrue, 5943feb3e9695150978a5d2372d3fe2f60466a7c8066cristy 0,0,exception); 59443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pattern=DestroyImage(pattern); 59453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 59463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 59473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (ximage->bytes_per_line-((ximage->width* 59483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bits_per_pixel) >> 3)); 59493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info=window->map_info; 59503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixels=window->pixel_info->pixels; 59513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) ximage->data; 59523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 595346ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy canvas_view=AcquireVirtualCacheView(canvas,exception); 59543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 59553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned short 59573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy polarity; 59583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 59603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 59613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground; 59623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 59643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert canvas to big-endian bitmap. 59653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 59663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 59673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->foreground_color) < 59683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->background_color) ? 0x80 : 0x00); 59693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 59703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->background_color) < 59713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->foreground_color) ? 0x80 : 0x00); 5972101ab708b0574518ac5715da4d3915400e9df79acristy polarity=(unsigned short) ((GetPixelInfoIntensity( 59736e963d8cbd0aebba1073d7f4b61e3d17177d6fedcristy &canvas->colormap[0])) < (QuantumRange/2) ? 1 : 0); 59743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas->colors == 2) 5975101ab708b0574518ac5715da4d3915400e9df79acristy polarity=GetPixelInfoIntensity(&canvas->colormap[0]) < 5976101ab708b0574518ac5715da4d3915400e9df79acristy GetPixelInfoIntensity(&canvas->colormap[1]); 59773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 59783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5979c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 59806710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 59814c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 59823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 59833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 59843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 59853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 59863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte>>=1; 59884c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelIndex(canvas,p) == (Quantum) polarity) 59893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 59903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 59913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 59923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 59933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 59943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 59963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 59973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 59983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5999ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 60003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 60023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte >> (8-bit); 60033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 60043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 60073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixel_info->colors != 0) 60083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 60093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 60113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 60133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 60143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 60153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 60163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 2 bit color-mapped X canvas. 60173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 60183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 60193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6020c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 60216710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 60224c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 60233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 60263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60274c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)] & 0x0f; 60283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 60293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 60313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 60333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 60373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 60393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 60433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 60453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 60493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 6); 60513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 60523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6056ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 60573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 60593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 60633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 60653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 60663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 60673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 60683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit color-mapped X canvas. 60693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 60703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 60713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6072c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 60736710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 60744c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 60753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 60783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60794c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)] & 0xf; 60803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 60813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 60833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 60853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 60893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 60913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 60923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6096ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 60973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 60993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 61033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 61043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 61063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit color-mapped X canvas. 61073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 61083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 6109cbda611068350bf4459f2dda1951f8823702e129cristy resource_info->quantize_info->dither_method != NoDitherMethod) 61103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61116710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 61123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 61153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6116c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 61176710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 61184c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 61193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 61213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61224c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)]; 61233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6124ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 61253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 61273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 61313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 61333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 61343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 61363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 61373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 61393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to multi-byte color-mapped X canvas. 61403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 61413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 61423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 61433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6144c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 61456710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 61464c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 61473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 61493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61504c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)]; 61513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 61523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 615342daae1036998661b8574cbce1fa28d25c1a4f42cristy *q++=(unsigned char) (pixel & 0xff); 61543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 61553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6156ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 61573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 61593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 61643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 61653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 61673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 61693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 61703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 61723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to contiguous 2 bit continuous-tone X canvas. 61733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 61743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 61753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 6177c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 61786710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 61794c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 61803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 61823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61834c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 61843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 61853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 61863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 61883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 61903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 61913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 61943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 61963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 61973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 62003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 62023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 62033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 62063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 6); 62083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 62093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 62103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6213ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 62143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 62163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 62203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 62223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 62233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 62243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 62253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to contiguous 4 bit continuous-tone X canvas. 62263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 62273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 62283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6229c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 62306710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 62314c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 62323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 62343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 62353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62364c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 62373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 62383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 62393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 62413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 62433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 62443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 62473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 62493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 62503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 62513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6254ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 62553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 62573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 62613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 62623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 62643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to contiguous 8 bit continuous-tone X canvas. 62653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 62663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 6267cbda611068350bf4459f2dda1951f8823702e129cristy resource_info->quantize_info->dither_method != NoDitherMethod) 62683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62696710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 62703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 62733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6274c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 62756710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 62764c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 62773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 62793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62804c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 62813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6282ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 62833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 62853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 62893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 62913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 62923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 65536L) && (map_info->green_mult == 256) && 62933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 1)) 62943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 62963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 62973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 62983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 62993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6300c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 63016710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 63024c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 63033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 63043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 63053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 63063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 63093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6312ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 63134c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 6314ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 63154c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6316ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 63174c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 63183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6319ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 63223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63258bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelBlue(canvas,p)); 63268bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelGreen(canvas,p)); 63278bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelRed(canvas,p)); 63283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6329ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 63343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 63353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 63363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 1) && (map_info->green_mult == 256) && 63373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 65536L)) 63383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 63413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 63433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6344c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 63456710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 63464c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 63473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 63483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 63493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 63503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 63533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6356ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 63574c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 6358ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 63594c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6360ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 63614c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 63623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6363ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 63663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63698bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelRed(canvas,p)); 63708bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelGreen(canvas,p)); 63718bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelBlue(canvas,p)); 63723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6373ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 63783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 63803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 63813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 63823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 63833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 63843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 63853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to multi-byte continuous-tone X canvas. 63873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 63893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 63903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6391c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 63926710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 63934c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 63943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6395c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) canvas->columns; x++) 63963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63974c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 63983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 63993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 640042daae1036998661b8574cbce1fa28d25c1a4f42cristy *q++=(unsigned char) (pixel & 0xff); 64013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 64023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6403ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 64043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 64063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 64093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image != (XImage *) NULL) 64123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 64143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize matte canvas. 64153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 64163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (matte_image->bytes_per_line- 64173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((matte_image->width*matte_image->bits_per_pixel) >> 3)); 64183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) matte_image->data; 64193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 64203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6421c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 64226710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 64234c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 64243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 64253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 64263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 64273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 64283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte>>=1; 64304c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelAlpha(canvas,p) > (QuantumRange/2)) 64313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=0x80; 64323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 64333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 64343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 64363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 64373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 64383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6439ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 64403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 64423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte >> (8-bit); 64433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 64443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6446c57f694b2d04975a0e501613e34368c464708c19cristy canvas_view=DestroyCacheView(canvas_view); 64473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != image) 64483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=DestroyImage(canvas); 64493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 64503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 64513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 64523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 64533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X M a k e I m a g e M S B F i r s t % 64573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 64613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeImageMSBFirst() initializes the pixel data of an X11 Image. The X 64633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% image pixels are copied in most-significant bit and byte first order. The 64643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% server's scanline pad is also respected. Rather than using one or two 64653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% general cases, many special cases are found here to help speed up the image 64663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% conversion. 64673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeImageMSBFirst method is: 64693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6470e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% XMakeImageMSBFirst(resource_info,window,image,ximage,matte_image, 6471e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% ExceptionInfo *exception) 64723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 64743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 64763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 64783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 64803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage: Specifies a pointer to a XImage structure; returned from 64823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 64833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o matte_image: Specifies a pointer to a XImage structure; returned from 64853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 64863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6487e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% o exception: return any errors or warnings in this structure. 6488e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% 64893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 64903ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void XMakeImageMSBFirst(const XResourceInfo *resource_info, 6491e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy const XWindowInfo *window,Image *image,XImage *ximage,XImage *matte_image, 6492e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy ExceptionInfo *exception) 64933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 6494c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 6495c57f694b2d04975a0e501613e34368c464708c19cristy *canvas_view; 6496c57f694b2d04975a0e501613e34368c464708c19cristy 64973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 64983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *canvas; 64993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 65013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 65023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 65043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 65053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65064c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 65073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 65083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 65103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 65113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 65133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit, 65143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte; 65153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 65173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad; 65183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6519f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 65203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel, 65213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pixels; 65223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap 65243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info; 65253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 65273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 65283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 65293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 65303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 65313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=image; 653254666e85e8e3b0eca47d318178a186ebb2901a73cristy if ((window->immutable != MagickFalse) && 653317f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy (image->storage_class == DirectClass) && (image->alpha_trait != UndefinedPixelTrait)) 65343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 65353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 65363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size[MaxTextExtent]; 65373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 65393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pattern; 65403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 65423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image_info; 65433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=AcquireImageInfo(); 65453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image_info->filename, 65463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture != (char *) NULL ? 65473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture : "pattern:checkerboard", 65483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MaxTextExtent); 6549b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",(double) 6550e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy image->columns,(double) image->rows); 65513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->size=ConstantString(size); 65526710d8414f0ed06e4eaf9346366be72e2b4719efcristy pattern=ReadImage(image_info,exception); 65533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=DestroyImageInfo(image_info); 65543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pattern != (Image *) NULL) 65553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 65566710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas=CloneImage(image,0,0,MagickTrue,exception); 65573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != (Image *) NULL) 6558feb3e9695150978a5d2372d3fe2f60466a7c8066cristy (void) CompositeImage(canvas,pattern,DstOverCompositeOp,MagickFalse, 6559feb3e9695150978a5d2372d3fe2f60466a7c8066cristy 0,0,exception); 65603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pattern=DestroyImage(pattern); 65613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 65623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 65634c08aed51c5899665ade97263692328eea4af106cristy scanline_pad=(unsigned int) (ximage->bytes_per_line-((ximage->width* 65644c08aed51c5899665ade97263692328eea4af106cristy ximage->bits_per_pixel) >> 3)); 65653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info=window->map_info; 65663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixels=window->pixel_info->pixels; 65673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) ximage->data; 65683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 656946ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy canvas_view=AcquireVirtualCacheView(canvas,exception); 65703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 65713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 65723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned short 65733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy polarity; 65743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 65763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 65773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground; 65783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 65803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert canvas to big-endian bitmap. 65813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 65823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 65833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->foreground_color) < 65843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->background_color) ? 0x01 : 0x00); 65853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 65863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->background_color) < 65873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->foreground_color) ? 0x01 : 0x00); 6588101ab708b0574518ac5715da4d3915400e9df79acristy polarity=(unsigned short) ((GetPixelInfoIntensity( 65896e963d8cbd0aebba1073d7f4b61e3d17177d6fedcristy &canvas->colormap[0])) < (QuantumRange/2) ? 1 : 0); 65903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas->colors == 2) 6591101ab708b0574518ac5715da4d3915400e9df79acristy polarity=GetPixelInfoIntensity(&canvas->colormap[0]) < 6592101ab708b0574518ac5715da4d3915400e9df79acristy GetPixelInfoIntensity(&canvas->colormap[1]); 65933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 65943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6595c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 65966710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 65974c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 65983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 65993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 66003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 66013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 66023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte<<=1; 66044c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelIndex(canvas,p) == (Quantum) polarity) 66053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 66063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 66073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 66083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 66093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 66103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 66123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 66133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 66143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6615ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 66163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 66183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte << (8-bit); 66193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 66203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 66233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixel_info->colors != 0) 66243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 66253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 66273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 66293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 66303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 66313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 66323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 2 bit color-mapped X canvas. 66333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 66343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 66353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6636c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 66376710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 66384c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 66393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 66413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 66423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66434c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) 66444c08aed51c5899665ade97263692328eea4af106cristy GetPixelIndex(canvas,p)] & 0xf; 66453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 66463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 66483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 6); 66503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 66513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 66543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 66563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 66573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 66603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 66623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 66633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 66663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 66683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 66693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 66703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6673ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 66743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 66763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 66803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 66823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 66833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 66843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 66853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit color-mapped X canvas. 66863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 66873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 66883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6689c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 66906710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 66914c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 66923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 66943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 66953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66964c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) 66974c08aed51c5899665ade97263692328eea4af106cristy GetPixelIndex(canvas,p)] & 0xf; 66983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 66993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 67013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 4); 67033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 67043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 67073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 67093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 67103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 67113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6714ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 67153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 67173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 67213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 67223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 67243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit color-mapped X canvas. 67253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 67263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 6727cbda611068350bf4459f2dda1951f8823702e129cristy resource_info->quantize_info->dither_method != NoDitherMethod) 67283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67296710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 67303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 67333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6734c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 67356710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 67364c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 67373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 67393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67406710d8414f0ed06e4eaf9346366be72e2b4719efcristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)]; 67413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6742ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 67433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 67453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 67493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 67513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 67523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 67543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 67553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 6757bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy channel[sizeof(size_t)]; 67583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 67603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit color-mapped X canvas. 67613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 67623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 67633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 67643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6765c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 67666710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 67674c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 67683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 67703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67714c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) 67724c08aed51c5899665ade97263692328eea4af106cristy GetPixelIndex(canvas,p)]; 67733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=(int) bytes_per_pixel-1; k >= 0; k--) 67743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy channel[k]=(unsigned char) pixel; 67763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 67773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 67793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=channel[k]; 6780ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 67813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 67833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 67883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 67893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 67913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 67933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 67943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 67963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit continuous-tone X canvas. 67973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 67983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 67993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6800c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 68016710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 68024c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 68033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 68063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68074c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 68083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 68093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 68103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 68123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 6); 68143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 68183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 68203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 68243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 68263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 68303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 68323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 68333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6837ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 68383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 68403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 68443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 68463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 68473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 68483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 68493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit continuous-tone X canvas. 68503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 68513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 68523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6853c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 68546710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 68554c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 68563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 68593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68604c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 68613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 68623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 68633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 68653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 4); 68673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 68713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 68733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 68743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6878ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 68793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 68813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 68853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 68863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 68883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit continuous-tone X canvas. 68893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 68903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 6891cbda611068350bf4459f2dda1951f8823702e129cristy resource_info->quantize_info->dither_method != NoDitherMethod) 68923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68936710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 68943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 68973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6898c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 68996710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 69004c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 69013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69044c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 69053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6906ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 69093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 69133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 69153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 69163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 65536L) && (map_info->green_mult == 256) && 69173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 1)) 69183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 69213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 69233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6924c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 69256710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 69264c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 69273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 69293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 69303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 69333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6937ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 69384c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 6939ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 69404c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6941ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 69424c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 6943ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 69463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 69508bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelRed(canvas,p)); 69518bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelGreen(canvas,p)); 69528bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelBlue(canvas,p)); 6953ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 69583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 69593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 69603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 1) && (map_info->green_mult == 256) && 69613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 65536L)) 69623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 69653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 69673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6968c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 69696710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 69704c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 69713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 69733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 69743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 69773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6981ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 69824c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 6983ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 69844c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6985ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 69864c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 6987ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 69903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 69948bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelBlue(canvas,p)); 69958bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelGreen(canvas,p)); 69968bc259be59a7cde483c27474125272a7d65c5744cristy *q++=ScaleQuantumToChar((Quantum) GetPixelRed(canvas,p)); 6997ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 70023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 70043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 70053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 70073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 70083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 7010bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy channel[sizeof(size_t)]; 70113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 70133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to multi-byte continuous-tone X canvas. 70143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 70153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 70163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 70173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7018c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 70196710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 70204c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 70213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 70223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 70233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70244c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 70253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=(int) bytes_per_pixel-1; k >= 0; k--) 70263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy channel[k]=(unsigned char) pixel; 70283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 70293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 70313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=channel[k]; 7032ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 70333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 70353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 70383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image != (XImage *) NULL) 70413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 70433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize matte canvas. 70443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 70453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (matte_image->bytes_per_line- 70463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((matte_image->width*matte_image->bits_per_pixel) >> 3)); 70473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) matte_image->data; 70483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 70493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7050c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 70516710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 70524c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 70533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 70543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 70553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 70563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 70573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte<<=1; 70594c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelAlpha(canvas,p) > (QuantumRange/2)) 70603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=0x01; 70613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 70623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 70633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 70653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 70663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 70673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7068ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 70693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 70713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte << (8-bit); 70723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 70733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7075c57f694b2d04975a0e501613e34368c464708c19cristy canvas_view=DestroyCacheView(canvas_view); 70763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != image) 70773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=DestroyImage(canvas); 70783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 70793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 70813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 70823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 70833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 70843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 70853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e M a g n i f y I m a g e % 70863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 70873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 70883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 70893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 70903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 70913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeMagnifyImage() magnifies a region of an X image and displays it. 70923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 70933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeMagnifyImage method is: 70943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 70956710d8414f0ed06e4eaf9346366be72e2b4719efcristy% void XMakeMagnifyImage(Display *display,XWindows *windows, 70966710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 70973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 70983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 70993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 71013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 71023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 71043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71056710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 71066710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 71073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 71086710d8414f0ed06e4eaf9346366be72e2b4719efcristyMagickPrivate void XMakeMagnifyImage(Display *display,XWindows *windows, 71096710d8414f0ed06e4eaf9346366be72e2b4719efcristy ExceptionInfo *exception) 71103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 71113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 71123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy tuple[MaxTextExtent]; 71133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 71153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 71163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71174c08aed51c5899665ade97263692328eea4af106cristy PixelInfo 71183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 71193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 71213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 71223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7123bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 71243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 71253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 71273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p, 71283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 71293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71309d314ff2c17a77996c05413c2013880387e50f0ecristy ssize_t 71319d314ff2c17a77996c05413c2013880387e50f0ecristy n; 71329d314ff2c17a77996c05413c2013880387e50f0ecristy 71333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static unsigned int 71343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy previous_magnify = 0; 71353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XWindowInfo 71373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window; 71383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 71403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 71413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 71423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k, 71433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy l, 71443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify, 71453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad, 71463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 71473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 71493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 71503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 71523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Check boundary conditions. 71533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 71543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 71553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 71563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 71573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify=1; 7158bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (n=1; n < (ssize_t) windows->magnify.data; n++) 71593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify<<=1; 71603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((magnify*windows->image.ximage->width) < windows->magnify.width) 71613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify<<=1; 71623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((magnify*windows->image.ximage->height) < windows->magnify.height) 71633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify<<=1; 71643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (magnify > windows->magnify.width) 71653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify>>=1; 71663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (magnify > windows->magnify.height) 71673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify>>=1; 716858a749ec1fc5d48a2ea305d892aa6004454bb5eacristy if (magnify == 0) 716958a749ec1fc5d48a2ea305d892aa6004454bb5eacristy magnify=1; 71703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magnify != previous_magnify) 71713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 71723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 71733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 71743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextProperty 71763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 71773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 71793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy New magnify factor: update magnify window name. 71803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 71813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 71823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((1 << i) <= (int) magnify) 71833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i++; 7184b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(windows->magnify.name,MaxTextExtent, 7185e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy "Magnify %.20gX",(double) i); 71863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XStringListToTextProperty(&windows->magnify.name,1,&window_name); 71873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 71883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 71893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetWMName(display,windows->magnify.id,&window_name); 71903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetWMIconName(display,windows->magnify.id,&window_name); 71913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) window_name.value); 71923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 71933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 71943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy previous_magnify=magnify; 71953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=windows->image.ximage; 71963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) windows->magnify.ximage->width; 71973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) windows->magnify.ximage->height; 71983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->magnify.x < 0) || 71993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->magnify.x >= windows->image.ximage->width)) 72003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.x=windows->image.ximage->width >> 1; 72013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=windows->magnify.x-((width/magnify) >> 1); 72023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 0) 72033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 72043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 72053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x > (int) (ximage->width-(width/magnify))) 72063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ximage->width-width/magnify; 72073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->magnify.y < 0) || 72083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->magnify.y >= windows->image.ximage->height)) 72093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.y=windows->image.ximage->height >> 1; 72103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=windows->magnify.y-((height/magnify) >> 1); 72113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y < 0) 72123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 72133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 72143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y > (int) (ximage->height-(height/magnify))) 72153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=ximage->height-height/magnify; 72163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) windows->magnify.ximage->data; 72173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (windows->magnify.ximage->bytes_per_line- 72183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((width*windows->magnify.ximage->bits_per_pixel) >> 3)); 72193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->bits_per_pixel < 8) 72203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 72223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 72233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte, 72243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground, 72253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit, 72263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit; 72273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 72283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 72293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy plane; 72303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 72313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelInfo 72323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pixel_info; 72333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 72343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel_info=windows->magnify.pixel_info; 72353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bitmap_bit_order) 72363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case LSBFirst: 72383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify little-endian bitmap. 72413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=0x00; 72433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=0x80; 72443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 72453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 72473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->foreground_color) < 72483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->background_color) ? 0x80 : 0x00); 72493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 72503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->background_color) < 72513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->foreground_color) ? 0x80 : 0x00); 72523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->magnify.depth > 1) 72533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Swap(background,foreground); 72543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7255bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 72563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 72593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 72613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 72633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 72643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=(unsigned char) (x*ximage->bits_per_pixel) & 0x07; 72653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 72663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 72673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 72683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 72713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 72733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate each bit plane. 72763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (plane=0; (int) plane < ximage->bits_per_pixel; plane++) 72783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte>>=1; 72803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*p & (0x01 << (p_bit+plane))) 72813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 72823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 72833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 72843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit++; 72853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit == 8) 72863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 72883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 72893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 72903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 72913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 72923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 72933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit+=ximage->bits_per_pixel; 72943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p_bit == 8) 72953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 72973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=0; 72983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 72993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit != 0) 73003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte >> (8-q_bit); 73013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 73023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 73053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 73073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case MSBFirst: 73093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 73103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify big-endian bitmap. 73133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=0x00; 73153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=0x01; 73163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 73173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 73193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->foreground_color) < 73203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->background_color) ? 0x01 : 0x00); 73213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 73223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->background_color) < 73233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->foreground_color) ? 0x01 : 0x00); 73243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->magnify.depth > 1) 73253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Swap(background,foreground); 73263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7327bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 73283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 73313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 73333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 73353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 73363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=(unsigned char) (x*ximage->bits_per_pixel) & 0x07; 73373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 73383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 73393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 73403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 73433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 73453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate each bit plane. 73483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (plane=0; (int) plane < ximage->bits_per_pixel; plane++) 73503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte<<=1; 73523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*p & (0x80 >> (p_bit+plane))) 73533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 73543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 73553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 73563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit++; 73573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit == 8) 73583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 73603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 73613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 73623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit+=ximage->bits_per_pixel; 73663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p_bit == 8) 73673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 73693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=0; 73703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit != 0) 73723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte << (8-q_bit); 73733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 73743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 73773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 73793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 73833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 73843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 73863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 73873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify 8 bit X image. 73903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7391bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 73923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 73953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 73973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 73993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 74003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 74013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 74043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 74063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(*p); 74073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 74083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 74103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 74123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 74143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 74163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 74183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel, 74193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy m; 74203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 74213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify multi-byte X image. 74233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) ximage->bits_per_pixel >> 3; 7425bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 74263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 74293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 74313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 74333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 74343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 74353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 74383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 74403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (m=0; m < bytes_per_pixel; m++) 74413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(*(p+m)); 74423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p+=bytes_per_pixel; 74433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 74453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 74473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 74493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Copy X image to magnify pixmap. 74533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=windows->magnify.x-((width/magnify) >> 1); 74553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 0) 74563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=(int) ((width >> 1)-windows->magnify.x*magnify); 74573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x > (int) (ximage->width-(width/magnify))) 74593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=(int) ((ximage->width-windows->magnify.x)*magnify-(width >> 1)); 74603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 74623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=windows->magnify.y-((height/magnify) >> 1); 74633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y < 0) 74643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=(int) ((height >> 1)-windows->magnify.y*magnify); 74653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y > (int) (ximage->height-(height/magnify))) 74673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=(int) ((ximage->height-windows->magnify.y)*magnify-(height >> 1)); 74683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 74703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((x != 0) || (y != 0)) 74713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillRectangle(display,windows->magnify.pixmap, 74723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,0,0,width,height); 74733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,windows->magnify.pixmap, 74743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,windows->magnify.ximage,0,0,x,y,width-x, 74753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height-y); 74763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((magnify > 1) && ((magnify <= (width >> 1)) && 74773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (magnify <= (height >> 1)))) 74783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 74803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info; 74813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 74823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Highlight center pixel. 74843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7485bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy highlight_info.x=(ssize_t) windows->magnify.width >> 1; 7486bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy highlight_info.y=(ssize_t) windows->magnify.height >> 1; 74873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info.width=magnify; 74883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info.height=magnify; 74893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,windows->magnify.pixmap, 74903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.highlight_context,(int) highlight_info.x, 74913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info.y,(unsigned int) highlight_info.width-1, 74923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info.height-1); 74933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magnify > 2) 74943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,windows->magnify.pixmap, 74953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,(int) highlight_info.x+1, 74963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info.y+1,(unsigned int) highlight_info.width-3, 74973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info.height-3); 74983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 75003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Show center pixel color. 75013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 75023aa9375ebfc21a5356d6b1754bcd1b162ad666c4cristy (void) GetOneVirtualPixelInfo(windows->image.image,TileVirtualPixelMethod, 75035201002e1ba0118594060d26142b48bdfb1320a2cristy (ssize_t) windows->magnify.x,(ssize_t) windows->magnify.y,&pixel,exception); 7504b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(tuple,MaxTextExtent,"%d,%d: ", 75053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.x,windows->magnify.y); 75063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,"(",MaxTextExtent); 7507ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,tuple); 75083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7509ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,tuple); 75103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7511ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,tuple); 75123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel.colorspace == CMYKColorspace) 75133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 75143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7515ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,BlackPixelChannel,X11Compliance,tuple); 75163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 751717f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy if (pixel.alpha_trait != UndefinedPixelTrait) 75183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 75193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7520ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,AlphaPixelChannel,X11Compliance,tuple); 75213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 75223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,")",MaxTextExtent); 75233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) windows->magnify.font_info->ascent+ 75243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.font_info->descent; 75253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=windows->magnify.font_info->max_bounds.width >> 1; 75263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=windows->magnify.font_info->ascent+(height >> 2); 75273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,windows->magnify.pixmap, 75283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple)); 75293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GetColorTuple(&pixel,MagickTrue,tuple); 75303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y+=height; 75313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,windows->magnify.pixmap, 75323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple)); 7533269c9413034627692b2a7d0a352f9dee4e8eada8cristy (void) QueryColorname(windows->image.image,&pixel,SVGCompliance,tuple, 75346710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 75353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y+=height; 75363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,windows->magnify.pixmap, 75373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple)); 75383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 75393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Refresh magnify window. 75403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 75413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window=windows->magnify; 75423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window.x=0; 75433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window.y=0; 75443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRefreshWindow(display,&magnify_window,(XEvent *) NULL); 75453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 75463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 75473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 75483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 75493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e P i x m a p % 75533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 75573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakePixmap() creates an X11 pixmap. 75593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakePixmap method is: 75613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XMakeStandardColormap(Display *display,XVisualInfo *visual_info, 75633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info,Image *image,XStandardColormap *map_info, 75643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XPixelInfo *pixel) 75653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 75673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 75693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 75713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 75723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 75743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 75763ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType XMakePixmap(Display *display, 75773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,XWindowInfo *window) 75783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 75793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 75803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 75813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 75823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 75833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 75843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 75853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 75863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 75873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixmap != (Pixmap) NULL) 75883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 75893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 75903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Destroy previous X pixmap. 75913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 75923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->pixmap); 75933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixmap=(Pixmap) NULL; 75943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 75953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->use_pixmap == MagickFalse) 75963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 75973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage == (XImage *) NULL) 75983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 75993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Display busy cursor. 76013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->busy_cursor); 76033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 76043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create pixmap. 76063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) window->ximage->width; 76083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) window->ximage->height; 76093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixmap=XCreatePixmap(display,window->id,width,height,window->depth); 76103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixmap == (Pixmap) NULL) 76113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 76123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Unable to allocate pixmap. 76143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 76163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 76173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 76183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Copy X image to pixmap. 76203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 76223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory) 76233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XShmPutImage(display,window->pixmap,window->annotate_context, 76243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,0,0,0,0,width,height,MagickTrue); 76253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 76263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 76273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,window->pixmap,window->annotate_context, 76283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,0,0,0,0,width,height); 76293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 76303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 76313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Pixmap:"); 76323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," width, height: %ux%u", 76333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width,height); 76343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 76353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restore cursor. 76373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 76393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 76403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 76413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 76423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 76433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 76443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e S t a n d a r d C o l o r m a p % 76483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 76523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeStandardColormap() creates an X11 Standard Colormap. 76543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeStandardColormap method is: 76563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76576710d8414f0ed06e4eaf9346366be72e2b4719efcristy% void XMakeStandardColormap(Display *display,XVisualInfo *visual_info, 76586710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XResourceInfo *resource_info,Image *image,XStandardColormap *map_info, 76596710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XPixelInfo *pixel,ExceptionInfo *exception) 76603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 76623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 76643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 76653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 76673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 76683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 76703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 76723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If a Standard Colormap type is specified, this structure is 76743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% initialized with info from the Standard Colormap. 76753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 76773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76786710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 76796710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 76803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 76813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 76823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 76833ed852eea50f9d4cd633efb8c2b054b8e33c253cristyextern "C" { 76843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 76853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7686a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristystatic inline double DiversityPixelIntensity( 76873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const DiversityPacket *pixel) 76883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7689a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy double 76903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy intensity; 76913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7692d3d2a275f6aeefb07eac111782edddfa085964f9cristy intensity=0.212656*pixel->red+0.715158*pixel->green+0.072186*pixel->blue; 76933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(intensity); 76943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 76953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 76963ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int IntensityCompare(const void *x,const void *y) 76973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 76983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPacket 76993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_1, 77003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_2; 77013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 77033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity; 77043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_1=(DiversityPacket *) x; 77063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_2=(DiversityPacket *) y; 77073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity=(int) (DiversityPixelIntensity(color_2)- 77083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPixelIntensity(color_1)); 77093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(diversity); 77103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77123ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int PopularityCompare(const void *x,const void *y) 77133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPacket 77153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_1, 77163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_2; 77173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_1=(DiversityPacket *) x; 77193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_2=(DiversityPacket *) y; 77203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((int) color_2->count-(int) color_1->count); 77213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 77243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 77263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7727bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic inline Quantum ScaleXToQuantum(const size_t x, 7728bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy const size_t scale) 77293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7730a19f1d70e9a9f88279c4ecafe6dfafc1f9a09599cristy return((Quantum) (((double) QuantumRange*x)/scale+0.5)); 77313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7733bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XMakeStandardColormap(Display *display, 77343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualInfo *visual_info,XResourceInfo *resource_info,Image *image, 77356710d8414f0ed06e4eaf9346366be72e2b4719efcristy XStandardColormap *map_info,XPixelInfo *pixel,ExceptionInfo *exception) 77363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 77383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 77393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7740bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 77413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 77423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 77443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 77453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7746bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 77473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors, 77483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors; 77493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned short 77513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value; 77523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 77543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color, 77553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colors, 77563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 77573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 77593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 77603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 77613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 77623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 77633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 77643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->map_type != (char *) NULL) 77653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 77663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 77673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Standard Colormap is already defined (i.e. xstdcmap). 77683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 77694c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,resource_info,image, 77703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel); 77713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=(unsigned int) (map_info->base_pixel+ 77723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_max+1)*(map_info->green_max+1)*(map_info->blue_max+1)); 77733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((map_info->red_max*map_info->green_max*map_info->blue_max) != 0) 777417f11b056210f082a6d0e54ac5d68e6d72fa76b2cristy if ((image->alpha_trait == UndefinedPixelTrait) && 77753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (resource_info->color_recovery == MagickFalse) && 7776cbda611068350bf4459f2dda1951f8823702e129cristy (resource_info->quantize_info->dither_method != NoDitherMethod) && 77773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_colors < MaxColormapSize)) 77783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 77793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 77803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *affinity_image; 77813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77824c08aed51c5899665ade97263692328eea4af106cristy register Quantum 7783c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 77843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 77863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Improve image appearance with error diffusion. 77873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 77886710d8414f0ed06e4eaf9346366be72e2b4719efcristy affinity_image=AcquireImage((ImageInfo *) NULL,exception); 77893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (affinity_image == (Image *) NULL) 77903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 77913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToDitherImage",image->filename); 77923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affinity_image->columns=number_colors; 77933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affinity_image->rows=1; 77943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 77953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize colormap image. 77963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 77973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(affinity_image,0,0,affinity_image->columns, 77983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1,exception); 77994c08aed51c5899665ade97263692328eea4af106cristy if (q != (Quantum *) NULL) 78003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7801bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 78023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78034c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(affinity_image,0,q); 78043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->red_max != 0) 7805534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy SetPixelRed(affinity_image,ScaleXToQuantum((size_t) 7806534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (i/map_info->red_mult),map_info->red_max),q); 78074c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(affinity_image,0,q); 78083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->green_max != 0) 7809534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy SetPixelGreen(affinity_image,ScaleXToQuantum((size_t) 7810534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ((i/map_info->green_mult) % (map_info->green_max+1)), 7811534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy map_info->green_max),q); 78124c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(affinity_image,0,q); 78133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 7814534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy SetPixelBlue(affinity_image,ScaleXToQuantum((size_t) 7815534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (i % map_info->green_mult),map_info->blue_max),q); 78164c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(affinity_image, 78174c08aed51c5899665ade97263692328eea4af106cristy TransparentAlpha,q); 7818ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(affinity_image); 78193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SyncAuthenticPixels(affinity_image,exception); 78213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemapImage(resource_info->quantize_info,image, 7822018f07f7333b25743d0afff892450cebdb905c1acristy affinity_image,exception); 78233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78244c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,resource_info,image, 78253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel); 7826574cc26500992189f637cd1cdf93d0654e7df7aecristy (void) SetImageStorageClass(image,DirectClass,exception); 78273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affinity_image=DestroyImage(affinity_image); 78283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 78303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "Standard Colormap:"); 78333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " colormap id: 0x%lx",map_info->colormap); 78353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue max: %lu %lu %lu",map_info->red_max, 78373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max,map_info->blue_max); 78383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue mult: %lu %lu %lu",map_info->red_mult, 78403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_mult,map_info->blue_mult); 78413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 78433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass != DirectColor) && 78453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass != TrueColor)) 78463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->storage_class == DirectClass) || 78473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((int) image->colors > visual_info->colormap_size)) 78483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantizeInfo 78503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy quantize_info; 78513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 78523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image has more colors than the visual supports. 78543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy quantize_info=(*resource_info->quantize_info); 7856bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy quantize_info.number_colors=(size_t) visual_info->colormap_size; 7857018f07f7333b25743d0afff892450cebdb905c1acristy (void) QuantizeImage(&quantize_info,image,exception); 78583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free previous and create new colormap. 78613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeStandardColormap(display,visual_info,map_info,pixel); 78633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XDefaultColormap(display,visual_info->screen); 78643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->visual != XDefaultVisual(display,visual_info->screen)) 78653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XCreateColormap(display,XRootWindow(display,visual_info->screen), 78663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->visual,visual_info->klass == DirectColor ? 78673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AllocAll : AllocNone); 78683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colormap == (Colormap) NULL) 78693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError,"UnableToCreateColormap", 78703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 78713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize the map and pixel info structures. 78733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGetMapInfo(visual_info,colormap,map_info); 78754c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,resource_info,image,pixel); 78763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocating colors in server colormap is based on visual class. 78783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (visual_info->klass) 78803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticGray: 78823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticColor: 78833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard Colormap for StaticGray or StaticColor visual. 78863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=image->colors; 78883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory((size_t) 78893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,sizeof(*colors)); 78903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 78913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 78923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 78933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 78943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 7895bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 78963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=ScaleQuantumToShort(XRedGamma(image->colormap[i].red)); 78983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=ScaleQuantumToShort(XGreenGamma(image->colormap[i].green)); 78993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=ScaleQuantumToShort(XBlueGamma(image->colormap[i].blue)); 79003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != StaticColor) 79013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 79033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 79043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 79053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 79063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XAllocColor(display,colormap,&color); 79083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 79093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XCopyColormapAndFree(display,colormap); 79113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&color); 79123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[i]=color.pixel; 79143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 79153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 79173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case GrayScale: 79193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PseudoColor: 79203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 79223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_type; 79233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard Colormap for GrayScale or PseudoColor visual. 79263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=image->colors; 79283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory((size_t) 79293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,sizeof(*colors)); 79303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 79313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 79323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 79333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Preallocate our GUI colors. 79353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->foreground_color); 79373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->background_color); 79383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->border_color); 79393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->matte_color); 79403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->highlight_color); 79413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->shadow_color); 79423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->depth_color); 79433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->trough_color); 79443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 79453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->pen_colors[i]); 79463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine if image colors will "fit" into X server colormap. 79483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_type=resource_info->colormap; 7950f2faecf9facdbbb14fcba373365f9f691a9658e0cristy status=XAllocColorCells(display,colormap,MagickFalse,(unsigned long *) 79513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy NULL,0,pixel->pixels,(unsigned int) image->colors); 79523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 79533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_type=PrivateColormap; 79543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colormap_type == SharedColormap) 79553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7956c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 7957c57f694b2d04975a0e501613e34368c464708c19cristy *image_view; 7958c57f694b2d04975a0e501613e34368c464708c19cristy 79593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPacket 79603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *diversity; 79613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 79633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 79643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 79663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 79673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned short 79693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index; 79703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 79723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *server_colors; 79733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard colormap for shared GrayScale or PseudoColor visual. 79763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity=(DiversityPacket *) AcquireQuantumMemory(image->colors, 79783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*diversity)); 79793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (diversity == (DiversityPacket *) NULL) 79803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 79813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 7982bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 79833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7984e42f658533644aecb733785ffd91b286d6778deacristy diversity[i].red=ClampToQuantum(image->colormap[i].red); 7985e42f658533644aecb733785ffd91b286d6778deacristy diversity[i].green=ClampToQuantum(image->colormap[i].green); 7986e42f658533644aecb733785ffd91b286d6778deacristy diversity[i].blue=ClampToQuantum(image->colormap[i].blue); 79873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[i].index=(unsigned short) i; 79883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[i].count=0; 79893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 799046ff2676b1044ea4101ac7a59b83289cd8f6cfdacristy image_view=AcquireAuthenticCacheView(image,exception); 79913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) image->rows; y++) 79923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7993c57f694b2d04975a0e501613e34368c464708c19cristy register int 79943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 79953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79964c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 7997c57f694b2d04975a0e501613e34368c464708c19cristy *restrict p; 79983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7999c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewAuthenticPixels(image_view,0,(ssize_t) y, 8000c57f694b2d04975a0e501613e34368c464708c19cristy image->columns,1,exception); 80014c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 80023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 8003c57f694b2d04975a0e501613e34368c464708c19cristy for (x=(int) image->columns-1; x >= 0; x--) 80044c08aed51c5899665ade97263692328eea4af106cristy { 80054c08aed51c5899665ade97263692328eea4af106cristy diversity[(ssize_t) GetPixelIndex(image,p)].count++; 8006ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(image); 80074c08aed51c5899665ade97263692328eea4af106cristy } 80083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8009c57f694b2d04975a0e501613e34368c464708c19cristy image_view=DestroyCacheView(image_view); 80103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Sort colors by decreasing intensity. 80123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy qsort((void *) diversity,image->colors,sizeof(*diversity), 80143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy IntensityCompare); 8015bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; ) 80163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[i].count<<=4; /* increase this colors popularity */ 8018dfe2b6658f367de8f84405263f62768fb853adafcristy i+=MagickMax((int) (image->colors >> 4),2); 80193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[image->colors-1].count<<=4; 80213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy qsort((void *) diversity,image->colors,sizeof(*diversity), 80223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PopularityCompare); 80233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate colors. 80253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 80273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 8028bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 80293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=diversity[i].index; 80313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red= 80323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XRedGamma(image->colormap[index].red)); 80333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green= 80343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XGreenGamma(image->colormap[index].green)); 80353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue= 80363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XBlueGamma(image->colormap[index].blue)); 80373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != PseudoColor) 80383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 80403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 80413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 80423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 80433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XAllocColor(display,colormap,&color); 80453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 80463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 80473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[index]=color.pixel; 80483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 80493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Read X server colormap. 80523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_colors=(XColor *) AcquireQuantumMemory((size_t) 80543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,sizeof(*server_colors)); 80553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (server_colors == (XColor *) NULL) 80563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 80573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 80583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=visual_info->colormap_size-1; x >= 0; x--) 8059bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy server_colors[x].pixel=(size_t) x; 80603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display,colormap,server_colors, 80613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) MagickMin((unsigned int) visual_info->colormap_size,256)); 80623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select remaining colors from X server colormap. 80643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8065bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (; i < (ssize_t) image->colors; i++) 80663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=diversity[i].index; 8068534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy color.red=ScaleQuantumToShort( 8069534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XRedGamma(image->colormap[index].red)); 8070534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy color.green=ScaleQuantumToShort( 8071534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XGreenGamma(image->colormap[index].green)); 8072534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy color.blue=ScaleQuantumToShort( 8073534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XBlueGamma(image->colormap[index].blue)); 80743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != PseudoColor) 80753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 80773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 80783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 80793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 80803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,server_colors,(unsigned int) 80823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,&color); 80833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[index]=color.pixel; 80843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 80853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) image->colors < visual_info->colormap_size) 80873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Fill up colors array-- more choices for pen colors. 80903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors=MagickMin((unsigned int) 80923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->colormap_size-image->colors),256); 8093bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) retain_colors; i++) 80943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=server_colors[i]; 80953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors+=retain_colors; 80963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_colors=(XColor *) RelinquishMagickMemory(server_colors); 80983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity=(DiversityPacket *) RelinquishMagickMemory(diversity); 80993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 81003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard colormap for private GrayScale or PseudoColor visual. 81033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 81053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Not enough colormap entries in the colormap-- Create a new colormap. 81083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XCreateColormap(display, 81103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRootWindow(display,visual_info->screen),visual_info->visual, 81113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AllocNone); 81123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colormap == (Colormap) NULL) 81133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 81143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 81153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=colormap; 81163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) image->colors < visual_info->colormap_size) 81173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Retain colors from the default colormap to help lessens the 81203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy effects of colormap flashing. 81213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors=MagickMin((unsigned int) 81233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->colormap_size-image->colors),256); 81243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors+image->colors; 8125bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) retain_colors; i++) 81263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8127c57f694b2d04975a0e501613e34368c464708c19cristy p->pixel=(unsigned long) i; 81283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 81293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display, 81313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultColormap(display,visual_info->screen), 81323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors+image->colors,(int) retain_colors); 81333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Transfer colors from default to private colormap. 81353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColorCells(display,colormap,MagickFalse, 8137f2faecf9facdbbb14fcba373365f9f691a9658e0cristy (unsigned long *) NULL,0,pixel->pixels,(unsigned int) 81383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors); 81393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors+image->colors; 8140bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) retain_colors; i++) 81413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->pixel=pixel->pixels[i]; 81433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 81443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XStoreColors(display,colormap,colors+image->colors, 81463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) retain_colors); 81473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors+=retain_colors; 81483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColorCells(display,colormap,MagickFalse, 8150f2faecf9facdbbb14fcba373365f9f691a9658e0cristy (unsigned long *) NULL,0,pixel->pixels,(unsigned int) 81513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors); 81523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Store the image colormap. 81553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 81573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 8158bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 81593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=ScaleQuantumToShort(XRedGamma(image->colormap[i].red)); 81613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=ScaleQuantumToShort(XGreenGamma(image->colormap[i].green)); 81623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=ScaleQuantumToShort(XBlueGamma(image->colormap[i].blue)); 81633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != PseudoColor) 81643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 81663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 81673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 81683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 81693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=pixel->pixels[i]; 81713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 81723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XStoreColors(display,colormap,colors,(int) image->colors); 81743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 81753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case TrueColor: 81773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case DirectColor: 81783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 81793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 81813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy linear_colormap; 81823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 81833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard Colormap for TrueColor or DirectColor visual. 81853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=(unsigned int) ((map_info->red_max*map_info->red_mult)+ 81873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max*map_info->green_mult)+ 81883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_max*map_info->blue_mult)+1); 81893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy linear_colormap=(number_colors > 4096) || 81903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (((int) (map_info->red_max+1) == visual_info->colormap_size) && 81913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((int) (map_info->green_max+1) == visual_info->colormap_size) && 81923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((int) (map_info->blue_max+1) == visual_info->colormap_size)) ? 81933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickTrue : MagickFalse; 81943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (linear_colormap != MagickFalse) 8195bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy number_colors=(size_t) visual_info->colormap_size; 81963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate color array. 81983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory(number_colors,sizeof(*colors)); 82003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 82013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 82023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 82033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize linear color ramp. 82053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 82073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 82083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (linear_colormap != MagickFalse) 8209bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 82103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=(unsigned short) 0; 82123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 8213bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.blue=(unsigned short) ((size_t) 82143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*(i % map_info->green_mult))/map_info->blue_max)); 82153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=color.blue; 82163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=color.blue; 82173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=XStandardPixel(map_info,&color); 82183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 82193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 8221bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 82223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=(unsigned short) 0; 82243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->red_max != 0) 8225bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.red=(unsigned short) ((size_t) 82263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*(i/map_info->red_mult))/map_info->red_max)); 82273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=(unsigned int) 0; 82283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->green_max != 0) 8229bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.green=(unsigned short) ((size_t) 82303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*((i/map_info->green_mult) % (map_info->green_max+1)))/ 82313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max)); 82323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=(unsigned short) 0; 82333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 8234bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.blue=(unsigned short) ((size_t) 82353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*(i % map_info->green_mult))/map_info->blue_max)); 82363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=XStandardPixel(map_info,&color); 82373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 82383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass == DirectColor) && 82403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (colormap != XDefaultColormap(display,visual_info->screen))) 82413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XStoreColors(display,colormap,colors,(int) number_colors); 82423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 8243bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 82443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&colors[i]); 82453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 82463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass != DirectColor) && 82493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass != TrueColor)) 82503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set foreground, background, border, etc. pixels. 82533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->foreground_color); 82563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->background_color); 82583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel->background_color.pixel == pixel->foreground_color.pixel) 82593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Foreground and background colors must differ. 82623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.red=(~pixel->foreground_color.red); 82643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.green= 82653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~pixel->foreground_color.green); 82663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.blue= 82673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~pixel->foreground_color.blue); 82683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->background_color); 82703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->border_color); 82733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->matte_color); 82753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->highlight_color); 82773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->shadow_color); 82793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->depth_color); 82813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->trough_color); 82833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 82843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->pen_colors[i]); 82873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[image->colors+i]=pixel->pen_colors[i].pixel; 82883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8289c57f694b2d04975a0e501613e34368c464708c19cristy pixel->colors=(ssize_t) (image->colors+MaxNumberPens); 82903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) RelinquishMagickMemory(colors); 82923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 82933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Standard Colormap:"); 82953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," colormap id: 0x%lx", 82963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap); 82973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 82983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue max: %lu %lu %lu",map_info->red_max, 82993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max,map_info->blue_max); 83003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 83013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue mult: %lu %lu %lu",map_info->red_mult, 83023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_mult,map_info->blue_mult); 83033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 83043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 83053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 83073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e W i n d o w % 83123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeWindow() creates an X11 window. 83183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeWindow method is: 83203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XMakeWindow(Display *display,Window parent,char **argv,int argc, 83223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClassHint *class_hint,XWMHints *manager_hints, 83233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowInfo *window_info) 83243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 83263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 83283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 83293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o parent: Specifies the parent window_info. 83313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o argv: Specifies the application's argument list. 83333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o argc: Specifies the number of arguments. 83353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o class_hint: Specifies a pointer to a X11 XClassHint structure. 83373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o manager_hints: Specifies a pointer to a X11 XWMHints structure. 83393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window_info: Specifies a pointer to a X11 XWindowInfo structure. 83413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8343bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XMakeWindow(Display *display,Window parent,char **argv, 83443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int argc,XClassHint *class_hint,XWMHints *manager_hints, 83453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowInfo *window_info) 83463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 83473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define MinWindowSize 64 83483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 83503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy atom_list[2]; 83513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 83533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gravity; 83543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XTextProperty 83563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_name, 83573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 83583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 83603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 83613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSizeHints 83633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *size_hints; 83643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 83663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set window info hints. 83673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 83683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 83693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 83703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window_info != (XWindowInfo *) NULL); 83713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints=XAllocSizeHints(); 83723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (size_hints == (XSizeHints *) NULL) 83733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToMakeXWindow",argv[0]); 8374dfe2b6658f367de8f84405263f62768fb853adafcristy size_hints->flags=(int) window_info->flags; 83753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->x=window_info->x; 83763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->y=window_info->y; 83773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->width=(int) window_info->width; 83783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->height=(int) window_info->height; 83793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->immutable != MagickFalse) 83803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 83813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 83823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window size cannot be changed. 83833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 83843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_width=size_hints->width; 83853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_height=size_hints->height; 83863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->max_width=size_hints->width; 83873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->max_height=size_hints->height; 83883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PMinSize; 83893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PMaxSize; 83903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 83913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 83923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 83933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 83943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window size can be changed. 83953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 83963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_width=(int) window_info->min_width; 83973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_height=(int) window_info->min_height; 83983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PResizeInc; 83993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->width_inc=(int) window_info->width_inc; 84003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->height_inc=(int) window_info->height_inc; 84013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(PRE_R4_ICCCM) 84023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PBaseSize; 84033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->base_width=size_hints->width_inc; 84043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->base_height=size_hints->height_inc; 84053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 84063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gravity=NorthWestGravity; 84083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->geometry != (char *) NULL) 84093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 84113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default_geometry[MaxTextExtent], 84123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry[MaxTextExtent]; 84133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 84153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 84163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 84183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 84193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 84213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy User specified geometry. 84223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8423b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(default_geometry,MaxTextExtent,"%dx%d", 84243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->width,size_hints->height); 84253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(geometry,window_info->geometry,MaxTextExtent); 84263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=geometry; 84273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (strlen(p) != 0) 84283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((isspace((int) ((unsigned char) *p)) == 0) && (*p != '%')) 84303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 84313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 84323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(p,p+1,MaxTextExtent); 84333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=XWMGeometry(display,window_info->screen,geometry,default_geometry, 84353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->border_width,size_hints,&size_hints->x,&size_hints->y, 84363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &size_hints->width,&size_hints->height,&gravity); 84373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & WidthValue) && (flags & HeightValue)) 84383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=USSize; 84393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & XValue) && (flags & YValue)) 84403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=USPosition; 84423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->x=size_hints->x; 84433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->y=size_hints->y; 84443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(PRE_R4_ICCCM) 84473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->win_gravity=gravity; 84483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PWinGravity; 84493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 84503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id == (Window) NULL) 84513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->id=XCreateWindow(display,parent,window_info->x,window_info->y, 84523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) size_hints->width,(unsigned int) size_hints->height, 84533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->border_width,(int) window_info->depth,InputOutput, 8454c57f694b2d04975a0e501613e34368c464708c19cristy window_info->visual,(unsigned long) window_info->mask, 8455c57f694b2d04975a0e501613e34368c464708c19cristy &window_info->attributes); 84563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 84573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickStatusType 84593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask; 84603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 84623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sans_event; 84633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowChanges 84653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes; 84663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 84683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window already exists; change relevant attributes. 84693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8470c57f694b2d04975a0e501613e34368c464708c19cristy (void) XChangeWindowAttributes(display,window_info->id,(unsigned long) 8471c57f694b2d04975a0e501613e34368c464708c19cristy window_info->mask,&window_info->attributes); 84723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask=ConfigureNotify; 84733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,window_info->id,(int) mask,&sans_event)) ; 84743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.x=window_info->x; 84753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.y=window_info->y; 84763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.width=(int) window_info->width; 84773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.height=(int) window_info->height; 84783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask=(MagickStatusType) (CWWidth | CWHeight); 84793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->flags & USPosition) 84803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask|=CWX | CWY; 84813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XReconfigureWMWindow(display,window_info->id,window_info->screen, 84823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask,&window_changes); 84833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id == (Window) NULL) 84853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToCreateWindow", 84863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->name); 84873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XStringListToTextProperty(&window_info->name,1,&window_name); 84883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 84893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToCreateTextProperty", 84903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->name); 84913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XStringListToTextProperty(&window_info->icon_name,1,&icon_name); 84923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 84933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToCreateTextProperty", 84943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->icon_name); 84953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->icon_geometry != (char *) NULL) 84963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 84983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags, 84993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 85003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 85013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 85033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy User specified icon geometry. 85043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 85053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=USPosition; 85063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=XWMGeometry(display,window_info->screen,window_info->icon_geometry, 85073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,0,size_hints,&manager_hints->icon_x, 85083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &manager_hints->icon_y,&width,&height,&gravity); 85093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & XValue) && (flags & YValue)) 85103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy manager_hints->flags|=IconPositionHint; 85113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetWMProperties(display,window_info->id,&window_name,&icon_name,argv,argc, 85133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints,manager_hints,class_hint); 85143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_name.value != (void *) NULL) 85153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) window_name.value); 85173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name.value=(unsigned char *) NULL; 85183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name.nitems=0; 85193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_name.value != (void *) NULL) 85213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) icon_name.value); 85233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_name.value=(unsigned char *) NULL; 85243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_name.nitems=0; 85253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy atom_list[0]=XInternAtom(display,"WM_DELETE_WINDOW",MagickFalse); 85273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy atom_list[1]=XInternAtom(display,"WM_TAKE_FOCUS",MagickFalse); 85283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWMProtocols(display,window_info->id,atom_list,2); 85293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) size_hints); 85303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->shape != MagickFalse) 85313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 85333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 85343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy error_base, 85353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event_base; 85363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 85383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Can we apply a non-rectangular shaping mask? 85393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 85403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy error_base=0; 85413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event_base=0; 85423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XShapeQueryExtension(display,&error_base,&event_base) == 0) 85433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shape=MagickFalse; 85443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 85453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shape=MagickFalse; 85463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 85473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->shared_memory) 85493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 85513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 85523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Can we use shared memory with this window? 85533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 85543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XShmQueryExtension(display) == 0) 85553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shared_memory=MagickFalse; 85563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 85573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shared_memory=MagickFalse; 85583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 85593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->image=NewImageList(); 85613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->destroy=MagickFalse; 85623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 85633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 85653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 85663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a g i c k P r o g r e s s M o n i t o r % 85703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 85743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMagickProgressMonitor() displays the progress a task is making in 85763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% completing a task. 85773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMagickProgressMonitor method is: 85793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XMagickProgressMonitor(const char *task, 85813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const MagickOffsetType quantum,const MagickSizeType span, 85823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void *client_data) 85833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 85853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o task: Identifies the task in progress. 85873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o quantum: Specifies the quantum position within the span which represents 85893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% how much progress has been made in completing a task. 85903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o span: Specifies the span relative to completing a task. 85923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_data: Pointer to any client data. 85943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 85963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85973ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic const char *GetLocaleMonitorMessage(const char *text) 85983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 85993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 86003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy message[MaxTextExtent], 86013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy tag[MaxTextExtent]; 86023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char 86043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *locale_message; 86053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 86073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 86083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(tag,text,MaxTextExtent); 86103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=strrchr(tag,'/'); 86113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p != (char *) NULL) 86123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p='\0'; 8613b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); 86143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy locale_message=GetLocaleMessage(message); 86153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (locale_message == message) 86163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(text); 86173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(locale_message); 86183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 86193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8620bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XMagickProgressMonitor(const char *tag, 86213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const MagickOffsetType quantum,const MagickSizeType span, 86223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy void *magick_unused(client_data)) 86233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 86243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 86253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 86263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=XSetWindows((XWindows *) ~0); 86283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows == (XWindows *) NULL) 86293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 86303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->info.mapped != MagickFalse) 86313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XProgressMonitorWidget(windows->display,windows, 86323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GetLocaleMonitorMessage(tag),quantum,span); 86333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 86343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 86353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 86373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X Q u e r y C o l o r D a t a b a s e % 86423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86479950d57e1124b73f684fb5946e206994cefda628cristy% XQueryColorCompliance() looks up a RGB values for a color given in the target 86483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% string. 86493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XQueryColorDatabase method is: 86513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86529950d57e1124b73f684fb5946e206994cefda628cristy% MagickBooleanType XQueryColorCompliance(const char *target,XColor *color) 86533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 86553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o target: Specifies the color to lookup in the X color database. 86573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8658101ab708b0574518ac5715da4d3915400e9df79acristy% o color: A pointer to an PixelInfo structure. The RGB value of the target 86593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% color is returned as this value. 86603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 86629950d57e1124b73f684fb5946e206994cefda628cristyMagickPrivate MagickBooleanType XQueryColorCompliance(const char *target, 86633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor *color) 86643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 86653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 86663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 86673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static Display 86693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *display = (Display *) NULL; 86703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 86723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 86733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 86753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xcolor; 86763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 86783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize color return value. 86793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 86803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(color != (XColor *) NULL); 86813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->red=0; 86823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->green=0; 86833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->blue=0; 86843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->flags=(char) (DoRed | DoGreen | DoBlue); 86853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((target == (char *) NULL) || (*target == '\0')) 86863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target="#ffffffffffff"; 86873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 86883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Let the X server define the color for us. 86893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 86903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 86913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay((char *) NULL); 86923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 86933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8694c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer",target); 86953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 86963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 86973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XDefaultColormap(display,XDefaultScreen(display)); 86983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,(char *) target,&xcolor); 86993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 8700c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"ColorIsNotKnownToServer",target) 87013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 87023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 87033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->red=xcolor.red; 87043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->green=xcolor.green; 87053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->blue=xcolor.blue; 87063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->flags=xcolor.flags; 87073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 87083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status != False ? MagickTrue : MagickFalse); 87093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 87103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 87123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X Q u e r y P o s i t i o n % 87173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XQueryPosition() gets the pointer coordinates relative to a window. 87233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XQueryPosition method is: 87253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XQueryPosition(Display *display,const Window window,int *x,int *y) 87273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 87293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 87313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 87323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window. 87343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o x: Return the x coordinate of the pointer relative to the origin of the 87363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 87373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o y: Return the y coordinate of the pointer relative to the origin of the 87393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 87403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8742534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristyMagickPrivate void XQueryPosition(Display *display,const Window window,int *x, 8743534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy int *y) 87443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 87453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 87463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_root, 87473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_root; 87483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 87503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask; 87513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 87533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 87543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 87563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 87573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 87583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(x != (int *) NULL); 87593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(y != (int *) NULL); 87603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryPointer(display,window,&root_window,&root_window,&x_root,&y_root, 87613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x,y,&mask); 87623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 87633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 87653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X R e f r e s h W i n d o w % 87703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XRefreshWindow() refreshes an image in a X window. 87763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XRefreshWindow method is: 87783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XRefreshWindow(Display *display,const XWindowInfo *window, 87803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XEvent *event) 87813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 87833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 87853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 87863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 87883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o event: Specifies a pointer to a XEvent structure. If it is NULL, 87903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the entire image is refreshed. 87913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8793bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XRefreshWindow(Display *display,const XWindowInfo *window, 87943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XEvent *event) 87953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 87963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 87973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 87983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 87993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 88013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 88023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 88033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 88053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 88063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 88073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage == (XImage *) NULL) 88083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 88093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (event != (XEvent *) NULL) 88103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine geometry from expose event. 88133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=event->xexpose.x; 88153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=event->xexpose.y; 88163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) event->xexpose.width; 88173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) event->xexpose.height; 88183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 88203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 88223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sans_event; 88233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Refresh entire window; discard outstanding expose events. 88263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 88283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 88293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=window->width; 88303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=window->height; 88313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,window->id,Expose,&sans_event)) ; 8832a0e5ad575fbabf93f14a3748ae501376928998fccristy if (window->matte_pixmap != (Pixmap) NULL) 8833a0e5ad575fbabf93f14a3748ae501376928998fccristy { 8834a0e5ad575fbabf93f14a3748ae501376928998fccristy#if defined(MAGICKCORE_HAVE_SHAPE) 8835a0e5ad575fbabf93f14a3748ae501376928998fccristy if (window->shape != MagickFalse) 8836a0e5ad575fbabf93f14a3748ae501376928998fccristy XShapeCombineMask(display,window->id,ShapeBounding,0,0, 8837a0e5ad575fbabf93f14a3748ae501376928998fccristy window->matte_pixmap,ShapeSet); 8838a0e5ad575fbabf93f14a3748ae501376928998fccristy#endif 8839a0e5ad575fbabf93f14a3748ae501376928998fccristy } 88403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Check boundary conditions. 88433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->ximage->width-(x+window->x)) < (int) width) 88453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) (window->ximage->width-(x+window->x)); 88463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->ximage->height-(y+window->y)) < (int) height) 88473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) (window->ximage->height-(y+window->y)); 88483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Refresh image. 88503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 8852a0e5ad575fbabf93f14a3748ae501376928998fccristy (void) XSetClipMask(display,window->annotate_context,window->matte_pixmap); 88533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixmap != (Pixmap) NULL) 88543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->depth > 1) 88563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCopyArea(display,window->pixmap,window->id, 88573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->annotate_context,x+window->x,y+window->y,width,height,x,y); 88583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 88593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCopyPlane(display,window->pixmap,window->id, 88603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->highlight_context,x+window->x,y+window->y,width,height,x,y, 88613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1L); 88623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 88643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 88663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory) 88673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XShmPutImage(display,window->id,window->annotate_context, 88683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,x+window->x,y+window->y,x,y,width,height,MagickTrue); 88693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 88703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 88713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,window->id,window->annotate_context, 88723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,x+window->x,y+window->y,x,y,width,height); 88733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 88753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetClipMask(display,window->annotate_context,None); 88763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 88773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 88783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 88803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 88813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X R e m o t e C o m m a n d % 88853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 88893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XRemoteCommand() forces a remote display(1) to display the specified 88913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% image filename. 88923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XRemoteCommand method is: 88943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XRemoteCommand(Display *display,const char *window, 88963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *filename) 88973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 88993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 89013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 89023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies the name or id of an X window. 89043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o filename: the name of the image filename to display. 89063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 89083ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType XRemoteCommand(Display *display, 89093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *window,const char *filename) 89103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 89113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 89123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_atom; 89133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 89143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 89153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window, 89163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 89173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 89183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(filename != (char *) NULL); 89193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); 89203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 89213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay((char *) NULL); 89223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 89233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 89243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToOpenXServer",filename); 89253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 89263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 89273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_atom=XInternAtom(display,"IM_PROTOCOLS",MagickFalse); 89283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=(Window) NULL; 89293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 89303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window != (char *) NULL) 89313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 89323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 89333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search window hierarchy and identify any clients by name or ID. 89343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 893502e64f85ab79992a87dd6979d4948488fec02817cristy if (isdigit((int) ((unsigned char) *window)) != 0) 89363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=XWindowByID(display,root_window,(Window) 89373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol((char *) window,(char **) NULL,0)); 89383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (remote_window == (Window) NULL) 89393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=XWindowByName(display,root_window,window); 89403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 89413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (remote_window == (Window) NULL) 89423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=XWindowByProperty(display,root_window,remote_atom); 89433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (remote_window == (Window) NULL) 89443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 89453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToConnectToRemoteDisplay", 89463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename); 89473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 89483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 89493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 89503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Send remote command. 89513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 89523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_atom=XInternAtom(display,"IM_REMOTE_COMMAND",MagickFalse); 89533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XChangeProperty(display,remote_window,remote_atom,XA_STRING,8, 89543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PropModeReplace,(unsigned char *) filename,(int) strlen(filename)); 89553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 89563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 89573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 89583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 89593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 89603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 89613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8964534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% X R e n d e r I m a g e % 8965534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 8966534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 8967534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 8968534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8969534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8970534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% XRenderImage() renders text on the image with an X11 font. It also returns 8971534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% the bounding box of the text relative to the image. 8972534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8973534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% The format of the XRenderImage method is: 8974534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8975534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% MagickBooleanType XRenderImage(Image *image,DrawInfo *draw_info, 8976534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 8977534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8978534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% A description of each parameter follows: 8979534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8980534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o image: the image. 8981534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8982534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o draw_info: the draw info. 8983534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8984534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o offset: (x,y) location of text relative to image. 8985534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8986534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o metrics: bounding box of text. 8987534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8988534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o exception: return any errors or warnings in this structure. 8989534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 8990534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy*/ 8991534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristyMagickPrivate MagickBooleanType XRenderImage(Image *image, 8992534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy const DrawInfo *draw_info,const PointInfo *offset,TypeMetric *metrics, 8993534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ExceptionInfo *exception) 8994534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy{ 8995534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy const char 8996534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy *client_name; 8997534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 8998534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy DrawInfo 8999534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy cache_info; 9000534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9001534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Display 9002534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy *display; 9003534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9004534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ImageInfo 9005534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy *image_info; 9006534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9007534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy MagickBooleanType 9008534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy status; 9009534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9010534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy size_t 9011534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy height, 9012534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy width; 9013534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9014534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XAnnotateInfo 9015534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info; 9016534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9017534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XFontStruct 9018534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy *font_info; 9019534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9020534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XPixelInfo 9021534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy pixel; 9022534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9023534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XResourceInfo 9024534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_info; 9025534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9026534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XrmDatabase 9027534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_database; 9028534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9029534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XStandardColormap 9030534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy *map_info; 9031534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9032534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XVisualInfo 9033534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy *visual_info; 9034534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9035534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9036534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Open X server connection. 9037534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9038534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy display=XOpenDisplay(draw_info->server_name); 9039534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (display == (Display *) NULL) 9040534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9041534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ThrowXWindowException(XServerError,"UnableToOpenXServer", 9042534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy draw_info->server_name); 9043534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 9044534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9045534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9046534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Get user defaults from X resource database. 9047534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9048534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) XSetErrorHandler(XError); 9049534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy image_info=AcquireImageInfo(); 9050534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy client_name=GetClientName(); 9051534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_database=XGetResourceDatabase(display,client_name); 9052534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XGetResourceInfo(image_info,resource_database,client_name,&resource_info); 9053534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_info.close_server=MagickFalse; 9054534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_info.colormap=PrivateColormap; 9055534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_info.font=AcquireString(draw_info->font); 9056534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_info.background_color=AcquireString("#ffffffffffff"); 9057534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy resource_info.foreground_color=AcquireString("#000000000000"); 9058534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy map_info=XAllocStandardColormap(); 90595da5d1e6619ecfae6a4258dae7d41fcd94b6a860cristy visual_info=(XVisualInfo *) NULL; 90605da5d1e6619ecfae6a4258dae7d41fcd94b6a860cristy font_info=(XFontStruct *) NULL; 90615da5d1e6619ecfae6a4258dae7d41fcd94b6a860cristy pixel.pixels=(unsigned long *) NULL; 9062534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (map_info == (XStandardColormap *) NULL) 9063534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9064534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 9065534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy image->filename); 9066534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 9067534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9068534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9069534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Initialize visual info. 9070534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9071534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy visual_info=XBestVisualInfo(display,map_info,&resource_info); 9072534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (visual_info == (XVisualInfo *) NULL) 9073534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 90745da5d1e6619ecfae6a4258dae7d41fcd94b6a860cristy XFreeResources(display,visual_info,map_info,&pixel,font_info, 90755da5d1e6619ecfae6a4258dae7d41fcd94b6a860cristy &resource_info,(XWindowInfo *) NULL); 9076c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToGetVisual",image->filename); 9077534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 9078534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9079534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy map_info->colormap=(Colormap) NULL; 9080534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9081534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Initialize Standard Colormap info. 9082534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9083534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XGetMapInfo(visual_info,XDefaultColormap(display,visual_info->screen), 9084534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy map_info); 9085534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XGetPixelInfo(display,visual_info,map_info,&resource_info,(Image *) NULL, 9086534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy &pixel); 9087534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy pixel.annotate_context=XDefaultGC(display,visual_info->screen); 9088534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9089534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Initialize font info. 9090534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9091534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy font_info=XBestFont(display,&resource_info,MagickFalse); 9092534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (font_info == (XFontStruct *) NULL) 9093534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9094534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XFreeResources(display,visual_info,map_info,&pixel,font_info, 9095534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy &resource_info,(XWindowInfo *) NULL); 90965da5d1e6619ecfae6a4258dae7d41fcd94b6a860cristy ThrowXWindowException(XServerError,"UnableToLoadFont",draw_info->font); 9097534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 9098534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9099534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy cache_info=(*draw_info); 9100534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9101534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Initialize annotate info. 9102534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9103534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy XGetAnnotateInfo(&annotate_info); 9104534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info.stencil=ForegroundStencil; 9105534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (cache_info.font != draw_info->font) 9106534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9107534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9108534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Type name has changed. 9109534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9110534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) XFreeFont(display,font_info); 9111534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) CloneString(&resource_info.font,draw_info->font); 9112534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy font_info=XBestFont(display,&resource_info,MagickFalse); 9113534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (font_info == (XFontStruct *) NULL) 9114534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9115534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ThrowXWindowException(XServerError,"UnableToLoadFont", 9116534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy draw_info->font); 9117534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 9118534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9119534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9120534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (image->debug != MagickFalse) 9121534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) LogMagickEvent(AnnotateEvent,GetMagickModule(), 9122534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy "Font %s; pointsize %g",draw_info->font != (char *) NULL ? 9123534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy draw_info->font : "none",draw_info->pointsize); 9124534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy cache_info=(*draw_info); 9125534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info.font_info=font_info; 9126534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info.text=(char *) draw_info->text; 9127534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info.width=(unsigned int) XTextWidth(font_info,draw_info->text,(int) 9128534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy strlen(draw_info->text)); 9129534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info.height=(unsigned int) font_info->ascent+font_info->descent; 9130534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->pixels_per_em.x=(double) font_info->max_bounds.width; 9131534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->pixels_per_em.y=(double) font_info->ascent+font_info->descent; 9132534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->ascent=(double) font_info->ascent+4; 9133534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->descent=(double) (-font_info->descent); 9134534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->width=annotate_info.width/ExpandAffine(&draw_info->affine); 9135534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->height=font_info->ascent+font_info->descent; 9136534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->max_advance=(double) font_info->max_bounds.width; 9137534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->bounds.x1=0.0; 9138534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->bounds.y1=metrics->descent; 9139534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->bounds.x2=metrics->ascent+metrics->descent; 9140534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->bounds.y2=metrics->ascent+metrics->descent; 9141534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->underline_position=(-2.0); 9142534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy metrics->underline_thickness=1.0; 9143534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (draw_info->render == MagickFalse) 9144534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickTrue); 9145534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (draw_info->fill.alpha == TransparentAlpha) 9146534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickTrue); 9147534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy /* 9148534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy Render fill color. 9149534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy */ 9150534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy width=annotate_info.width; 9151534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy height=annotate_info.height; 9152534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if ((fabs(draw_info->affine.rx) >= MagickEpsilon) || 9153534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (fabs(draw_info->affine.ry) >= MagickEpsilon)) 9154534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9155534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if ((fabs(draw_info->affine.sx-draw_info->affine.sy) < MagickEpsilon) && 9156534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (fabs(draw_info->affine.rx+draw_info->affine.ry) < MagickEpsilon)) 9157534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy annotate_info.degrees=(double) (180.0/MagickPI)* 9158534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy atan2(draw_info->affine.rx,draw_info->affine.sx); 9159534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9160534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) FormatLocaleString(annotate_info.geometry,MaxTextExtent, 9161534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy "%.20gx%.20g%+.20g%+.20g",(double) width,(double) height, 9162534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ceil(offset->x-0.5),ceil(offset->y-metrics->ascent-metrics->descent+ 9163534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy draw_info->interline_spacing-0.5)); 9164534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy pixel.pen_color.red=ScaleQuantumToShort(draw_info->fill.red); 9165534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy pixel.pen_color.green=ScaleQuantumToShort(draw_info->fill.green); 9166534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy pixel.pen_color.blue=ScaleQuantumToShort(draw_info->fill.blue); 9167534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy status=XAnnotateImage(display,&pixel,&annotate_info,image,exception); 9168534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy if (status == 0) 9169534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy { 9170534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ThrowXWindowException(ResourceLimitError,"MemoryAllocationFailed", 9171534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy image->filename); 9172534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 9173534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy } 9174534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickTrue); 9175534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy} 9176534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9177534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy/* 9178534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9179534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9180534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9181534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 91823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X R e t a i n W i n d o w C o l o r s % 91833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 91843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 91853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 91863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 91873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 91883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XRetainWindowColors() sets X11 color resources on a window. This preserves 91893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the colors associated with an image displayed on the window. 91903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 91913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XRetainWindowColors method is: 91923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 91933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XRetainWindowColors(Display *display,const Window window) 91943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 91953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 91963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 91973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 91983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 91993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 92013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 92033ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XRetainWindowColors(Display *display,const Window window) 92043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 92053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 92063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property; 92073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 92093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixmap; 92103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 92123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Put property on the window. 92133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 92143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 92153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 92163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 92173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property=XInternAtom(display,"_XSETROOT_ID",MagickFalse); 92183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (property == (Atom) NULL) 92193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9220c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToCreateProperty", 92213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "_XSETROOT_ID"); 92223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 92233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 92243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixmap=XCreatePixmap(display,window,1,1,1); 92253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixmap == (Pixmap) NULL) 92263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9227c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToCreateBitmap",""); 92283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 92293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 92303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XChangeProperty(display,window,property,XA_PIXMAP,32,PropModeReplace, 92313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned char *) &pixmap,1); 92323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetCloseDownMode(display,RetainPermanent); 92333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 92343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 92363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X S e l e c t W i n d o w % 92413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSelectWindow() allows a user to select a window using the mouse. If the 92473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% mouse moves, a cropping rectangle is drawn and the extents of the rectangle 92483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% is returned in the crop_info structure. 92493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XSelectWindow function is: 92513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% target_window=XSelectWindow(display,crop_info) 92533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 92553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: XSelectWindow returns the window id. 92573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 92593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 92603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o crop_info: Specifies a pointer to a RectangleInfo structure. It 92623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any cropping rectangle. 92633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 92653ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window XSelectWindow(Display *display,RectangleInfo *crop_info) 92663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 92673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define MinimumCropArea (unsigned int) 9 92683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cursor 92703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_cursor; 92713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 92733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_context; 92743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 92763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses, 92773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset, 92783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset; 92793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 92813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 92823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 92843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window, 92853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window; 92863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 92883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event; 92893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 92913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 92923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 92943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize graphic context. 92953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 92963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 92973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 92983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(crop_info != (RectangleInfo *) NULL); 92993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 93003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.background=XBlackPixel(display,XDefaultScreen(display)); 93013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.foreground=XWhitePixel(display,XDefaultScreen(display)); 93023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.function=GXinvert; 93033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.plane_mask= 93043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.background ^ context_values.foreground; 93053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.subwindow_mode=IncludeInferiors; 9306bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy annotate_context=XCreateGC(display,root_window,(size_t) (GCBackground | 93073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GCForeground | GCFunction | GCSubwindowMode),&context_values); 93083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_context == (GC) NULL) 93093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 93103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 93113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Grab the pointer using target cursor. 93123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 93133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_cursor=XMakeCursor(display,root_window,XDefaultColormap(display, 93143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultScreen(display)),(char * ) "white",(char * ) "black"); 93153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGrabPointer(display,root_window,MagickFalse,(unsigned int) 93163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask),GrabModeSync, 93173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GrabModeAsync,root_window,target_cursor,CurrentTime); 93183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != GrabSuccess) 93193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9320c38fbf5b3fd6e8baf7b455793bebb7220952d70dcristy ThrowXWindowException(XServerError,"UnableToGrabMouse",""); 93213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 93223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 93243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select a window. 93253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 93263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->width=0; 93273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->height=0; 93283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses=0; 93293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=(Window) NULL; 93303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset=0; 93313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset=0; 93323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy do 93333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 93343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width*crop_info->height) >= MinimumCropArea) 93353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,root_window,annotate_context, 93363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) crop_info->x,(int) crop_info->y,(unsigned int) crop_info->width-1, 93373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) crop_info->height-1); 93383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 93393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allow another event. 93403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 93413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllowEvents(display,SyncPointer,CurrentTime); 93423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWindowEvent(display,root_window,ButtonPressMask | 93433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ButtonReleaseMask | ButtonMotionMask,&event); 93443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width*crop_info->height) >= MinimumCropArea) 93453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,root_window,annotate_context, 93463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) crop_info->x,(int) crop_info->y,(unsigned int) crop_info->width-1, 93473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) crop_info->height-1); 93483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (event.type) 93493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 93503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case ButtonPress: 93513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 93523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=XGetSubwindow(display,event.xbutton.subwindow, 93533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event.xbutton.x,event.xbutton.y); 93543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 93553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=root_window; 93563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset=event.xbutton.x_root; 93573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset=event.xbutton.y_root; 9358ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->x=(ssize_t) x_offset; 9359ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->y=(ssize_t) y_offset; 93603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->width=0; 93613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->height=0; 93623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses++; 93633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 93643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case ButtonRelease: 93663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 93673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses--; 93683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 93693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case MotionNotify: 93713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 93723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 93733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Discard pending button motion events. 93743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 93753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ; 9376ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->x=(ssize_t) event.xmotion.x; 9377ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->y=(ssize_t) event.xmotion.y; 93783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 93793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Check boundary conditions. 93803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 93813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) crop_info->x < x_offset) 9382ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->width=(size_t) (x_offset-crop_info->x); 93833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 93843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9385ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->width=(size_t) (crop_info->x-x_offset); 9386ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->x=(ssize_t) x_offset; 93873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) crop_info->y < y_offset) 9389ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->height=(size_t) (y_offset-crop_info->y); 93903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 93913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9392ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->height=(size_t) (crop_info->y-y_offset); 9393ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->y=(ssize_t) y_offset; 93943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 93973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 93983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } while ((target_window == (Window) NULL) || (presses > 0)); 94003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XUngrabPointer(display,CurrentTime); 94013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,target_cursor); 94023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,annotate_context); 94033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width*crop_info->height) < MinimumCropArea) 94043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 94053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->width=0; 94063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->height=0; 94073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 94083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width != 0) && (crop_info->height != 0)) 94093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=root_window; 94103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 94113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 94123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 94133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 94143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X S e t C u r s o r S t a t e % 94193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSetCursorState() sets the cursor state to busy, otherwise the cursor are 94253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% reset to their default. 94263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XXSetCursorState method is: 94283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSetCursorState(display,windows,const MagickStatusType state) 94303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 94323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 94343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 94353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 94373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o state: An unsigned integer greater than 0 sets the cursor state 94393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% to busy, otherwise the cursor are reset to their default. 94403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9442bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XSetCursorState(Display *display,XWindows *windows, 94433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const MagickStatusType state) 94443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 94453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 94463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 94473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 94483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (state) 94493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 94503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->image.id, 94513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->image.busy_cursor); 94523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->pan.id, 94533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pan.busy_cursor); 94543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->magnify.id, 94553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.busy_cursor); 94563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->command.id, 94573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->command.busy_cursor); 94583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 94593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 94603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 94613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->image.id, 94623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->image.cursor); 94633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->pan.id,windows->pan.cursor); 94643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->magnify.id, 94653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.cursor); 94663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->command.id, 94673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->command.cursor); 94683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->command.id, 94693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->widget.cursor); 94703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); 94713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 94723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->info.mapped=MagickFalse; 94733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 94743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 94753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 94763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X S e t W i n d o w s % 94813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSetWindows() sets the X windows structure if the windows info is specified. 94873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Otherwise the current windows structure is returned. 94883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XSetWindows method is: 94903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindows *XSetWindows(XWindows *windows_info) 94923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 94943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows_info: Initialize the Windows structure with this information. 94963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9498bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XWindows *XSetWindows(XWindows *windows_info) 94993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 95003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XWindows 95013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows = (XWindows *) NULL; 95023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows_info != (XWindows *) ~0) 95043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 95053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=(XWindows *) RelinquishMagickMemory(windows); 95063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=windows_info; 95073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 95083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(windows); 95093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 95103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 95113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 95123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X U s e r P r e f e r e n c e s % 95163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 95203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XUserPreferences() saves the preferences in a configuration file in the 95223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% users' home directory. 95233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XUserPreferences method is: 95253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XUserPreferences(XResourceInfo *resource_info) 95273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 95293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 95313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9533bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XUserPreferences(XResourceInfo *resource_info) 95343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 95353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(X11_PREFERENCES_PATH) 95363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 95373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cache[MaxTextExtent], 95383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent], 95393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy specifier[MaxTextExtent]; 95403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char 9542104cea817534e8601291610f22e496c10f8f9ddbcristy *client_name, 95433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *value; 95443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmDatabase 95463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy preferences_database; 95473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 95493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Save user preferences to the client configuration file. 95503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 95513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 9552104cea817534e8601291610f22e496c10f8f9ddbcristy client_name=GetClientName(); 95533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy preferences_database=XrmGetStringDatabase(""); 9554b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.backdrop",client_name); 95553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->backdrop ? "True" : "False"; 95563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9557b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.colormap",client_name); 95583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->colormap == SharedColormap ? "Shared" : "Private"; 95593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9560b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.confirmExit", 9561104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 95623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->confirm_exit ? "True" : "False"; 95633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9564b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.confirmEdit", 9565104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 95663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->confirm_edit ? "True" : "False"; 95673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9568b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.displayWarnings", 9569104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 95703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->display_warnings ? "True" : "False"; 95713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9572b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.dither",client_name); 9573cbda611068350bf4459f2dda1951f8823702e129cristy value=resource_info->quantize_info->dither_method != NoDitherMethod ? 9574cbda611068350bf4459f2dda1951f8823702e129cristy "True" : "False"; 95753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9576b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.gammaCorrect", 9577104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 95783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->gamma_correct ? "True" : "False"; 95793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9580b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.undoCache",client_name); 9581b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(cache,MaxTextExtent,"%.20g",(double) 95823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->undo_cache); 95833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,cache); 9584b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.usePixmap",client_name); 95853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->use_pixmap ? "True" : "False"; 95863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9587b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(filename,MaxTextExtent,"%s%src", 9588104cea817534e8601291610f22e496c10f8f9ddbcristy X11_PREFERENCES_PATH,client_name); 95893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandFilename(filename); 95903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutFileDatabase(preferences_database,filename); 95913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 95923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 95933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 95953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 95963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X V i s u a l C l a s s N a m e % 96003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XVisualClassName() returns the visual class name as a character string. 96063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XVisualClassName method is: 96083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XVisualClassName(const int visual_class) 96103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 96123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_type: XVisualClassName returns the visual class as a character 96143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% string. 96153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o class: Specifies the visual class. 96173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 96193ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic const char *XVisualClassName(const int visual_class) 96203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 96213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (visual_class) 96223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 96233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticGray: return("StaticGray"); 96243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case GrayScale: return("GrayScale"); 96253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticColor: return("StaticColor"); 96263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PseudoColor: return("PseudoColor"); 96273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case TrueColor: return("TrueColor"); 96283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case DirectColor: return("DirectColor"); 96293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 96303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return("unknown visual class"); 96313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 96323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 96343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W a r n i n g % 96393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWarning() displays a warning reason in a Notice widget. 96453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWarning method is: 96473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XWarning(const unsigned int warning,const char *reason, 96493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *description) 96503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 96523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o warning: Specifies the numeric warning category. 96543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o reason: Specifies the reason to display before terminating the 96563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% program. 96573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o description: Specifies any description to the reason. 96593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9661bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XWarning(const ExceptionType magick_unused(warning), 96623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *reason,const char *description) 96633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 96643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 96653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy text[MaxTextExtent]; 96663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 96683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 96693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (reason == (char *) NULL) 96713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 96723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(text,reason,MaxTextExtent); 96733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(text,":",MaxTextExtent); 96743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=XSetWindows((XWindows *) ~0); 96753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XNoticeWidget(windows->display,windows,text,(char *) description); 96763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 96773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 96793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W i n d o w B y I D % 96843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowByID() locates a child window with a given ID. If not window with 96903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the given name is found, 0 is returned. Only the window specified and its 96913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% subwindows are searched. 96923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWindowByID function is: 96943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% child=XWindowByID(display,window,id) 96963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 96983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o child: XWindowByID returns the window with the specified 97003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% id. If no windows are found, XWindowByID returns 0. 97013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 97033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 97043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o id: Specifies the id of the window to locate. 97063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9708bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Window XWindowByID(Display *display,const Window root_window, 9709bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy const size_t id) 97103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 97113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 97123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rectangle_info; 97133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 97153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 97163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 97183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 97193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 97213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 97223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 97243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 97253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 97263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window; 97273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 97293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 97303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(root_window != (Window) NULL); 97313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (id == 0) 97323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(XSelectWindow(display,&rectangle_info)); 97333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (root_window == id) 9734dfe2b6658f367de8f84405263f62768fb853adafcristy return(root_window); 97353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,root_window,&child,&child,&children, 97363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_children); 97373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 97383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 97393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=(Window) NULL; 97403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_children; i++) 97413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 97423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 97433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search each child and their children. 97443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 97453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=XWindowByID(display,children[i],id); 97463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window != (Window) NULL) 97473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 97483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 97493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (children != (Window *) NULL) 97503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 97513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(window); 97523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 97533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 97553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W i n d o w B y N a m e % 97603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowByName() locates a window with a given name on a display. If no 97663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window with the given name is found, 0 is returned. If more than one window 97673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% has the given name, the first one is returned. Only root and its children 97683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% are searched. 97693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWindowByName function is: 97713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window=XWindowByName(display,root_window,name) 97733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 97753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: XWindowByName returns the window id. 97773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 97793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 97803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o root_window: Specifies the id of the root window. 97823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o name: Specifies the name of the window to locate. 97843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9786bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Window XWindowByName(Display *display,const Window root_window, 97873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *name) 97883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 97893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 97903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 97913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 97933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 97943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 97963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 97973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 97993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 98003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 98013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window; 98023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextProperty 98043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 98053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 98073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(root_window != (Window) NULL); 98083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(name != (char *) NULL); 98093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name); 98103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetWMName(display,root_window,&window_name) != 0) 98113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare((char *) window_name.value,name) == 0) 98123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(root_window); 98133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,root_window,&child,&child,&children, 98143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_children); 98153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 98163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 98173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=(Window) NULL; 98183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_children; i++) 98193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 98203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 98213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search each child and their children. 98223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 98233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=XWindowByName(display,children[i],name); 98243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window != (Window) NULL) 98253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 98263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 98273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (children != (Window *) NULL) 98283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 98293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(window); 98303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 98313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 98333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 98343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 98353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 98363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 98373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W i n d o w B y P r o p e r y % 98383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 98393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 98403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 98413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 98423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowByProperty() locates a child window with a given property. If not 98443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window with the given name is found, 0 is returned. If more than one window 98453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% has the given property, the first one is returned. Only the window 98463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified and its subwindows are searched. 98473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWindowByProperty function is: 98493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% child=XWindowByProperty(display,window,property) 98513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 98533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o child: XWindowByProperty returns the window id with the specified 98553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% property. If no windows are found, XWindowByProperty returns 0. 98563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 98583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 98593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o property: Specifies the property of the window to locate. 98613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9863bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Window XWindowByProperty(Display *display,const Window window, 98643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const Atom property) 98653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 98663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 98673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type; 98683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 98703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 98713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 98733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 98743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 98763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *data; 98773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 98793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 98803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 98813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9882f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 98833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy after, 98843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_items; 98853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 98873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 98883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 98893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy parent, 98903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root; 98913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 98923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 98933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 98943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 98953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(property != (Atom) NULL); 98963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,window,&root,&parent,&children,&number_children); 98973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 98983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 98993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type=(Atom) NULL; 99003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child=(Window) NULL; 99013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; (i < number_children) && (child == (Window) NULL); i++) 99023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 99033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowProperty(display,children[i],property,0L,0L,MagickFalse, 99043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (Atom) AnyPropertyType,&type,&format,&number_items,&after,&data); 99053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (data != NULL) 99063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) data); 99073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == Success) && (type != (Atom) NULL)) 99083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child=children[i]; 99093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 99103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; (i < number_children) && (child == (Window) NULL); i++) 99113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child=XWindowByProperty(display,children[i],property); 99123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (children != (Window *) NULL) 99133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 99143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(child); 99153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 99163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 99173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 99183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 99193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 99203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 99213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 99223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 99233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X I m p o r t I m a g e % 99243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 99253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 99263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 99273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 99283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 99293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XImportImage() reads an image from an X window. 99303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 99313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XImportImage method is: 99323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9933a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info, 9934a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% ExceptionInfo *exception) 99353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 99363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 99373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 99383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: the image info.. 99393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 99403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage_info: Specifies a pointer to an XImportInfo structure. 99413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9942a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% o exception: return any errors or warnings in this structure. 9943a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% 99443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 99454bc52025ac134838f6a62b8dc8ea6cfacab91796cristyMagickExport Image *XImportImage(const ImageInfo *image_info, 9946a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy XImportInfo *ximage_info,ExceptionInfo *exception) 99473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 99483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info != (const ImageInfo *) NULL); 99493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info->signature == MagickSignature); 99503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image_info->debug != MagickFalse) 99513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 99523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename); 99533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(ximage_info != (XImportInfo *) NULL); 9954a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy assert(exception != (ExceptionInfo *) NULL); 9955a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy assert(exception->signature == MagickSignature); 99563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 99573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 9958534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy 9959534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy/* 9960534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9961534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9962534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9963534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9964534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% X R e n d e r X 1 1 % 9965534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9966534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9967534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% % 9968534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9969534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9970534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% XRenderImage() renders text on the image with an X11 font. It also returns 9971534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% the bounding box of the text relative to the image. 9972534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9973534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% The format of the XRenderImage method is: 9974534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9975534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% MagickBooleanType XRenderImage(Image *image,DrawInfo *draw_info, 9976534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% const PointInfo *offset,TypeMetric *metrics,ExceptionInfo *exception) 9977534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9978534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% A description of each parameter follows: 9979534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9980534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o image: the image. 9981534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9982534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o draw_info: the draw info. 9983534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9984534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o offset: (x,y) location of text relative to image. 9985534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9986534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o metrics: bounding box of text. 9987534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9988534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% o exception: return any errors or warnings in this structure. 9989534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy% 9990534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy*/ 9991534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristyMagickPrivate MagickBooleanType XRenderImage(Image *image, 9992534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy const DrawInfo *draw_info,const PointInfo *offset,TypeMetric *metrics, 9993534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy ExceptionInfo *exception) 9994534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy{ 9995534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) draw_info; 9996534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) offset; 9997534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) metrics; 9998534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy (void) ThrowMagickException(exception,GetMagickModule(), 9999534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","'%s' (X11)", 10000534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy image->filename); 10001534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy return(MagickFalse); 10002534d0a353b31242ce2f7b26c4eb4fe53f914d0f5cristy} 100033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 100043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 100053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 100063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 100073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 100083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 100093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 10010576974eba31c1fac74b2492a74862b2fcd50f21ccristy+ X C o m p o n e n t G e n e s i s % 10011576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 10012576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 10013576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 10014576974eba31c1fac74b2492a74862b2fcd50f21ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10015576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 10016576974eba31c1fac74b2492a74862b2fcd50f21ccristy% XComponentGenesis() instantiates the X component. 10017576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 10018576974eba31c1fac74b2492a74862b2fcd50f21ccristy% The format of the XComponentGenesis method is: 10019576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 10020576974eba31c1fac74b2492a74862b2fcd50f21ccristy% MagickBooleanType XComponentGenesis(void) 10021576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 10022576974eba31c1fac74b2492a74862b2fcd50f21ccristy*/ 100235ff4eaf57b3cd47d0371f204f865cbba614674a0cristyMagickPrivate MagickBooleanType XComponentGenesis(void) 10024576974eba31c1fac74b2492a74862b2fcd50f21ccristy{ 10025576974eba31c1fac74b2492a74862b2fcd50f21ccristy return(MagickTrue); 10026576974eba31c1fac74b2492a74862b2fcd50f21ccristy} 10027576974eba31c1fac74b2492a74862b2fcd50f21ccristy 10028576974eba31c1fac74b2492a74862b2fcd50f21ccristy/* 10029576974eba31c1fac74b2492a74862b2fcd50f21ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10030576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 10031576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 10032576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 100333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t I m p o r t I n f o % 100343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 100353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 100363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 100373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 100383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 100393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetImportInfo() initializes the XImportInfo structure. 100403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 100413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetImportInfo method is: 100423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 100433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetImportInfo(XImportInfo *ximage_info) 100443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 100453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 100463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 100473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage_info: Specifies a pointer to an ImageInfo structure. 100483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 100493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 100503ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XGetImportInfo(XImportInfo *ximage_info) 100513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 100523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(ximage_info != (XImportInfo *) NULL); 100533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->frame=MagickFalse; 100543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->borders=MagickFalse; 100553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->screen=MagickFalse; 100563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->descend=MagickTrue; 100573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->silent=MagickFalse; 100583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 10059