xwindow.c revision 63a81879d3568083e4ee4f78ebcae2bc831cb764
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 % 163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% John Cristy % 173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% July 1992 % 183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 201454be7db7a897f42cd40e4165f945d77196a6f8cristy% Copyright 1999-2012 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 2093ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickRealType 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 4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte; 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) 5633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_image->matte=MagickTrue; 564c57f694b2d04975a0e501613e34368c464708c19cristy annotate_view=AcquireCacheView(annotate_image); 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 6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickRealType 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); 6983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte=image->matte; 6993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CompositeImage(image,annotate_image->matte != MagickFalse ? 700e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy OverCompositeOp : CopyCompositeOp,annotate_image,(ssize_t) x,(ssize_t) y, 701e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy exception); 7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->matte=matte; 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 { 7673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitError,"MemoryAllocationFailed", 7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font); 7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char **) NULL); 7703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=font; 7723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) fonts; i++) 7733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (q=p; *q != '\0'; q++) 7753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((*q == ':') || (*q == ';') || (*q == ',')) 7763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 7773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist[i]=(char *) AcquireQuantumMemory((size_t) (q-p)+1UL, 7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*fontlist[i])); 7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (fontlist[i] == (char *) NULL) 7803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitError,"MemoryAllocationFailed", 7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font); 7833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char **) NULL); 7843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(fontlist[i],p,(size_t) (q-p+1)); 7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=q+1; 7873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist[i]=(char *) NULL; 7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(fontlist); 7903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 7913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 792bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XFontStruct *XBestFont(Display *display, 7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,const MagickBooleanType text_font) 7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 7953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const char 7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *Fonts[]= 7973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-1", 7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-arial-medium-r-normal--12-*-*-*-*-*-iso8859-1", 8003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-15", 8013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-arial-medium-r-normal--12-*-*-*-*-*-iso8859-15", 8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-helvetica-medium-r-normal--12-*-*-*-*-*-*-*", 8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-arial-medium-r-normal--12-*-*-*-*-*-*-*", 8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "variable", 8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "fixed", 8063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL 8073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *TextFonts[]= 8093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-1", 8113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-courier-medium-r-normal-*-12-*-*-*-*-*-iso8859-15", 8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "-*-fixed-medium-r-normal-*-12-*-*-*-*-*-*-*", 8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "fixed", 8143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL 8153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 8163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *font_name; 8193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register const char 8213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **p; 8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XFontStruct 8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *font_info; 8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=(XFontStruct *) NULL; 8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_name=resource_info->font; 8283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (text_font != MagickFalse) 8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_name=resource_info->text_font; 8303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((font_name != (char *) NULL) && (*font_name != '\0')) 8313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 8333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **fontlist; 8343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 8363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Load preferred font specified in the X resource database. 8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist=FontToList(font_name); 8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (fontlist != (char **) NULL) 8433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; fontlist[i] != (char *) NULL; i++) 8453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info == (XFontStruct *) NULL) 8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=XLoadQueryFont(display,fontlist[i]); 8483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist[i]=DestroyString(fontlist[i]); 8493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy fontlist=(char **) RelinquishMagickMemory(fontlist); 8513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info == (XFontStruct *) NULL) 8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToLoadFont",font_name); 8543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 8563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Load fonts from list of fonts until one is found. 8573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=Fonts; 8593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (text_font != MagickFalse) 8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=TextFonts; 8613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XDisplayHeight(display,XDefaultScreen(display)) >= 748) 8623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 8633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (*p != (char *) NULL) 8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info != (XFontStruct *) NULL) 8663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 8673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy font_info=XLoadQueryFont(display,(char *) *p); 8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(font_info); 8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t I c o n S i z e % 8793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestIconSize() returns the "best" icon size. "Best" is defined as an icon 8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% size that maintains the aspect ratio of the image. If the window manager 8863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% has preferred icon sizes, one of the preferred sizes is used. 8873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestIconSize method is: 8893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XBestIconSize(Display *display,XWindowInfo *window,Image *image) 8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 8953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 8963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 8983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 900bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XBestIconSize(Display *display,XWindowInfo *window, 9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image *image) 9023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 9033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 9043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 9053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_sizes; 9063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickRealType 9083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scale_factor; 9093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 9113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 9123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_height, 9133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_width, 9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 9153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 9173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 9183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XIconSize 9203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *icon_size, 9213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *size_list; 9223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine if the window manager has specified preferred icon sizes. 9253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 9273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 9283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 9293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 9303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width=MaxIconSize; 9313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height=MaxIconSize; 9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size=(XIconSize *) NULL; 9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_sizes=0; 9343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,window->screen); 9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetIconSizes(display,root_window,&size_list,&number_sizes) != 0) 9363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_sizes > 0) && (size_list != (XIconSize *) NULL)) 9373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size=size_list; 9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_size == (XIconSize *) NULL) 9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window manager does not restrict icon size. 9423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size=XAllocIconSize(); 9443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_size == (XIconSize *) NULL) 9453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitError, 9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed",image->filename); 9483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 9493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->min_width=1; 9513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->max_width=MaxIconSize; 9523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->min_height=1; 9533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->max_height=MaxIconSize; 9543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->width_inc=1; 9553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_size->height_inc=1; 9563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine aspect ratio of image. 9593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) image->columns; 9613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) image->rows; 9623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 9633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->crop_geometry) 9643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(window->crop_geometry,&i,&i,&width,&height); 9653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 9663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Look for an icon size that maintains the aspect ratio of image. 9673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 9683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scale_factor=(MagickRealType) icon_size->max_width/width; 9693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (scale_factor > ((MagickRealType) icon_size->max_height/height)) 9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scale_factor=(MagickRealType) icon_size->max_height/height; 9713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_width=(unsigned int) icon_size->min_width; 9723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((int) icon_width < icon_size->max_width) 9733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_width >= (unsigned int) (scale_factor*width+0.5)) 9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_width+=icon_size->width_inc; 9773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_height=(unsigned int) icon_size->min_height; 9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((int) icon_height < icon_size->max_height) 9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_height >= (unsigned int) (scale_factor*height+0.5)) 9823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_height+=icon_size->height_inc; 9843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 9853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) icon_size); 9863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width=icon_width; 9873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height=icon_height; 9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 9893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 9913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t P i x e l % 9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestPixel() returns a pixel from an array of pixels that is closest to the 10023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% requested color. If the color array is NULL, the colors are obtained from 10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the X server. 10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestPixel method is: 10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XBestPixel(Display *display,const Colormap colormap,XColor *colors, 10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% unsigned int number_colors,XColor *color) 10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: XBestPixel returns the pixel value closest to the requested 10133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% color. 10143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 10163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 10173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colormap: Specifies the ID of the X server colormap. 10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colors: Specifies an array of XColor structures. 10213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o number_colors: Specifies the number of XColor structures in the 10233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% color definition array. 10243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o color: Specifies the desired RGB value to find in the colors array. 10263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 10273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1028bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XBestPixel(Display *display,const Colormap colormap, 10293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor *colors,unsigned int number_colors,XColor *color) 10303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 10313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 10323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy query_server; 10333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10344c08aed51c5899665ade97263692328eea4af106cristy PixelInfo 10353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 10363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickRealType 10383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy min_distance; 10393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register MagickRealType 10413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance; 10423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 10443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 10453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j; 10463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 10483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 10493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 10503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 10513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Find closest representation for the requested RGB color. 10523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 10533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 10543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 10553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(color != (XColor *) NULL); 10563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XAllocColor(display,colormap,color); 10573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 10583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 10593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy query_server=colors == (XColor *) NULL ? MagickTrue : MagickFalse; 10603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (query_server != MagickFalse) 10613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 10633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Read X server colormap. 10643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 10653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory(number_colors,sizeof(*colors)); 10663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 10673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitError, 10693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed","..."); 10703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 10713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 1073bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy colors[i].pixel=(size_t) i; 10743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_colors > 256) 10753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=256; 10763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display,colormap,colors,(int) number_colors); 10773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy min_distance=3.0*((MagickRealType) QuantumRange+1.0)*((MagickRealType) 10793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantumRange+1.0); 10803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=0; 10813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 10823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 10833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.red=colors[i].red-(MagickRealType) color->red; 10843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance=pixel.red*pixel.red; 10853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (distance > min_distance) 10863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 10873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.green=colors[i].green-(MagickRealType) color->green; 10883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance+=pixel.green*pixel.green; 10893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (distance > min_distance) 10903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 10913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel.blue=colors[i].blue-(MagickRealType) color->blue; 10923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy distance+=pixel.blue*pixel.blue; 10933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (distance > min_distance) 10943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 10953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy min_distance=distance; 10963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->pixel=colors[i].pixel; 10973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=i; 10983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 10993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&colors[j]); 11003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (query_server != MagickFalse) 11013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) RelinquishMagickMemory(colors); 11023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 11033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 11053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X B e s t V i s u a l I n f o % 11103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 11133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XBestVisualInfo() returns visual information for a visual that is the "best" 11163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the server supports. "Best" is defined as: 11173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1. Restrict the visual list to those supported by the default screen. 11193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2. If a visual type is specified, restrict the visual list to those of 11213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% that type. 11223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 3. If a map type is specified, choose the visual that matches the id 11243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified by the Standard Colormap. 11253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 4 From the list of visuals, choose one that can display the most 11273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% simultaneous colors. If more than one visual can display the same 11283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% number of simultaneous colors, one is chosen based on a rank. 11293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XBestVisualInfo method is: 11313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XVisualInfo *XBestVisualInfo(Display *display, 11333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info,XResourceInfo *resource_info) 11343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 11363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: XBestVisualInfo returns a pointer to a X11 XVisualInfo 11383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% structure. 11393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 11413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 11423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 11443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 11453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 11473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 11483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 11493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11503ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic inline int MagickMax(const int x,const int y) 11513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 11523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x > y) 11533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(x); 11543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(y); 11553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 11563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1157bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic inline size_t MagickMin(const unsigned int x, 11583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const unsigned int y) 11593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 11603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < y) 11613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(x); 11623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(y); 11633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 11643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1165bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XVisualInfo *XBestVisualInfo(Display *display, 11663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap *map_info,XResourceInfo *resource_info) 11673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 11683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define MaxStandardColormaps 7 11693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define XVisualColormapSize(visual_info) MagickMin((unsigned int) (\ 11703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass == TrueColor) || (visual_info->klass == DirectColor) ? \ 11713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->red_mask | visual_info->green_mask | visual_info->blue_mask : \ 11723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) visual_info->colormap_size),1U << visual_info->depth) 11733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 11753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_type, 11763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_type; 11773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1178c57f694b2d04975a0e501613e34368c464708c19cristy int 1179c57f694b2d04975a0e501613e34368c464708c19cristy visual_mask; 1180c57f694b2d04975a0e501613e34368c464708c19cristy 11813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 11823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 11833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11848891f9ce489d3e61399b60436ea6c62f5ed9b887cristy size_t 11858891f9ce489d3e61399b60436ea6c62f5ed9b887cristy one; 11868891f9ce489d3e61399b60436ea6c62f5ed9b887cristy 11873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static int 11883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_visuals; 11893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XVisualInfo 11913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template; 11923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualInfo 11943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_info, 11953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual_list; 11963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 11973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 11983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restrict visual search by screen number. 11993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 12013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 12023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 12033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 12043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_type=resource_info->map_type; 12053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_type=resource_info->visual_type; 12063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask=VisualScreenMask; 12073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.screen=XDefaultScreen(display); 12083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.depth=XDefaultDepth(display,XDefaultScreen(display)); 12098891f9ce489d3e61399b60436ea6c62f5ed9b887cristy one=1; 12103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((resource_info->immutable != MagickFalse) && (resource_info->colors != 0)) 12118891f9ce489d3e61399b60436ea6c62f5ed9b887cristy if (resource_info->colors <= (one << (size_t) visual_template.depth)) 12123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualDepthMask; 12133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_type != (char *) NULL) 12143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restrict visual search by class or visual id. 12173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("staticgray",visual_type) == 0) 12193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=StaticGray; 12223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("grayscale",visual_type) == 0) 12253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=GrayScale; 12283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("staticcolor",visual_type) == 0) 12313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=StaticColor; 12343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("pseudocolor",visual_type) == 0) 12373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=PseudoColor; 12403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("truecolor",visual_type) == 0) 12433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=TrueColor; 12463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("directcolor",visual_type) == 0) 12493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualClassMask; 12513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.klass=DirectColor; 12523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("default",visual_type) == 0) 12553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualIDMask; 12573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual( 12583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultVisual(display,XDefaultScreen(display))); 12593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (isdigit((int) ((unsigned char) *visual_type)) != 0) 12623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask|=VisualIDMask; 12643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid= 12653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol(visual_type,(char **) NULL,0); 12663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 12683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError, 12693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnrecognizedVisualSpecifier",visual_type); 12703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get all visuals that meet our criteria so far. 12733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_visuals=0; 12753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_list=XGetVisualInfo(display,visual_mask,&visual_template, 12763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_visuals); 12773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_mask=VisualScreenMask | VisualIDMask; 12783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_visuals == 0) || (visual_list == (XVisualInfo *) NULL)) 12793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 12813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Failed to get visual; try using the default visual. 12823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 12833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerWarning,"UnableToGetVisual", 12843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_type); 12853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual(XDefaultVisual(display, 12863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultScreen(display))); 12873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_list=XGetVisualInfo(display,visual_mask,&visual_template, 12883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_visuals); 12893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_visuals == 0) || (visual_list == (XVisualInfo *) NULL)) 12903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 12913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerWarning,"UsingDefaultVisual", 12923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualClassName(visual_list->klass)); 12933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 12943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->color_recovery=MagickFalse; 12953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((map_info != (XStandardColormap *) NULL) && (map_type != (char *) NULL)) 12963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 12973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 12983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property; 12993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 13013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_name[MaxTextExtent]; 13023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 13043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 13053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_maps; 13063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 13083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 13093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 13113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 13123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap 13143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_list; 13153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Choose a visual associated with a standard colormap. 13183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 13203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=False; 13213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(map_type,"list") != 0) 13223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy User specified Standard Colormap. 13253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 1326b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString((char *) map_name,MaxTextExtent, 13273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_%s_MAP",map_type); 13283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy LocaleUpper(map_name); 13293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property=XInternAtom(display,(char *) map_name,MagickTrue); 13303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_property != (Atom) NULL) 13313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetRGBColormaps(display,root_window,&map_list,&number_maps, 13323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property); 13333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 13353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const char 13373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colormap[MaxStandardColormaps]= 13383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "_HP_RGB_SMOOTH_MAP_LIST", 13403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_BEST_MAP", 13413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_DEFAULT_MAP", 13423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_GRAY_MAP", 13433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_RED_MAP", 13443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_GREEN_MAP", 13453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "RGB_BLUE_MAP", 13463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 13473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 13483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Choose a standard colormap from a list. 13503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxStandardColormaps; i++) 13523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property=XInternAtom(display,(char *) colormap[i],MagickTrue); 13543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_property == (Atom) NULL) 13553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 13563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetRGBColormaps(display,root_window,&map_list,&number_maps, 13573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_property); 13583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 13593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->color_recovery=i == 0 ? MagickTrue : MagickFalse; 13623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 13643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToGetStandardColormap", 13663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_type); 13673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 13683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 13703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search all Standard Colormaps and visuals for ids that match. 13713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 13723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info=map_list[0]; 13733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(PRE_R4_ICCCM) 13743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual(visual_list[0].visual); 13753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < number_maps; i++) 13763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < number_visuals; j++) 13773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_list[i].visualid == 13783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualIDFromVisual(visual_list[j].visual)) 13793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info=map_list[i]; 13813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual( 13823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_list[j].visual); 13833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 13843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->visualid != visual_template.visualid) 13863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError, 13883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToMatchVisualToStandardColormap",map_type); 13893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 13903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 13923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->colormap == (Colormap) NULL) 13933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 13943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError, 13953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "StandardColormapIsNotInitialized",map_type); 13963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 13973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 13983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) map_list); 13993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 14013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const unsigned int 14033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rank[]= 14043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StaticGray, 14063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GrayScale, 14073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy StaticColor, 14083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DirectColor, 14093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy TrueColor, 14103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PseudoColor 14113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 14123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualInfo 14143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 14153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 14173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pick one visual that displays the most simultaneous colors. 14183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=visual_list; 14203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=visual_list; 14213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=1; i < number_visuals; i++) 14223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 14233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 14243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XVisualColormapSize(p) > XVisualColormapSize(visual_info)) 14253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=p; 14263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 14273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XVisualColormapSize(p) == XVisualColormapSize(visual_info)) 14283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (rank[p->klass] > rank[visual_info->klass]) 14293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=p; 14303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_template.visualid=XVisualIDFromVisual(visual_info->visual); 14323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 14333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) visual_list); 14343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 14353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Retrieve only one visual by its screen & id number. 14363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 14373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info=XGetVisualInfo(display,visual_mask,&visual_template, 14383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_visuals); 14393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_visuals == 0) || (visual_info == (XVisualInfo *) NULL)) 14403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XVisualInfo *) NULL); 14413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(visual_info); 14423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C h e c k D e f i n e C u r s o r % 14503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCheckDefineCursor() prevents cursor changes on the root window. 14563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XXCheckDefineCursor method is: 14583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCheckDefineCursor(display,window,cursor) 14603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 14623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 14643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 14653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: the window. 14673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o cursor: the cursor. 14693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1471bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate int XCheckDefineCursor(Display *display,Window window, 14723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cursor cursor) 14733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 14743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 14753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 14763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window == XRootWindow(display,XDefaultScreen(display))) 14773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(0); 14783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(XDefineCursor(display,window,cursor)); 14793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 14803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 14813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 14823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C h e c k R e f r e s h W i n d o w s % 14873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 14903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCheckRefreshWindows() checks the X server for exposure events for a 14933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% particular window and updates the areassociated with the exposure event. 14943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XCheckRefreshWindows method is: 14963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XCheckRefreshWindows(Display *display,XWindows *windows) 14983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 14993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 15003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 15023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 15033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 15053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1507bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XCheckRefreshWindows(Display *display,XWindows *windows) 15083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 15093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 15103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id; 15113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 15133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event; 15143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 15163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 15173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 15183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDelay(display,SuspendTime); 15193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->command.id; 15203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCommandWidget(display,windows,(char const **) NULL,&event); 15223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->image.id; 15233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRefreshWindow(display,&windows->image,&event); 15253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDelay(display,SuspendTime << 1); 15263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->command.id; 15273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCommandWidget(display,windows,(char const **) NULL,&event); 15293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=windows->image.id; 15303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,id,Expose,&event) != MagickFalse) 15313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRefreshWindow(display,&windows->image,&event); 15323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 15353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C l i e n t M e s s a g e % 15403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClientMessage() sends a reason to a window with XSendEvent. The reason is 15463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% initialized with a particular protocol type and atom. 15473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XClientMessage function is: 15493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClientMessage(display,window,protocol,reason,timestamp) 15513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 15533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 15553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 15563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 15583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o protocol: Specifies an atom value. 15603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o reason: Specifies an atom value which is the reason to send. 15623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o timestamp: Specifies a value of type Time. 15643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1566bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XClientMessage(Display *display,const Window window, 15673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const Atom protocol,const Atom reason,const Time timestamp) 15683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 15693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XClientMessageEvent 15703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event; 15713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 15733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.type=ClientMessage; 15743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.window=window; 15753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.message_type=protocol; 15763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_event.format=32; 1577c57f694b2d04975a0e501613e34368c464708c19cristy client_event.data.l[0]=(long) reason; 1578c57f694b2d04975a0e501613e34368c464708c19cristy client_event.data.l[1]=(long) timestamp; 15793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSendEvent(display,window,MagickFalse,NoEventMask,(XEvent *) &client_event); 15803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 15813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 15823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 15833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X C l i e n t W i n d o w % 15883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 15913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClientWindow() finds a window, at or below the specified window, which has 15943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% a WM_STATE property. If such a window is found, it is returned, otherwise 15953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the argument window is returned. 15963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XClientWindow function is: 15983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 15993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% client_window=XClientWindow(display,target_window) 16003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 16023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_window: XClientWindow returns a window, at or below the specified 16043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window, which has a WM_STATE property otherwise the argument 16053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% target_window is returned. 16063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 16083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 16093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o target_window: Specifies the window to find a WM_STATE property. 16113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 16133ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window XClientWindow(Display *display,Window target_window) 16143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 16153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 16163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy state, 16173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type; 16183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 16203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 16213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 16233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 16243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 16263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *data; 16273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1628f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 16293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy after, 16303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_items; 16313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 16333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window; 16343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 16363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 16373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy state=XInternAtom(display,"WM_STATE",MagickTrue); 16383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (state == (Atom) NULL) 16393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 16403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type=(Atom) NULL; 16413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowProperty(display,target_window,state,0L,0L,MagickFalse, 16423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (Atom) AnyPropertyType,&type,&format,&number_items,&after,&data); 16433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == Success) && (type != (Atom) NULL)) 16443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 16453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window=XWindowByProperty(display,target_window,state); 16463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (client_window == (Window) NULL) 16473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 16483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(client_window); 16493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 16503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 16513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 16523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 1656f34a145c545cb86152ad42a787f6d5fffea6b77ccristy+ X C o m p o n e n t T e r m i n u s % 1657f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1658f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1659f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1660f34a145c545cb86152ad42a787f6d5fffea6b77ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1661f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1662f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% XComponentTerminus() destroys the module component. 1663f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1664f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% The format of the XComponentTerminus method is: 1665f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1666f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% XComponentTerminus(void) 1667f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% 1668f34a145c545cb86152ad42a787f6d5fffea6b77ccristy*/ 16695ff4eaf57b3cd47d0371f204f865cbba614674a0cristyMagickPrivate void XComponentTerminus(void) 1670f34a145c545cb86152ad42a787f6d5fffea6b77ccristy{ 1671f34a145c545cb86152ad42a787f6d5fffea6b77ccristy DestroyXResources(); 1672f34a145c545cb86152ad42a787f6d5fffea6b77ccristy} 1673f34a145c545cb86152ad42a787f6d5fffea6b77ccristy 1674f34a145c545cb86152ad42a787f6d5fffea6b77ccristy/* 1675f34a145c545cb86152ad42a787f6d5fffea6b77ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1676f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1677f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 1678f34a145c545cb86152ad42a787f6d5fffea6b77ccristy% % 16793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C o n f i g u r e I m a g e C o l o r m a p % 16803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 16833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XConfigureImageColormap() creates a new X colormap. 16863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XConfigureImageColormap method is: 16883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XConfigureImageColormap(Display *display, 16906710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XResourceInfo *resource_info,XWindows *windows,Image *image, 16916710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 16923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 16943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 16963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 16973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 16983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 16993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 17013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 17033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17046710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 17056710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 17063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1707bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XConfigureImageColormap(Display *display, 17086710d8414f0ed06e4eaf9346366be72e2b4719efcristy XResourceInfo *resource_info,XWindows *windows,Image *image, 17096710d8414f0ed06e4eaf9346366be72e2b4719efcristy ExceptionInfo *exception) 17103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 17113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 17123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 17133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 17153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Make standard colormap. 17163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 17173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetCursorState(display,windows,MagickTrue); 17183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XCheckRefreshWindows(display,windows); 17193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeStandardColormap(display,windows->visual_info,resource_info,image, 17206710d8414f0ed06e4eaf9346366be72e2b4719efcristy windows->map_info,windows->pixel_info,exception); 17213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=windows->map_info->colormap; 17223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->image.id,colormap); 17233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->command.id,colormap); 17243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->widget.id,colormap); 17253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->magnify.mapped != MagickFalse) 17263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->magnify.id,colormap); 17273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->pan.mapped != MagickFalse) 17283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWindowColormap(display,windows->pan.id,colormap); 17293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetCursorState(display,windows,MagickFalse); 17303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XClientMessage(display,windows->image.id,windows->im_protocols, 17313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_update_colormap,CurrentTime); 17323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 17333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 17353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X C o n s t r a i n W i n d o w P o s i t i o n % 17403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XConstrainWindowPosition() assures a window is positioned within the X 17463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% server boundaries. 17473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XConstrainWindowPosition method is: 17493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XConstrainWindowPosition(Display *display,XWindowInfo *window_info) 17513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 17533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 17553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 17563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window_info: Specifies a pointer to a XWindowInfo structure. 17583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1760bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XConstrainWindowPosition(Display *display, 17613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowInfo *window_info) 17623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 17633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 17643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy limit; 17653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 17673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 17683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window_info != (XWindowInfo *) NULL); 17693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy limit=XDisplayWidth(display,window_info->screen)-window_info->width; 17703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->x < 0) 17713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->x=0; 17723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 17733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->x > (int) limit) 17743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->x=(int) limit; 17753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy limit=XDisplayHeight(display,window_info->screen)-window_info->height; 17763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->y < 0) 17773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->y=0; 17783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 17793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->y > limit) 17803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->y=limit; 17813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 17823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 17833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 17843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D e l a y % 17893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 17923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDelay() suspends program execution for the number of milliseconds 17953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified. 17963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 17973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the Delay method is: 17983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 1799bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy% void XDelay(Display *display,const size_t milliseconds) 18003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 18043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 18053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o milliseconds: Specifies the number of milliseconds to delay before 18073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returning. 18083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1810bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XDelay(Display *display,const size_t milliseconds) 18113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 18133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 1814a21afdefe277667f7821fa90decc1f15a167eacfcristy MagickDelay(milliseconds); 18153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 18163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 18183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D e s t r o y R e s o u r c e I n f o % 18233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDestroyResourceInfo() frees memory associated with the XResourceInfo 18293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% structure. 18303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDestroyResourceInfo method is: 18323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XDestroyResourceInfo(XResourceInfo *resource_info) 18343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 18383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 18403ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XDestroyResourceInfo(XResourceInfo *resource_info) 18413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->image_geometry != (char *) NULL) 18433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_geometry=(char *) 18443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(resource_info->image_geometry); 18453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->quantize_info != (QuantizeInfo *) NULL) 18463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info=DestroyQuantizeInfo( 18473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info); 18483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->client_name != (char *) NULL) 18493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->client_name=(char *) 18503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RelinquishMagickMemory(resource_info->client_name); 18513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->name != (char *) NULL) 18523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->name=DestroyString(resource_info->name); 18533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(resource_info,0,sizeof(*resource_info)); 18543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 18553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 18573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D e s t r o y W i n d o w C o l o r s % 18623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 18653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDestroyWindowColors() frees X11 color resources previously saved on a 18683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window by XRetainWindowColors or programs like xsetroot. 18693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDestroyWindowColors method is: 18713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XDestroyWindowColors(Display *display,Window window) 18733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 18753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 18773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 18783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 18803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 18813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1882bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XDestroyWindowColors(Display *display,Window window) 18833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 18843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 18853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property, 18863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type; 18873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 18893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 18903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 18923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 18933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 18943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 18953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *data; 18963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1897f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 18983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy after, 18993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length; 19003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy If there are previous resources on the root window, destroy them. 19033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 19053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 19063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property=XInternAtom(display,"_XSETROOT_ID",MagickFalse); 19073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (property == (Atom) NULL) 19083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToCreateProperty", 19103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "_XSETROOT_ID"); 19113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 19123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowProperty(display,window,property,0L,1L,MagickTrue, 19143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (Atom) AnyPropertyType,&type,&format,&length,&after,&data); 19153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != Success) 19163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 19173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((type == XA_PIXMAP) && (format == 32) && (length == 1) && (after == 0)) 19183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 19193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XKillClient(display,(XID) (*((Pixmap *) data))); 19203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDeleteProperty(display,window,property); 19213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 19223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (type != None) 19233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) data); 19243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 19253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 19273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D i s p l a y I m a g e I n f o % 19323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 19353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDisplayImageInfo() displays information about an X image. 19383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDisplayImageInfo method is: 19403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XDisplayImageInfo(Display *display, 19423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XResourceInfo *resource_info,XWindows *windows,Image *undo_image, 19436710d8414f0ed06e4eaf9346366be72e2b4719efcristy% Image *image,ExceptionInfo *exception) 19443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 19463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 19483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 19493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 19513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 19533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o undo_image: the undo image. 19553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 19573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 19586710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 19596710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 19603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 1961bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XDisplayImageInfo(Display *display, 19623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,XWindows *windows,Image *undo_image, 19636710d8414f0ed06e4eaf9346366be72e2b4719efcristy Image *image,ExceptionInfo *exception) 19643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 19653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 19663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent], 19673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *text, 19683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy **textlist; 19693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy FILE 19713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *file; 19723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 19743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unique_file; 19753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1976bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 19773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 19783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1979bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 19803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_pixels; 19813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 19829d314ff2c17a77996c05413c2013880387e50f0ecristy ssize_t 19839d314ff2c17a77996c05413c2013880387e50f0ecristy bytes; 19849d314ff2c17a77996c05413c2013880387e50f0ecristy 19859d314ff2c17a77996c05413c2013880387e50f0ecristy unsigned int 19869d314ff2c17a77996c05413c2013880387e50f0ecristy levels; 19879d314ff2c17a77996c05413c2013880387e50f0ecristy 19883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 19893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the X server to a file. 19903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 19913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 19923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 19933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 19943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 19953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug) 19963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 19973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy file=(FILE *) NULL; 19983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unique_file=AcquireUniqueFileResource(filename); 19993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (unique_file != -1) 20003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy file=fdopen(unique_file,"w"); 20013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((unique_file == -1) || (file == (FILE *) NULL)) 20023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XNoticeWidget(display,windows,"Unable to display image info",filename); 20043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 20053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->gamma_correct != MagickFalse) 20073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->display_gamma != (char *) NULL) 2008b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Display\n gamma: %s\n\n", 20093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->display_gamma); 20103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the X image to a file. 20123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2013b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"X\n visual: %s\n", 20143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualClassName((int) windows->image.storage_class)); 2015b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," depth: %d\n",windows->image.ximage->depth); 20163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->visual_info->colormap_size != 0) 2017b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," colormap size: %d\n", 20183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->colormap_size); 20193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->colormap== SharedColormap) 2020b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," colormap type: Shared\n"); 20213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2022b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," colormap type: Private\n"); 20231e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file," geometry: %dx%d\n", 20241e604812fad85bb96f757a2393015ae3d061c39acristy windows->image.ximage->width,windows->image.ximage->height); 20253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.crop_geometry != (char *) NULL) 20261e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file," crop geometry: %s\n", 20271e604812fad85bb96f757a2393015ae3d061c39acristy windows->image.crop_geometry); 20283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.pixmap == (Pixmap) NULL) 2029b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," type: X Image\n"); 20303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2031b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," type: Pixmap\n"); 20323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.shape != MagickFalse) 2033b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," non-rectangular shape: True\n"); 20343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2035b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," non-rectangular shape: False\n"); 20363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->image.shared_memory != MagickFalse) 2037b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," shared memory: True\n"); 20383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 2039b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," shared memory: False\n"); 2040b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"\n"); 20413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->font != (char *) NULL) 2042b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Font: %s\n\n",resource_info->font); 20433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->text_font != (char *) NULL) 2044b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Text font: %s\n\n",resource_info->text_font); 20453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the undo cache to a file. 20473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes=0; 20493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (levels=0; undo_image != (Image *) NULL; levels++) 20503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_pixels=undo_image->list->columns*undo_image->list->rows; 2052101ab708b0574518ac5715da4d3915400e9df79acristy bytes+=number_pixels*sizeof(PixelInfo); 20533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy undo_image=GetPreviousImageInList(undo_image); 20543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2055b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file,"Undo Edit Cache\n levels: %u\n",levels); 20561e604812fad85bb96f757a2393015ae3d061c39acristy (void) FormatLocaleFile(file," bytes: %.20gmb\n",(double) 20571e604812fad85bb96f757a2393015ae3d061c39acristy ((bytes+(1 << 19)) >> 20)); 2058b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleFile(file," limit: %.20gmb\n\n",(double) 2059f2faecf9facdbbb14fcba373365f9f691a9658e0cristy resource_info->undo_cache); 20603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Write info about the image to a file. 20623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20636710d8414f0ed06e4eaf9346366be72e2b4719efcristy (void) IdentifyImage(image,file,MagickTrue,exception); 20643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) fclose(file); 20656710d8414f0ed06e4eaf9346366be72e2b4719efcristy text=FileToString(filename,~0,exception); 20663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RelinquishUniqueFileResource(filename); 20673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (text == (char *) NULL) 20683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XNoticeWidget(display,windows,"MemoryAllocationFailed", 20703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToDisplayImageInfo"); 20713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 20723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=StringToList(text); 20743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (textlist != (char **) NULL) 20753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 20763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 20773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy title[MaxTextExtent]; 20783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 20793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 20803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Display information about the image in the Text View widget. 20813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 20823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); 2083b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(title,MaxTextExtent,"Image Info: %s", 20843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 20853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextViewWidget(display,resource_info,windows,MagickTrue,title, 20863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char const **) textlist); 20873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; textlist[i] != (char *) NULL; i++) 20883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist[i]=DestroyString(textlist[i]); 20893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy textlist=(char **) RelinquishMagickMemory(textlist); 20903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 20913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy text=DestroyString(text); 20923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 20933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 20943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 20953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 20993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X D i t h e r I m a g e % 21003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 21013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 21023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 21033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDitherImage() dithers the reference image as required by the HP Color 21063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Recovery algorithm. The color values are quantized to 3 bits of red and 21073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% green, and 2 bits of blue (3/3/2) and can be used as indices into a 8-bit X 21083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% standard colormap. 21093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDitherImage method is: 21113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21126710d8414f0ed06e4eaf9346366be72e2b4719efcristy% void XDitherImage(Image *image,XImage *ximage,ExceptionInfo *exception) 21133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 21153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 21173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage: Specifies a pointer to a XImage structure; returned from 21193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 21203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 21216710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 21226710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 21233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 21246710d8414f0ed06e4eaf9346366be72e2b4719efcristystatic void XDitherImage(Image *image,XImage *ximage,ExceptionInfo *exception) 21253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 21263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const short int 21273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy dither_red[2][16]= 21283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {-16, 4, -1, 11,-14, 6, -3, 9,-15, 5, -2, 10,-13, 7, -4, 8}, 21303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 15, -5, 0,-12, 13, -7, 2,-10, 14, -6, 1,-11, 12, -8, 3, -9} 21313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 21323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy dither_green[2][16]= 21333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 11,-15, 7, -3, 8,-14, 4, -2, 10,-16, 6, -4, 9,-13, 5, -1}, 21353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy {-12, 14, -8, 2, -9, 13, -5, 1,-11, 15, -7, 3,-10, 12, -6, 0} 21363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 21373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy dither_blue[2][16]= 21383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { -3, 9,-13, 7, -1, 11,-15, 5, -4, 8,-14, 6, -2, 10,-16, 4}, 21403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2,-10, 12, -8, 0,-12, 14, -6, 3, -9, 13, -7, 1,-11, 15, -5} 21413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 21423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2143c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 2144c57f694b2d04975a0e501613e34368c464708c19cristy *image_view; 21453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 2147c57f694b2d04975a0e501613e34368c464708c19cristy value, 21483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 21493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2150101ab708b0574518ac5715da4d3915400e9df79acristy PixelInfo 2151c57f694b2d04975a0e501613e34368c464708c19cristy color; 21523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 21543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 21553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21564c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 21573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 21583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 21603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 21613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 21623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 21633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 21653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad; 21663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2167bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register size_t 21683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 21693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 21713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *blue_map[2][16], 21723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *green_map[2][16], 21733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *red_map[2][16]; 21743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 21753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 21763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate and initialize dither maps. 21773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 21783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < 2; i++) 21793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < 16; j++) 21803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_map[i][j]=(unsigned char *) AcquireQuantumMemory(256UL, 21823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*red_map)); 21833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_map[i][j]=(unsigned char *) AcquireQuantumMemory(256UL, 21843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*green_map)); 21853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_map[i][j]=(unsigned char *) AcquireQuantumMemory(256UL, 21863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*blue_map)); 21873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_map[i][j] == (unsigned char *) NULL) || 21883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (green_map[i][j] == (unsigned char *) NULL) || 21893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_map[i][j] == (unsigned char *) NULL)) 21903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 21913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitError, 21923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed",image->filename); 21933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 21943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 21953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 21963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 21973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize dither tables. 21983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 21993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < 2; i++) 22003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < 16; j++) 22013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < 256; x++) 22023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 22033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x-16; 22043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 48) 22053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x/2+8; 22063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value+=dither_red[i][j]; 22073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_map[i][j][x]=(unsigned char) 22083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((value < 0) ? 0 : (value > 255) ? 255 : value); 22093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x-16; 22103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 48) 22113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x/2+8; 22123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value+=dither_green[i][j]; 22133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_map[i][j][x]=(unsigned char) 22143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((value < 0) ? 0 : (value > 255) ? 255 : value); 22153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x-32; 22163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 112) 22173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=x/2+24; 2218bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy value+=((size_t) dither_blue[i][j] << 1); 22193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_map[i][j][x]=(unsigned char) 22203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((value < 0) ? 0 : (value > 255) ? 255 : value); 22213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 22223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 22233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Dither image. 22243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 22253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (ximage->bytes_per_line- 2226bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy ((size_t) (ximage->width*ximage->bits_per_pixel) >> 3)); 22273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 22283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=0; 22293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=ximage->data; 2230c57f694b2d04975a0e501613e34368c464708c19cristy image_view=AcquireCacheView(image); 22313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) image->rows; y++) 22323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2233c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) y,image->columns,1, 22346710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 22354c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 22363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 22373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) image->columns; x++) 22383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2239e42f658533644aecb733785ffd91b286d6778deacristy color.red=(double) ClampToQuantum((MagickRealType) (red_map[i][j][ 2240e42f658533644aecb733785ffd91b286d6778deacristy (int) ScaleQuantumToChar(GetPixelRed(image,p))] << 8)); 2241e42f658533644aecb733785ffd91b286d6778deacristy color.green=(double) ClampToQuantum((MagickRealType) (green_map[i][j][ 2242e42f658533644aecb733785ffd91b286d6778deacristy (int) ScaleQuantumToChar(GetPixelGreen(image,p))] << 8)); 2243e42f658533644aecb733785ffd91b286d6778deacristy color.blue=(double) ClampToQuantum((MagickRealType) (blue_map[i][j][ 2244e42f658533644aecb733785ffd91b286d6778deacristy (int) ScaleQuantumToChar(GetPixelBlue(image,p))] << 8)); 2245bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy pixel=(size_t) (((size_t) color.red & 0xe0) | 2246bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (((size_t) color.green & 0xe0) >> 3) | 2247bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (((size_t) color.blue & 0xc0) >> 6)); 22483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(char) pixel; 2249ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(image); 22503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j++; 22513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (j == 16) 22523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j=0; 22533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 22543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 22553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i++; 22563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (i == 2) 22573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 22583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2259c57f694b2d04975a0e501613e34368c464708c19cristy image_view=DestroyCacheView(image_view); 22603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 22613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free allocated memory. 22623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 22633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < 2; i++) 22643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < 16; j++) 22653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 22663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_map[i][j]=(unsigned char *) RelinquishMagickMemory(green_map[i][j]); 22673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_map[i][j]=(unsigned char *) RelinquishMagickMemory(blue_map[i][j]); 22683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_map[i][j]=(unsigned char *) RelinquishMagickMemory(red_map[i][j]); 22693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 22703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 22713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 22723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 22733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X D r a w I m a g e % 22783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 22813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XDrawImage() draws a line on the image. 22843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XDrawImage method is: 22863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22876710d8414f0ed06e4eaf9346366be72e2b4719efcristy% MagickBooleanType XDrawImage(Display *display,const XPixelInfo *pixel, 22886710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XDrawInfo *draw_info,Image *image,ExceptionInfo *exception) 22893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 22913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 22933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 22943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 22963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o draw_info: Specifies a pointer to a XDrawInfo structure. 22983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 22993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 23003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 23016710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 23026710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 23033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2304bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XDrawImage(Display *display, 23056710d8414f0ed06e4eaf9346366be72e2b4719efcristy const XPixelInfo *pixel,XDrawInfo *draw_info,Image *image, 23066710d8414f0ed06e4eaf9346366be72e2b4719efcristy ExceptionInfo *exception) 23073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 2308c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 2309c57f694b2d04975a0e501613e34368c464708c19cristy *draw_view; 2310c57f694b2d04975a0e501613e34368c464708c19cristy 23113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 23123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_context; 23133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 23153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *draw_image; 23163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 23183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 23193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 23203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 23223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte; 23233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 23253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_pixmap; 23263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 23283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth, 23293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 23303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 23313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 23333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 23343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 23363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 23373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 23393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *draw_ximage; 23403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 23413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize drawd image. 23433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 23453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 23463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(draw_info != (XDrawInfo *) NULL); 23473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 23483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 23493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 23503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize drawd pixmap. 23523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 23543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth=(unsigned int) XDefaultDepth(display,XDefaultScreen(display)); 23553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_pixmap=XCreatePixmap(display,root_window,draw_info->width, 23563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->height,depth); 23573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_pixmap == (Pixmap) NULL) 23583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 23593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize graphics info. 23613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2362bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy context_values.background=(size_t) (~0); 23633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.foreground=0; 23643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.line_width=(int) draw_info->line_width; 2365bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy draw_context=XCreateGC(display,root_window,(size_t) 23663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (GCBackground | GCForeground | GCLineWidth),&context_values); 23673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_context == (GC) NULL) 23683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 23693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Clear pixmap. 23713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillRectangle(display,draw_pixmap,draw_context,0,0,draw_info->width, 23733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->height); 23743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 23753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Draw line to pixmap. 23763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 23773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetBackground(display,draw_context,0); 2378bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (void) XSetForeground(display,draw_context,(size_t) (~0)); 2379dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy if (draw_info->stipple != (Pixmap) NULL) 2380dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy { 2381dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy (void) XSetFillStyle(display,draw_context,FillOpaqueStippled); 2382dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy (void) XSetStipple(display,draw_context,draw_info->stipple); 2383dd05bebf92311ac0db88ae24d6a6862a4729e8a5cristy } 23843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (draw_info->element) 23853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 23863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PointElement: 23873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 23883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 23893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLines(display,draw_pixmap,draw_context, 23903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->coordinate_info,(int) draw_info->number_coordinates, 23913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CoordModeOrigin); 23923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 23933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 23943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case LineElement: 23953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 23963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLine(display,draw_pixmap,draw_context,draw_info->line_info.x1, 23973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->line_info.y1,draw_info->line_info.x2, 23983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->line_info.y2); 23993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case RectangleElement: 24023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,draw_pixmap,draw_context, 24043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height); 24073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillRectangleElement: 24103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillRectangle(display,draw_pixmap,draw_context, 24123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height); 24153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case CircleElement: 24183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case EllipseElement: 24193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawArc(display,draw_pixmap,draw_context, 24213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height,0,360*64); 24243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillCircleElement: 24273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillEllipseElement: 24283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillArc(display,draw_pixmap,draw_context, 24303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->rectangle_info.x,(int) draw_info->rectangle_info.y, 24313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.width, 24323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) draw_info->rectangle_info.height,0,360*64); 24333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PolygonElement: 24363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPoint 24383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *coordinate_info; 24393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 24403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info=draw_info->coordinate_info; 24413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLines(display,draw_pixmap,draw_context,coordinate_info, 24423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) draw_info->number_coordinates,CoordModeOrigin); 24433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLine(display,draw_pixmap,draw_context, 24443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info[draw_info->number_coordinates-1].x, 24453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info[draw_info->number_coordinates-1].y, 24463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy coordinate_info[0].x,coordinate_info[0].y); 24473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case FillPolygonElement: 24503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 24513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillPolygon(display,draw_pixmap,draw_context, 24523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->coordinate_info,(int) draw_info->number_coordinates,Complex, 24533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CoordModeOrigin); 24543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 24553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 24573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,draw_context); 24583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 24593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize X image. 24603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 24613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_ximage=XGetImage(display,draw_pixmap,0,0,draw_info->width, 24623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_info->height,AllPlanes,ZPixmap); 24633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_ximage == (XImage *) NULL) 24643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 24653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,draw_pixmap); 24663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 24673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize draw image. 24683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 24696710d8414f0ed06e4eaf9346366be72e2b4719efcristy draw_image=AcquireImage((ImageInfo *) NULL,exception); 24703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_image == (Image *) NULL) 24713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 24723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image->columns=draw_info->width; 24733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image->rows=draw_info->height; 24743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 24753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Transfer drawn X image to image. 24763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 24773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) image->columns; 24783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) image->rows; 24793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 24803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 24813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height); 2482f05d4947caf1bc27fbec041eb37c474a80c83c0bcristy (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,(ssize_t) x, 2483f05d4947caf1bc27fbec041eb37c474a80c83c0bcristy (ssize_t) y,&draw_image->background_color,exception); 24846710d8414f0ed06e4eaf9346366be72e2b4719efcristy if (SetImageStorageClass(draw_image,DirectClass,exception) == MagickFalse) 24853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 24863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image->matte=MagickTrue; 2487c57f694b2d04975a0e501613e34368c464708c19cristy draw_view=AcquireCacheView(draw_image); 24883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) draw_image->rows; y++) 24893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2490c57f694b2d04975a0e501613e34368c464708c19cristy register int 24913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 24923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 24934c08aed51c5899665ade97263692328eea4af106cristy register Quantum 2494c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 24953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2496c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(draw_view,0,(ssize_t) y,draw_image->columns, 2497c57f694b2d04975a0e501613e34368c464708c19cristy 1,exception); 2498acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 24993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 2500c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) draw_image->columns; x++) 25013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetPixel(draw_ximage,x,y) == 0) 25033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set this pixel to the background color. 25063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2507803640d20a6a664315eddfff6f8531d0c5e0871dcristy SetPixelInfoPixel(draw_image,&draw_image->background_color,q); 25087676158e6c207e287beb252c9837d565863c3328cristy SetPixelAlpha(draw_image,(Quantum) (draw_info->stencil == 25094c08aed51c5899665ade97263692328eea4af106cristy OpaqueStencil ? TransparentAlpha : OpaqueAlpha),q); 25103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 25123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set this pixel to the pen color. 25153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25164c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(draw_image,ScaleShortToQuantum( 25174c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.red),q); 25184c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(draw_image,ScaleShortToQuantum( 25194c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.green),q); 25204c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(draw_image,ScaleShortToQuantum( 25214c08aed51c5899665ade97263692328eea4af106cristy pixel->pen_color.blue),q); 25224c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(draw_image,(Quantum) (draw_info->stencil == 25234c08aed51c5899665ade97263692328eea4af106cristy OpaqueStencil ? OpaqueAlpha : TransparentAlpha),q); 25243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2525ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(draw_image); 25263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2527c57f694b2d04975a0e501613e34368c464708c19cristy if (SyncCacheViewAuthenticPixels(draw_view,exception) == MagickFalse) 25283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2530c57f694b2d04975a0e501613e34368c464708c19cristy draw_view=DestroyCacheView(draw_view); 25313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(draw_ximage); 25323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine draw geometry. 25343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height); 25363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((width != (unsigned int) draw_image->columns) || 25373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (height != (unsigned int) draw_image->rows)) 25383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 25403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_geometry[MaxTextExtent]; 25413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Scale image. 25443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2545b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(image_geometry,MaxTextExtent,"%ux%u", 25463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width,height); 2547e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) TransformImage(&draw_image,(char *) NULL,image_geometry, 2548e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy exception); 25493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->degrees != 0.0) 25513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 25533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *rotate_image; 25543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 25563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rotations; 25573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickRealType 25593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees; 25603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 25613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate image. 25633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25646710d8414f0ed06e4eaf9346366be72e2b4719efcristy rotate_image=RotateImage(draw_image,draw_info->degrees,exception); 25653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (rotate_image == (Image *) NULL) 25663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 25673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image=DestroyImage(draw_image); 25683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image=rotate_image; 25693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Annotation is relative to the degree of rotation. 25713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees=draw_info->degrees; 25733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (normalized_degrees < -45.0) 25743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees+=360.0; 25753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (rotations=0; normalized_degrees > 45.0; rotations++) 25763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy normalized_degrees-=90.0; 25773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (rotations % 4) 25783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 25803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 25813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 25833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 90 degrees. 25863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) draw_image->columns/2; 25883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y+(int) draw_image->columns/2; 25893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 25923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 25933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 25943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 180 degrees. 25953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 25963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) draw_image->columns; 25973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 25983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 25993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 26003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 26023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Rotate 270 degrees. 26033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 26043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x-(int) draw_image->columns/2; 26053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y-(int) (draw_image->rows-(draw_image->columns/2)); 26063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 26073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 26113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Composite text onto the image. 26123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 2613c57f694b2d04975a0e501613e34368c464708c19cristy draw_view=AcquireCacheView(draw_image); 26143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) draw_image->rows; y++) 26153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2616c57f694b2d04975a0e501613e34368c464708c19cristy register int 26173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 26183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26194c08aed51c5899665ade97263692328eea4af106cristy register Quantum 2620c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 26213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 2622c57f694b2d04975a0e501613e34368c464708c19cristy q=GetCacheViewAuthenticPixels(draw_view,0,(ssize_t) y,draw_image->columns,1, 2623c57f694b2d04975a0e501613e34368c464708c19cristy exception); 2624acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 26253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 2626c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) draw_image->columns; x++) 26273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26284c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelAlpha(image,q) != TransparentAlpha) 26294c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(draw_image,OpaqueAlpha,q); 2630ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(draw_image); 26313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2632c57f694b2d04975a0e501613e34368c464708c19cristy if (SyncCacheViewAuthenticPixels(draw_view,exception) == MagickFalse) 26333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 26343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 2635c57f694b2d04975a0e501613e34368c464708c19cristy draw_view=DestroyCacheView(draw_view); 26363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseGeometry(draw_info->geometry,&x,&y,&width,&height); 26373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (draw_info->stencil == TransparentStencil) 2638e4a404711bf20d9062d11ab28bc12e5acd307f9ccristy (void) CompositeImage(image,CopyAlphaCompositeOp,draw_image,(ssize_t) x, 2639e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (ssize_t) y,exception); 26403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 26413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte=image->matte; 2643c57f694b2d04975a0e501613e34368c464708c19cristy (void) CompositeImage(image,OverCompositeOp,draw_image,(ssize_t) x, 2644e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (ssize_t) y,exception); 26453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->matte=matte; 26463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy draw_image=DestroyImage(draw_image); 26483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 26493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 26503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 26523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X E r r o r % 26573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 26603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XError() ignores BadWindow errors for XQueryTree and XGetWindowAttributes, 26633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% and ignores BadDrawable errors for XGetGeometry, and ignores BadValue errors 2664bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy% for XQueryColor. It returns MagickFalse in those cases. Otherwise it 2665bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy% returns True. 26663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XError function is: 26683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 2669bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristy% int XError(display,error) 26703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 26723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 26743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 26753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o error: Specifies the error event. 26773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 26783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 26793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 26813ed852eea50f9d4cd633efb8c2b054b8e33c253cristyextern "C" { 26823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 26833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 26843ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport int XError(Display *display,XErrorEvent *error) 26853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 26863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 26873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 26883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(error != (XErrorEvent *) NULL); 26893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xerror_alert=MagickTrue; 26903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (error->request_code) 26913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_GetGeometry: 26933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 26943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) error->error_code == BadDrawable) 26953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 26963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 26973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 26983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_GetWindowAttributes: 26993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_QueryTree: 27003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) error->error_code == BadWindow) 27023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 27033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 27043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case X_QueryColors: 27063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) error->error_code == BadValue) 27083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 27093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 27103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 27133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 27143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 27153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 27163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 27173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 27183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 27193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 27203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X F r e e R e s o u r c e s % 27253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 27283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XFreeResources() frees X11 resources. 27313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XFreeResources method is: 27333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XFreeResources(Display *display,XVisualInfo *visual_info, 27353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 27363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info,XWindowInfo *window_info) 27373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource_info,window_info) 27383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 27403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 27423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 27433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 27453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 27463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 27483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 27493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 27513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o font_info: Specifies a pointer to a XFontStruct structure. 27533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 27553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window_info: Specifies a pointer to a X11 XWindowInfo structure. 27573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 27583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2759bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XFreeResources(Display *display,XVisualInfo *visual_info, 27603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 27613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XResourceInfo *resource_info,XWindowInfo *window_info) 27623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 27633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 27643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 27653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 27663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info != (XWindowInfo *) NULL) 27673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 27693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free X image. 27703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 27713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->ximage != (XImage *) NULL) 27723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(window_info->ximage); 27733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id != (Window) NULL) 27743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 27753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 27763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free destroy window and free cursors. 27773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 27783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id != XRootWindow(display,visual_info->screen)) 27793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDestroyWindow(display,window_info->id); 27803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->annotate_context != (GC) NULL) 27813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,window_info->annotate_context); 27823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->highlight_context != (GC) NULL) 27833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,window_info->highlight_context); 27843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->widget_context != (GC) NULL) 27853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,window_info->widget_context); 27863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->cursor != (Cursor) NULL) 27873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window_info->cursor); 27883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->cursor=(Cursor) NULL; 27893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->busy_cursor != (Cursor) NULL) 27903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window_info->busy_cursor); 27913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->busy_cursor=(Cursor) NULL; 27923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 27943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 27953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free font. 27963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 27973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (font_info != (XFontStruct *) NULL) 2798aafc19213cef0b96cd237edb693a33fd1a2466eacristy { 2799aafc19213cef0b96cd237edb693a33fd1a2466eacristy (void) XFreeFont(display,font_info); 2800aafc19213cef0b96cd237edb693a33fd1a2466eacristy font_info=(XFontStruct *) NULL; 2801aafc19213cef0b96cd237edb693a33fd1a2466eacristy } 28023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info != (XStandardColormap *) NULL) 28033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 28043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 28053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free X Standard Colormap. 28063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 28073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->map_type == (char *) NULL) 28083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeStandardColormap(display,visual_info,map_info,pixel); 28093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) map_info); 28103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 28113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 28123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free X visual info. 28133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 28143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info != (XVisualInfo *) NULL) 28153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) visual_info); 28163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->close_server != MagickFalse) 28173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCloseDisplay(display); 28183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 28193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 28203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 28213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X F r e e S t a n d a r d C o l o r m a p % 28263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XFreeStandardColormap() frees an X11 colormap. 28323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XFreeStandardColormap method is: 28343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XFreeStandardColormap(Display *display, 28363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XVisualInfo *visual_info,XStandardColormap *map_info, 28373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XPixelInfo *pixel) 28383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 28403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 28423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 28433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 28453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 28463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 28483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 28493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 28513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2853bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XFreeStandardColormap(Display *display, 28543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XVisualInfo *visual_info,XStandardColormap *map_info,XPixelInfo *pixel) 28553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 28563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 28573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free colormap. 28583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 28593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 28603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 28613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 28623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 28633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 28643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->colormap != (Colormap) NULL) 28653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 28663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->colormap != XDefaultColormap(display,visual_info->screen)) 28673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeColormap(display,map_info->colormap); 28683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 28693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel != (XPixelInfo *) NULL) 28703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass != TrueColor) && 28713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass != DirectColor)) 28723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeColors(display,map_info->colormap,pixel->pixels, 28733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) pixel->colors,0); 28743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 28753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=(Colormap) NULL; 28763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel != (XPixelInfo *) NULL) 28773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 2878f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (pixel->pixels != (unsigned long *) NULL) 2879f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels); 2880f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) NULL; 28813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 28823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 28833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 28843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 28853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t A n n o t a t e I n f o % 28903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 28933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetAnnotateInfo() initializes the AnnotateInfo structure. 28963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetAnnotateInfo method is: 28983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 28993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetAnnotateInfo(XAnnotateInfo *annotate_info) 29003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 29023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_info: Specifies a pointer to a XAnnotateInfo structure. 29043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2906bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetAnnotateInfo(XAnnotateInfo *annotate_info) 29073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 29083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 29093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize annotate structure. 29103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 29113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 29123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_info != (XAnnotateInfo *) NULL); 29133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->x=0; 29143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->y=0; 29153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->width=0; 29163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->height=0; 29173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->stencil=ForegroundStencil; 29183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->degrees=0.0; 29193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->font_info=(XFontStruct *) NULL; 29203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->text=(char *) NULL; 29213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *annotate_info->geometry='\0'; 29223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->previous=(XAnnotateInfo *) NULL; 29233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_info->next=(XAnnotateInfo *) NULL; 29243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSupportsLocale(); 29253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetLocaleModifiers(""); 29263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 29273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 29283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 29293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t M a p I n f o % 29343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetMapInfo() initializes the XStandardColormap structure. 29403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XStandardColormap method is: 29423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetMapInfo(const XVisualInfo *visual_info,const Colormap colormap, 29443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info) 29453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 29473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colormap: Specifies the ID of the X server colormap. 29493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 29513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 29523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: Specifies a pointer to a X11 XStandardColormap structure. 29543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 29553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 2956bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetMapInfo(const XVisualInfo *visual_info, 29573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const Colormap colormap,XStandardColormap *map_info) 29583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 29593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 29603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize map info. 29613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 29623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 29633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 29643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 29653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=colormap; 29663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->red_max=visual_info->red_mask; 2967bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy map_info->red_mult=(size_t) (map_info->red_max != 0 ? 1 : 0); 29683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->red_max != 0) 29693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((map_info->red_max & 0x01) == 0) 29703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 29713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->red_max>>=1; 29723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->red_mult<<=1; 29733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 29743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max=visual_info->green_mask; 2975bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy map_info->green_mult=(size_t) (map_info->green_max != 0 ? 1 : 0); 29763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->green_max != 0) 29773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((map_info->green_max & 0x01) == 0) 29783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 29793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max>>=1; 29803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_mult<<=1; 29813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 29823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->blue_max=visual_info->blue_mask; 2983bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy map_info->blue_mult=(size_t) (map_info->blue_max != 0 ? 1 : 0); 29843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 29853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((map_info->blue_max & 0x01) == 0) 29863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 29873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->blue_max>>=1; 29883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->blue_mult<<=1; 29893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 29903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->base_pixel=0; 29913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 29923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 29933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 29943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 29953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 29983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t P i x e l I n f o % 29993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 30003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 30013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 30023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 3004101ab708b0574518ac5715da4d3915400e9df79acristy% XGetPixelInfo() initializes the PixelInfo structure. 30053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30064c08aed51c5899665ade97263692328eea4af106cristy% The format of the XGetPixelInfo method is: 30073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30084c08aed51c5899665ade97263692328eea4af106cristy% void XGetPixelInfo(Display *display,const XVisualInfo *visual_info, 30093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XStandardColormap *map_info,const XResourceInfo *resource_info, 30103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Image *image,XPixelInfo *pixel) 30113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pixel) 30123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 30143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 30163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 30173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 30193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 30203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 30223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 30233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 30253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 30273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 30293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 30303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 3031bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetPixelInfo(Display *display, 30323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XVisualInfo *visual_info,const XStandardColormap *map_info, 30333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,Image *image,XPixelInfo *pixel) 30343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 30353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const char 30363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *PenColors[MaxNumberPens]= 30373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 30383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#000000000000", /* black */ 30393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#00000000ffff", /* blue */ 30403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#0000ffffffff", /* cyan */ 30413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#0000ffff0000", /* green */ 30423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#bdbdbdbdbdbd", /* gray */ 30433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffff00000000", /* red */ 30443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffff0000ffff", /* magenta */ 30453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffffffff0000", /* yellow */ 30463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#ffffffffffff", /* white */ 30473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#bdbdbdbdbdbd", /* gray */ 30483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "#bdbdbdbdbdbd" /* gray */ 30493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 30503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 30523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 30533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3054bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 30553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 30563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 30583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 30593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 30613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy packets; 30623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 30633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 30643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize pixel info. 30653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 30663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 30673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 30683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 30693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 30703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 30713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 30723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->colors=0; 30733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image != (Image *) NULL) 30743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->storage_class == PseudoClass) 3075c57f694b2d04975a0e501613e34368c464708c19cristy pixel->colors=(ssize_t) image->colors; 30763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy packets=(unsigned int) 30773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickMax((int) pixel->colors,visual_info->colormap_size)+MaxNumberPens; 3078f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (pixel->pixels != (unsigned long *) NULL) 3079f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) RelinquishMagickMemory(pixel->pixels); 3080f2faecf9facdbbb14fcba373365f9f691a9658e0cristy pixel->pixels=(unsigned long *) AcquireQuantumMemory(packets, 30813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(pixel->pixels)); 3082f2faecf9facdbbb14fcba373365f9f691a9658e0cristy if (pixel->pixels == (unsigned long *) NULL) 30833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError,"UnableToGetPixelInfo", 30843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 30853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 30863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set foreground color. 30873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 30883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=map_info->colormap; 30893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,(char *) ForegroundColor, 30903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->foreground_color); 30913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->foreground_color, 30923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->foreground_color); 30933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 30943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer", 30953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->foreground_color); 30963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->foreground_color.pixel= 30973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardPixel(map_info,&pixel->foreground_color); 30983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->foreground_color.flags=(char) (DoRed | DoGreen | DoBlue); 30993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set background color. 31013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,"#d6d6d6d6d6d6",&pixel->background_color); 31033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->background_color, 31043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->background_color); 31053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 31063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer", 31073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->background_color); 31083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.pixel= 31093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardPixel(map_info,&pixel->background_color); 31103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.flags=(char) (DoRed | DoGreen | DoBlue); 31113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set border color. 31133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,(char *) BorderColor, 31153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->border_color); 31163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->border_color, 31173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->border_color); 31183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 31193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer", 31203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->border_color); 31213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->border_color.pixel=XStandardPixel(map_info,&pixel->border_color); 31223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->border_color.flags=(char) (DoRed | DoGreen | DoBlue); 31233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set matte color. 31253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color=pixel->background_color; 31273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->matte_color != (char *) NULL) 31283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 31293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Matte color is specified as a X resource or command line argument. 31313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->matte_color, 31333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->matte_color); 31343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 31353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer", 31363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->matte_color); 31373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.pixel=XStandardPixel(map_info,&pixel->matte_color); 31383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.flags=(char) (DoRed | DoGreen | DoBlue); 31393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 31403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set highlight color. 31423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->highlight_color.red=(unsigned short) (( 31443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(HighlightModulate))/65535L+ 31453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ScaleQuantumToShort((Quantum) (QuantumRange-HighlightModulate)))); 31463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->highlight_color.green=(unsigned short) (( 31473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(HighlightModulate))/65535L+ 31483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ScaleQuantumToShort((Quantum) (QuantumRange-HighlightModulate)))); 31493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->highlight_color.blue=(unsigned short) (( 31503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(HighlightModulate))/65535L+ 31513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ScaleQuantumToShort((Quantum) (QuantumRange-HighlightModulate)))); 31523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->highlight_color.pixel= 31533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardPixel(map_info,&pixel->highlight_color); 31543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->highlight_color.flags=(char) (DoRed | DoGreen | DoBlue); 31553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set shadow color. 31573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.red=(unsigned short) (((MagickRealType) 31593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(ShadowModulate))/65535L); 31603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.green=(unsigned short) (((MagickRealType) 31613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(ShadowModulate))/65535L); 31623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.blue=(unsigned short) (((MagickRealType) 31633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(ShadowModulate))/65535L); 31643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.pixel=XStandardPixel(map_info,&pixel->shadow_color); 31653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->shadow_color.flags=(char) (DoRed | DoGreen | DoBlue); 31663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set depth color. 31683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.red=(unsigned short) (((MagickRealType) 31703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(DepthModulate))/65535L); 31713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.green=(unsigned short) (((MagickRealType) 31723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(DepthModulate))/65535L); 31733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.blue=(unsigned short) (((MagickRealType) 31743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(DepthModulate))/65535L); 31753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.pixel=XStandardPixel(map_info,&pixel->depth_color); 31763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->depth_color.flags=(char) (DoRed | DoGreen | DoBlue); 31773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set trough color. 31793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.red=(unsigned short) (((MagickRealType) 31813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.red*ScaleQuantumToShort(TroughModulate))/65535L); 31823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.green=(unsigned short) (((MagickRealType) 31833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.green*ScaleQuantumToShort(TroughModulate))/65535L); 31843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.blue=(unsigned short) (((MagickRealType) 31853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->matte_color.blue*ScaleQuantumToShort(TroughModulate))/65535L); 31863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.pixel=XStandardPixel(map_info,&pixel->trough_color); 31873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->trough_color.flags=(char) (DoRed | DoGreen | DoBlue); 31883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 31893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set pen color. 31903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 31913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 31923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 31933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,(char *) PenColors[i], 31943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->pen_colors[i]); 31953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,resource_info->pen_colors[i], 31963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->pen_colors[i]); 31973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 31983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer", 31993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[i]); 32003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_colors[i].pixel=XStandardPixel(map_info,&pixel->pen_colors[i]); 32013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_colors[i].flags=(char) (DoRed | DoGreen | DoBlue); 32023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->box_color=pixel->background_color; 32043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_color=pixel->foreground_color; 32053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->box_index=0; 32063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pen_index=1; 32073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image != (Image *) NULL) 32083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 32093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((resource_info->gamma_correct != MagickFalse) && 32103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (image->gamma != 0.0)) 32113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 32123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GeometryInfo 32133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry_info; 32143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickStatusType 32163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 32173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 32193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize map relative to display and image gamma. 32203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 32213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=ParseGeometry(resource_info->display_gamma,&geometry_info); 32223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_gamma=geometry_info.rho; 32233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma=geometry_info.sigma; 32243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & SigmaValue) == 0) 32253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma=red_gamma; 32263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma=geometry_info.xi; 32273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & XiValue) == 0) 32283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma=red_gamma; 32293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_gamma*=image->gamma; 32303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_gamma*=image->gamma; 32313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_gamma*=image->gamma; 32323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->storage_class == PseudoClass) 32343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 32353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 32363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize pixel array for images of type PseudoClass. 32373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3238bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 32394c08aed51c5899665ade97263692328eea4af106cristy pixel->pixels[i]=XGammaPacket(map_info,image->colormap+i); 32403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 32413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[image->colors+i]=pixel->pen_colors[i].pixel; 32423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->colors+=MaxNumberPens; 32433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 32453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 32463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 32483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e C l a s s % 32533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 32563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceClass() queries the X server for the specified resource name or 32593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% class. If the resource name or class is not defined in the database, the 32603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% supplied default value is returned. 32613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceClass method is: 32633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XGetResourceClass(XrmDatabase database,const char *client_name, 32653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *keyword,char *resource_default) 32663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 32683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: Specifies a resource database; returned from 32703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmGetStringDatabase. 32713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve resource 32733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% info from the X server database. 32743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o keyword: Specifies the keyword of the value being retrieved. 32763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_default: Specifies the default value to return if the query 32783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% fails to find the specified keyword/class. 32793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 32803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 32813ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *XGetResourceClass(XrmDatabase database, 32823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *client_name,const char *keyword,char *resource_default) 32833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 32843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 32853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_class[MaxTextExtent], 32863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_name[MaxTextExtent]; 32873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static char 32893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_type; 32903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 32923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 32933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmValue 32953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value; 32963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 32973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (database == (XrmDatabase) NULL) 32983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_default); 32993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_name='\0'; 33003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_class='\0'; 33013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (keyword != (char *) NULL) 33023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 33033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 33043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c, 33053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 33063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 33083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize resource keyword and class. 33093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 3310b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(resource_name,MaxTextExtent,"%s.%s", 33113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name,keyword); 33123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=(int) (*client_name); 33133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_a) && (c <= XK_z)) 33143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_a-XK_A); 33153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_agrave) && (c <= XK_odiaeresis)) 33173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_agrave-XK_Agrave); 33183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_oslash) && (c <= XK_thorn)) 33203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_oslash-XK_Ooblique); 33213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k=(int) (*keyword); 33223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((k >= XK_a) && (k <= XK_z)) 33233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k-=(XK_a-XK_A); 33243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((k >= XK_agrave) && (k <= XK_odiaeresis)) 33263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k-=(XK_agrave-XK_Agrave); 33273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 33283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((k >= XK_oslash) && (k <= XK_thorn)) 33293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k-=(XK_oslash-XK_Ooblique); 3330b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(resource_class,MaxTextExtent,"%c%s.%c%s",c, 33313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name+1,k,keyword+1); 33323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 33333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XrmGetResource(database,resource_name,resource_class,&resource_type, 33343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &resource_value); 33353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 33363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_default); 33373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_value.addr); 33383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 33393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 33413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e D a t a b a s e % 33463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 33493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceDatabase() creates a new resource database and initializes it. 33523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceDatabase method is: 33543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmDatabase XGetResourceDatabase(Display *display, 33563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *client_name) 33573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 33593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: XGetResourceDatabase() returns the database after it is 33613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% initialized. 33623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 33643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 33653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve resource 33673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% info from the X server database. 33683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 33693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 33703ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport XrmDatabase XGetResourceDatabase(Display *display, 33713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *client_name) 33723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 33733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 33743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent]; 33753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 33773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c; 33783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register const char 33803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 33813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmDatabase 33833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_database, 33843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_database; 33853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 33863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 33873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XrmDatabase) NULL); 33883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(client_name != (char *) NULL); 33893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 33903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize resource database. 33913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 33923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmInitialize(); 33933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XGetDefault(display,(char *) client_name,"dummy"); 33943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_database=XrmGetDatabase(display); 33953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 33963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Combine application database. 33973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 33983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (client_name != (char *) NULL) 33993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 34003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get basename of client. 34023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=client_name+(strlen(client_name)-1); 34043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((p > client_name) && (*p != '/')) 34053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p--; 34063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*p == '/') 34073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name=p+1; 34083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 34093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c=(int) (*client_name); 34103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_a) && (c <= XK_z)) 34113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_a-XK_A); 34123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 34133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_agrave) && (c <= XK_odiaeresis)) 34143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_agrave-XK_Agrave); 34153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 34163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((c >= XK_oslash) && (c <= XK_thorn)) 34173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy c-=(XK_oslash-XK_Ooblique); 34183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(X11_APPLICATION_PATH) 3419b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(filename,MaxTextExtent,"%s%c%s", 34203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy X11_APPLICATION_PATH,c,client_name+1); 34213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XrmCombineFileDatabase(filename,&resource_database,MagickFalse); 34223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 34233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XResourceManagerString(display) != (char *) NULL) 34243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 34253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Combine server database. 34273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_database=XrmGetStringDatabase(XResourceManagerString(display)); 34293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmCombineDatabase(server_database,&resource_database,MagickFalse); 34303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 34313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Merge user preferences database. 34333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(X11_PREFERENCES_PATH) 3435b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(filename,MaxTextExtent,"%s%src", 34363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy X11_PREFERENCES_PATH,client_name); 34373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandFilename(filename); 34383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XrmCombineFileDatabase(filename,&resource_database,MagickFalse); 34393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 34403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_database); 34413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 34423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 34433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 34443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e I n f o % 34493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 34523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceInfo(image_info,) initializes the ResourceInfo structure. 34553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceInfo method is: 34573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetResourceInfo(const ImageInfo *image_info,XrmDatabase database, 34593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *client_name,XResourceInfo *resource_info) 34603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 34623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: the image info. 34643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: Specifies a resource database; returned from 34663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmGetStringDatabase. 34673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve 34693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource info from the X server database. 34703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 34723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 34733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 34743ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XGetResourceInfo(const ImageInfo *image_info, 34753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmDatabase database,const char *client_name,XResourceInfo *resource_info) 34763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 34773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 347800976d8abcff7a3bc7b986b8105dde8d091dee61cristy *directory, 34793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_value; 34803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 34813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 34823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize resource info fields. 34833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 34843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 34853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 34863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(resource_info,0,sizeof(*resource_info)); 34873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->resource_database=database; 34883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info=(ImageInfo *) image_info; 34893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SetImageInfoProgressMonitor(resource_info->image_info, 34903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMagickProgressMonitor,(void *) NULL); 34913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL); 34923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->close_server=MagickTrue; 34933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->client_name=AcquireString(client_name); 34943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"backdrop", 34953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 34963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->backdrop=IsMagickTrue(resource_value); 34973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->background_color=XGetResourceInstance(database,client_name, 34983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "background",(char *) "#d6d6d6d6d6d6"); 34993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->border_color=XGetResourceInstance(database,client_name, 35003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "borderColor",BorderColor); 35013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"borderWidth", 35023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "2"); 350300976d8abcff7a3bc7b986b8105dde8d091dee61cristy resource_info->border_width=(unsigned int) StringToUnsignedLong( 350400976d8abcff7a3bc7b986b8105dde8d091dee61cristy resource_value); 35053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"colormap", 35063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "shared"); 35073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->colormap=UndefinedColormap; 35083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("private",resource_value) == 0) 35093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->colormap=PrivateColormap; 35103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare("shared",resource_value) == 0) 35113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->colormap=SharedColormap; 35123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->colormap == UndefinedColormap) 35133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(OptionError,"UnrecognizedColormapType", 35143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value); 35153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name, 35163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "colorRecovery",(char *) "False"); 35173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->color_recovery=IsMagickTrue(resource_value); 35183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"confirmExit", 35193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->confirm_exit=IsMagickTrue(resource_value); 35213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"confirmEdit", 35223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->confirm_edit=IsMagickTrue(resource_value); 3524ba0c32599a8e592fffab86dd9b8ee367ca573c22cristy resource_value=XGetResourceClass(database,client_name,"delay",(char *) "1"); 3525e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->delay=(unsigned int) StringToUnsignedLong(resource_value); 35263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->display_gamma=XGetResourceClass(database,client_name, 35273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "displayGamma",(char *) "2.2"); 35283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"displayWarnings", 35293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 35303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->display_warnings=IsMagickTrue(resource_value); 35313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font=XGetResourceClass(database,client_name,"font", 35323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 35333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font=XGetResourceClass(database,client_name,"fontList", 35343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font); 35353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[0]=XGetResourceClass(database,client_name,"font1", 35363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "fixed"); 35373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[1]=XGetResourceClass(database,client_name,"font2", 35383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "variable"); 35393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[2]=XGetResourceClass(database,client_name,"font3", 35403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "5x8"); 35413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[3]=XGetResourceClass(database,client_name,"font4", 35423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "6x10"); 35433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[4]=XGetResourceClass(database,client_name,"font5", 35443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "7x13bold"); 35453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[5]=XGetResourceClass(database,client_name,"font6", 35463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "8x13bold"); 35473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[6]=XGetResourceClass(database,client_name,"font7", 35483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "9x15bold"); 35493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[7]=XGetResourceClass(database,client_name,"font8", 35503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "10x20"); 35513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[8]=XGetResourceClass(database,client_name,"font9", 35523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "12x24"); 35533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[9]=XGetResourceClass(database,client_name,"font0", 35543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "fixed"); 35553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->font_name[10]=XGetResourceClass(database,client_name,"font0", 35563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "fixed"); 35573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->foreground_color=XGetResourceInstance(database,client_name, 35583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "foreground",ForegroundColor); 35593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"gammaCorrect", 35603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 35613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->gamma_correct=IsMagickTrue(resource_value); 35623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_geometry=ConstantString(XGetResourceClass(database, 35633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_name,"geometry",(char *) NULL)); 35643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"gravity", 35653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "Center"); 3566042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy resource_info->gravity=(GravityType) ParseCommandOption(MagickGravityOptions, 35673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickFalse,resource_value); 356800976d8abcff7a3bc7b986b8105dde8d091dee61cristy directory=getcwd(resource_info->home_directory,MaxTextExtent); 356900976d8abcff7a3bc7b986b8105dde8d091dee61cristy (void) directory; 35703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->icon_geometry=XGetResourceClass(database,client_name, 35713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "iconGeometry",(char *) NULL); 35723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"iconic", 35733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->iconic=IsMagickTrue(resource_value); 35753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"immutable", 35763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy LocaleCompare(client_name,"PerlMagick") == 0 ? (char *) "True" : 35773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 35783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->immutable=IsMagickTrue(resource_value); 35793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"magnify", 35803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "3"); 3581e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->magnify=(unsigned int) StringToUnsignedLong(resource_value); 35823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->map_type=XGetResourceClass(database,client_name,"map", 35833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 35843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->matte_color=XGetResourceInstance(database,client_name, 35853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "mattecolor",(char *) NULL); 35863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->name=ConstantString(XGetResourceClass(database,client_name, 35873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "name",(char *) NULL)); 35883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[0]=XGetResourceClass(database,client_name,"pen1", 35893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "black"); 35903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[1]=XGetResourceClass(database,client_name,"pen2", 35913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "blue"); 35923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[2]=XGetResourceClass(database,client_name,"pen3", 35933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "cyan"); 35943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[3]=XGetResourceClass(database,client_name,"pen4", 35953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "green"); 35963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[4]=XGetResourceClass(database,client_name,"pen5", 35973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "gray"); 35983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[5]=XGetResourceClass(database,client_name,"pen6", 35993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "red"); 36003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[6]=XGetResourceClass(database,client_name,"pen7", 36013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "magenta"); 36023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[7]=XGetResourceClass(database,client_name,"pen8", 36033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "yellow"); 36043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[8]=XGetResourceClass(database,client_name,"pen9", 36053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "white"); 36063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[9]=XGetResourceClass(database,client_name,"pen0", 36073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "gray"); 36083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->pen_colors[10]=XGetResourceClass(database,client_name,"pen0", 36093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "gray"); 36103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"pause",(char *) "0"); 3611e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->pause=(unsigned int) StringToUnsignedLong(resource_value); 36123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"quantum",(char *) "1"); 3613f2f2727f17ecbb23d902f70bb98f81faabc92dbdcristy resource_info->quantum=StringToLong(resource_value); 36143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->text_font=XGetResourceClass(database,client_name,(char *) 36153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "font",(char *) "fixed"); 36163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->text_font=XGetResourceClass(database,client_name, 36173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "textFontList",resource_info->text_font); 36183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->title=XGetResourceClass(database,client_name,"title", 36193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 36203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"undoCache", 36213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "16"); 3622e27293e706ca05b6b121e9512a83b16f7ad887f2cristy resource_info->undo_cache=(unsigned int) StringToUnsignedLong(resource_value); 36233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"update", 36243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "False"); 36253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->update=IsMagickTrue(resource_value); 36263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"usePixmap", 36273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 36283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->use_pixmap=IsMagickTrue(resource_value); 36293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value=XGetResourceClass(database,client_name,"sharedMemory", 36303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) "True"); 36313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->use_shared_memory=IsMagickTrue(resource_value); 36323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->visual_type=XGetResourceClass(database,client_name,"visual", 36333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 36343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->window_group=XGetResourceClass(database,client_name, 36353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "windowGroup",(char *) NULL); 36363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->window_id=XGetResourceClass(database,client_name,"window", 36373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL); 36383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->write_filename=XGetResourceClass(database,client_name, 36393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "writeFilename",(char *) NULL); 36403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 36413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 36433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t R e s o u r c e I n s t a n c e % 36483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 36513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 36523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetResourceInstance() queries the X server for the specified resource name. 36543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% If the resource name is not defined in the database, the supplied default 36553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% value is returned. 36563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetResourceInstance method is: 36583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XGetResourceInstance(XrmDatabase database,const char *client_name, 36603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *keyword,const char *resource_default) 36613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 36633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o database: Specifies a resource database; returned from 36653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XrmGetStringDatabase. 36663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_name: Specifies the application name used to retrieve 36683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource info from the X server database. 36693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o keyword: Specifies the keyword of the value being retrieved. 36713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_default: Specifies the default value to return if the query 36733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% fails to find the specified keyword/class. 36743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 36753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 36763ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *XGetResourceInstance(XrmDatabase database, 36773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *client_name,const char *keyword,const char *resource_default) 36783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 36793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 36803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_type, 36813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_name[MaxTextExtent]; 36823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 36843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 36853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmValue 36873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_value; 36883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 36893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (database == (XrmDatabase) NULL) 36903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char *) resource_default); 36913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resource_name='\0'; 36923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (keyword != (char *) NULL) 3693b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(resource_name,MaxTextExtent,"%s.%s",client_name, 36943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy keyword); 36953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XrmGetResource(database,resource_name,"ImageMagick",&resource_type, 36963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &resource_value); 36973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 36983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((char *) resource_default); 36993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(resource_value.addr); 37003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 37013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 37033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t S c r e e n D e n s i t y % 37083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetScreenDensity() returns the density of the X server screen in 37143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% dots-per-inch. 37153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetScreenDensity method is: 37173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XGetScreenDensity(Display *display) 37193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 37213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o density: XGetScreenDensity() returns the density of the X screen in 37233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% dots-per-inch. 37243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 37263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 37273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 37293ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport char *XGetScreenDensity(Display *display) 37303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 37313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 37323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy density[MaxTextExtent]; 37333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy double 37353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_density, 37363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_density; 37373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 37393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set density as determined by screen size. 37403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 37413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_density=((((double) DisplayWidth(display,XDefaultScreen(display)))*25.4)/ 37423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((double) DisplayWidthMM(display,XDefaultScreen(display)))); 37433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_density=((((double) DisplayHeight(display,XDefaultScreen(display)))*25.4)/ 37443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((double) DisplayHeightMM(display,XDefaultScreen(display)))); 3745b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(density,MaxTextExtent,"%gx%g",x_density, 37468cd5b3193212b4aebce08c4e7afbb66b09778029cristy y_density); 37473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(GetPageGeometry(density)); 37483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 37493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 37513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X G e t S u b w i n d o w % 37563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 37593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 37603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetSubwindow() returns the subwindow of a window chosen the user with the 37623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pointer and a button press. 37633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetSubwindow method is: 37653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Window XGetSubwindow(Display *display,Window window,int x,int y) 37673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 37693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o subwindow: XGetSubwindow() returns NULL if no subwindow is found 37713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% otherwise the subwindow is returned. 37723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 37743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 37753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window. 37773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o x: the x coordinate of the pointer relative to the origin of the 37793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 37803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o y: the y coordinate of the pointer relative to the origin of the 37823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 37833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 37843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 37853ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window XGetSubwindow(Display *display,Window window,int x,int y) 37863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 37873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 37883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset, 37893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset; 37903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 37923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 37933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 37953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source_window, 37963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window; 37973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 37983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 37993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source_window=XRootWindow(display,XDefaultScreen(display)); 38003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window == (Window) NULL) 38013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(source_window); 38023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=window; 38033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for ( ; ; ) 38043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 38053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XTranslateCoordinates(display,source_window,window,x,y, 38063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &x_offset,&y_offset,&target_window); 38073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != True) 38083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 38093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 38103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 38113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source_window=window; 38123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=target_window; 38133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=x_offset; 38143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=y_offset; 38153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 38163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 38173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=window; 38183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 38193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 38203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 38223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t W i n d o w C o l o r % 38273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 38303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowColor() returns the color of a pixel interactively chosen from the 38333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X server. 38343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetWindowColor method is: 38363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XGetWindowColor(Display *display,XWindows *windows, 38386710d8414f0ed06e4eaf9346366be72e2b4719efcristy% char *name,ExceptionInfo *exception) 38393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 38413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 38433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 38443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 38463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o name: the name of the color if found in the X Color Database is 38483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned in this character string. 38493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 38506710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 38516710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 38523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 3853bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XGetWindowColor(Display *display, 38546710d8414f0ed06e4eaf9346366be72e2b4719efcristy XWindows *windows,char *name,ExceptionInfo *exception) 38553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 38563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 38573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 38583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 38593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 3860101ab708b0574518ac5715da4d3915400e9df79acristy PixelInfo 38613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 38623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 38643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 38653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 38673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 38683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 38703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 38713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window, 38723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window, 38733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window; 38743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 38763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color; 38773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 38793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 38803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowAttributes 38823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_attributes; 38833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 38843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 38853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Choose a pixel from the X server. 38863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 38873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 38883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(name != (char *) NULL); 38893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name); 38903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *name='\0'; 38913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=XSelectWindow(display,&crop_info); 38923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 38933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 38943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 38953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window=target_window; 38963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window != root_window) 38973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 38983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 38993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy d; 39003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get client window. 39033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetGeometry(display,target_window,&root_window,&x,&x,&d,&d,&d,&d); 39053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 39063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 39073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client_window=XClientWindow(display,target_window); 39083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=client_window; 39093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 39103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 39113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Verify window is viewable. 39133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowAttributes(display,target_window,&window_attributes); 39153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (window_attributes.map_state != IsViewable)) 39163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 39173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get window X image. 39193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,root_window,target_window, 39213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) crop_info.x,(int) crop_info.y,&x,&y,&child); 39223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XGetImage(display,target_window,x,y,1,1,AllPlanes,ZPixmap); 39233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 39243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 39253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=XGetPixel(ximage,0,0); 39263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 39273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 39283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Match color against the color database. 39293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 39303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColor(display,window_attributes.colormap,&color); 3931e42f658533644aecb733785ffd91b286d6778deacristy pixel.red=(double) ScaleShortToQuantum(color.red); 3932e42f658533644aecb733785ffd91b286d6778deacristy pixel.green=(double) ScaleShortToQuantum(color.green); 3933e42f658533644aecb733785ffd91b286d6778deacristy pixel.blue=(double) ScaleShortToQuantum(color.blue); 39344c08aed51c5899665ade97263692328eea4af106cristy pixel.alpha=OpaqueAlpha; 39353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) QueryColorname(windows->image.image,&pixel,X11Compliance,name, 39366710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 39373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 39383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 39393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 39413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 39423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X G e t W i n d o w I m a g e % 39463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 39493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 39503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowImage() reads an image from the target X window and returns it. 39523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowImage() optionally descends the window hierarchy and overlays the 39533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% target image with each child image in an optimized fashion. Any child 39543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window that have the same visual, colormap, and are contained by its parent 39553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% are exempted. 39563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetWindowImage method is: 39583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Image *XGetWindowImage(Display *display,const Window window, 39606710d8414f0ed06e4eaf9346366be72e2b4719efcristy% const unsigned int borders,const unsigned int level, 39616710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 39623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 39643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 39663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 39673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies the window to obtain the image from. 39693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o borders: Specifies whether borders pixels are to be saved with 39713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the image. 39723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o level: Specifies an unsigned integer representing the level of 39743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% decent in the window hierarchy. This value must be zero or one on 39753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the initial call to XGetWindowImage. A value of zero returns after 39763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% one call. A value of one causes the function to descend the window 39773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% hierarchy and overlay the target image with each subwindow image. 39783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 39796710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 39806710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 39813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 39823ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Image *XGetWindowImage(Display *display,const Window window, 39836710d8414f0ed06e4eaf9346366be72e2b4719efcristy const unsigned int borders,const unsigned int level,ExceptionInfo *exception) 39843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 39853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct _ColormapInfo 39863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 39873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 39883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 39893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 39913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colors; 39923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy struct _ColormapInfo 39943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *next; 39953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } ColormapInfo; 39963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 39973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy typedef struct _WindowInfo 39983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 39993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 40003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window, 40013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy parent; 40023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Visual 40043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *visual; 40053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 40073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 40083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSegment 40103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bounds; 40113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 40133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 40143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } WindowInfo; 40153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 40173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_height, 40183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_width, 40193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id, 40203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset, 40213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset; 40223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40234c08aed51c5899665ade97263692328eea4af106cristy Quantum 40244c08aed51c5899665ade97263692328eea4af106cristy index; 40254c08aed51c5899665ade97263692328eea4af106cristy 40263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 40273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 40283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 40303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 40313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static ColormapInfo 40333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colormap_info = (ColormapInfo *) NULL; 40343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static int 40363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows = 0, 40373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows = 0; 40383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static WindowInfo 40403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *window_info; 40413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 40433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 40443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 40463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 40473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 40483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowAttributes 40503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_attributes; 40513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 40523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Verify window is viewable. 40543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 40553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 40563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 40573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowAttributes(display,window,&window_attributes); 40583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (window_attributes.map_state != IsViewable)) 40593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 40603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cropping rectangle is relative to root window. 40623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 40633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 40643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,window,root_window,0,0,&x_offset, 40653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &y_offset,&child); 4066bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.x=(ssize_t) x_offset; 4067bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.y=(ssize_t) y_offset; 4068bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width=(size_t) window_attributes.width; 4069bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) window_attributes.height; 40703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (borders != MagickFalse) 40713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Include border in image. 40743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 4075bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.x-=(ssize_t) window_attributes.border_width; 4076bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.y-=(ssize_t) window_attributes.border_width; 4077bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width+=(size_t) (window_attributes.border_width << 1); 4078bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height+=(size_t) (window_attributes.border_width << 1); 40793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 40803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 40813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Crop to root window. 40823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 40833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_info.x < 0) 40843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.width+=crop_info.x; 40863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x=0; 40873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 40883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_info.y < 0) 40893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 40903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.height+=crop_info.y; 40913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y=0; 40923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 40933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_width=XDisplayWidth(display,XDefaultScreen(display)); 40943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) (crop_info.x+crop_info.width) > display_width) 4095bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width=(size_t) (display_width-crop_info.x); 40963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display_height=XDisplayHeight(display,XDefaultScreen(display)); 40973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) (crop_info.y+crop_info.height) > display_height) 4098bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) (display_height-crop_info.y); 40993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize window info attributes. 41013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_windows >= max_windows) 41033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate or resize window info buffer. 41063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows+=1024; 41083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info == (WindowInfo *) NULL) 41093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info=(WindowInfo *) AcquireQuantumMemory((size_t) max_windows, 41103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*window_info)); 41113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 41123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info=(WindowInfo *) ResizeQuantumMemory(window_info,(size_t) 41133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows,sizeof(*window_info)); 41143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info == (WindowInfo *) NULL) 41163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitError, 41183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed","..."); 41193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 41203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy id=number_windows++; 41223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].window=window; 41233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].visual=window_attributes.visual; 41243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].colormap=window_attributes.colormap; 41253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.x1=(short) crop_info.x; 41263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.y1=(short) crop_info.y; 41273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.x2=(short) (crop_info.x+(int) crop_info.width-1); 41283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].bounds.y2=(short) (crop_info.y+(int) crop_info.height-1); 41293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x-=x_offset; 41303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y-=y_offset; 41313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].crop_info=crop_info; 41323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (level != 0) 41333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 41353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 41363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 41383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children; 41393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Descend the window hierarchy. 41423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,window,&root_window,&window_info[id].parent, 41443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &children,&number_children); 41453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < id; i++) 41463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[i].window == window_info[id].parent) && 41473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[i].visual == window_info[id].visual) && 41483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[i].colormap == window_info[id].colormap)) 41493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].bounds.x1 <= window_info[i].bounds.x1) || 41513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.x1 >= window_info[i].bounds.x2) || 41523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 <= window_info[i].bounds.y1) || 41533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 >= window_info[i].bounds.y2)) 41543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 41563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Eliminate windows not circumscribed by their parent. 41573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 41583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows--; 41593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 41603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == True) && (number_children != 0)) 41633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 41643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_children; i++) 41656710d8414f0ed06e4eaf9346366be72e2b4719efcristy (void) XGetWindowImage(display,children[i],MagickFalse,level+1, 41666710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 41673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 41683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 41703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (level <= 1) 41713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4172c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 4173c57f694b2d04975a0e501613e34368c464708c19cristy *composite_view; 4174c57f694b2d04975a0e501613e34368c464708c19cristy 41753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ColormapInfo 41763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *next; 41773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 41793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *composite_image, 41803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image; 41813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 41833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 41843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 41863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy import; 41873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 41893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 41903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 41913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41924c08aed51c5899665ade97263692328eea4af106cristy register Quantum 4193c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 41943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4195bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register size_t 41963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 41973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 41983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 41993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors; 42003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 42023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colors; 42033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 42053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 42063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get X image for each window in the list. 42093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=NewImageList(); 42113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (id=0; id < number_windows; id++) 42123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Does target window intersect top level window? 42153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy import= 42173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((window_info[id].bounds.x2 >= window_info[0].bounds.x1) && 42183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.x1 <= window_info[0].bounds.x2) && 42193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y2 >= window_info[0].bounds.y1) && 42203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 <= window_info[0].bounds.y2)) ? 42213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickTrue : MagickFalse; 42223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Is target window contained by another window with the same colormap? 42243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < id; j++) 42263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual == window_info[j].visual) && 42273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].colormap == window_info[j].colormap)) 42283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].bounds.x1 <= window_info[j].bounds.x1) || 42303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.x1 >= window_info[j].bounds.x2) || 42313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 <= window_info[j].bounds.y1) || 42323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 >= window_info[j].bounds.y2)) 42333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy import=MagickFalse; 42343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 42363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual != window_info[j].visual) || 42373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].colormap != window_info[j].colormap)) 42383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].bounds.x2 > window_info[j].bounds.x1) && 42403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.x1 < window_info[j].bounds.x2) && 42413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y2 > window_info[j].bounds.y1) && 42423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].bounds.y1 < window_info[j].bounds.y2)) 42433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy import=MagickTrue; 42443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (import == MagickFalse) 42463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 42473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get X image. 42493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XGetImage(display,window_info[id].window,(int) 42513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].crop_info.x,(int) window_info[id].crop_info.y, 42523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) window_info[id].crop_info.width,(unsigned int) 42533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info[id].crop_info.height,AllPlanes,ZPixmap); 42543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 42553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 42563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize window colormap. 42583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=0; 42603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) NULL; 42613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info[id].colormap != (Colormap) NULL) 42623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ColormapInfo 42643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 42653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 42663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search colormap list for window colormap. 42683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=(unsigned int) window_info[id].visual->map_entries; 42703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (p=colormap_info; p != (ColormapInfo *) NULL; p=p->next) 42713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p->colormap == window_info[id].colormap) 42723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 42733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p == (ColormapInfo *) NULL) 42743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 42763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get the window colormap. 42773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 42783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory(number_colors, 42793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*colors)); 42803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 42813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 42823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 42833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 42843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual->klass != DirectColor) && 42863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].visual->klass != TrueColor)) 42873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 42883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4289bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy colors[i].pixel=(size_t) i; 42903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors[i].pad='\0'; 42913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 42923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 42933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4294bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 42953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue, 42963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_bit, 42973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green, 42983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_bit, 42993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red, 43003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_bit; 43013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 43023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DirectColor or TrueColor visual. 43043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red=0; 43063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green=0; 43073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue=0; 43083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_bit=window_info[id].visual->red_mask & 43093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~(window_info[id].visual->red_mask)+1); 43103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_bit=window_info[id].visual->green_mask & 43113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~(window_info[id].visual->green_mask)+1); 43123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_bit=window_info[id].visual->blue_mask & 43133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~(window_info[id].visual->blue_mask)+1); 43143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_colors; i++) 43153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43168891f9ce489d3e61399b60436ea6c62f5ed9b887cristy colors[i].pixel=(unsigned long) (red | green | blue); 43173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors[i].pad='\0'; 43183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red+=red_bit; 43193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (red > window_info[id].visual->red_mask) 43203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red=0; 43213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green+=green_bit; 43223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (green > window_info[id].visual->green_mask) 43233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green=0; 43243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue+=blue_bit; 43253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (blue > window_info[id].visual->blue_mask) 43263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue=0; 43273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display,window_info[id].colormap,colors, 43303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) number_colors); 43313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Append colormap to colormap list. 43333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 433473bd4a51b419e914565bdf204bf1540dc4c8ee26cristy p=(ColormapInfo *) AcquireMagickMemory(sizeof(*p)); 43353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p == (ColormapInfo *) NULL) 43363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 43373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->colormap=window_info[id].colormap; 43383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->colors=colors; 43393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->next=colormap_info; 43403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=p; 43413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=p->colors; 43433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate image structure. 43463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43476710d8414f0ed06e4eaf9346366be72e2b4719efcristy composite_image=AcquireImage((ImageInfo *) NULL,exception); 43483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (composite_image == (Image *) NULL) 43493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 43513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 43523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert X image to MIFF format. 43553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window_info[id].visual->klass != TrueColor) && 43573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].visual->klass != DirectColor)) 43583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image->storage_class=PseudoClass; 4359bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy composite_image->columns=(size_t) ximage->width; 4360bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy composite_image->rows=(size_t) ximage->height; 4361c57f694b2d04975a0e501613e34368c464708c19cristy composite_view=AcquireCacheView(composite_image); 43623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (composite_image->storage_class) 43633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case DirectClass: 43653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 43663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4367bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register size_t 43683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color, 43693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index; 43703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 4371bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 43723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_mask, 43733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_shift, 43743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_mask, 43753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_shift, 43763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_mask, 43773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_shift; 43783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 43793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 43803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine shift and mask for red, green, and blue. 43813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 43823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_mask=window_info[id].visual->red_mask; 43833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_shift=0; 43843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((red_mask != 0) && ((red_mask & 0x01) == 0)) 43853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_mask>>=1; 43873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy red_shift++; 43883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_mask=window_info[id].visual->green_mask; 43903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_shift=0; 43913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((green_mask != 0) && ((green_mask & 0x01) == 0)) 43923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 43933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_mask>>=1; 43943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy green_shift++; 43953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 43963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_mask=window_info[id].visual->blue_mask; 43973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_shift=0; 43983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((blue_mask != 0) && ((blue_mask & 0x01) == 0)) 43993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_mask>>=1; 44013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy blue_shift++; 44023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 44043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert X image to DirectClass packets. 44053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 44063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((number_colors != 0) && 44073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (window_info[id].visual->klass == DirectColor)) 44083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) composite_image->rows; y++) 44093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4410c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(composite_view,0,(ssize_t) y, 44113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image->columns,1,exception); 4412acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 44133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) composite_image->columns; x++) 44153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel=XGetPixel(ximage,x,y); 44173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=(pixel >> red_shift) & red_mask; 44184c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(composite_image, 44194c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum(colors[index].red),q); 44203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=(pixel >> green_shift) & green_mask; 44214c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(composite_image, 44224c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum(colors[index].green),q); 44233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=(pixel >> blue_shift) & blue_mask; 44244c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(composite_image, 44254c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum(colors[index].blue),q); 4426ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(composite_image); 44273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44280b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=SyncCacheViewAuthenticPixels(composite_view,exception); 44290b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 44333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) composite_image->rows; y++) 44343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4435c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(composite_view,0,(ssize_t) y, 44363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image->columns,1,exception); 4437acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 44383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) composite_image->columns; x++) 44403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel=XGetPixel(ximage,x,y); 44423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(pixel >> red_shift) & red_mask; 44433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(65535UL*color)/red_mask; 44444c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(composite_image, 44454c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum((unsigned short) color),q); 44463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(pixel >> green_shift) & green_mask; 44473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(65535UL*color)/green_mask; 44484c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(composite_image, 44494c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum((unsigned short) color),q); 44503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(pixel >> blue_shift) & blue_mask; 44513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color=(65535UL*color)/blue_mask; 44524c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(composite_image, 44534c08aed51c5899665ade97263692328eea4af106cristy ScaleShortToQuantum((unsigned short) color),q); 4454ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(composite_image); 44553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44560b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=SyncCacheViewAuthenticPixels(composite_view,exception); 44570b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PseudoClass: 44633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 44653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create colormap. 44663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 44670b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=AcquireImageColormap(composite_image,number_colors, 44680b1a797184d12984eb55d950fb5f532298d9fd0fcristy exception); 44690b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 44703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 44723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy composite_image=DestroyImage(composite_image); 44733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 44743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) composite_image->colors; i++) 44763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4477e42f658533644aecb733785ffd91b286d6778deacristy composite_image->colormap[colors[i].pixel].red=(double) 44783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleShortToQuantum(colors[i].red); 4479e42f658533644aecb733785ffd91b286d6778deacristy composite_image->colormap[colors[i].pixel].green=(double) 44803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleShortToQuantum(colors[i].green); 4481e42f658533644aecb733785ffd91b286d6778deacristy composite_image->colormap[colors[i].pixel].blue=(double) 44823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleShortToQuantum(colors[i].blue); 44833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 44843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 44853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert X image to PseudoClass packets. 44863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 44873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) composite_image->rows; y++) 44883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 4489c57f694b2d04975a0e501613e34368c464708c19cristy q=QueueCacheViewAuthenticPixels(composite_view,0,(ssize_t) y, 4490c57f694b2d04975a0e501613e34368c464708c19cristy composite_image->columns,1,exception); 4491acd2ed254c18c254a0ab5aafa06d1645e5d079d8cristy if (q == (Quantum *) NULL) 44923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 44933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) composite_image->columns; x++) 44943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 44954c08aed51c5899665ade97263692328eea4af106cristy index=(Quantum) XGetPixel(ximage,x,y); 44964c08aed51c5899665ade97263692328eea4af106cristy SetPixelIndex(composite_image,index,q); 4497803640d20a6a664315eddfff6f8531d0c5e0871dcristy SetPixelInfoPixel(composite_image, 44984c08aed51c5899665ade97263692328eea4af106cristy composite_image->colormap+(ssize_t) index,q); 4499ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(composite_image); 45003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45010b1a797184d12984eb55d950fb5f532298d9fd0fcristy status=SyncCacheViewAuthenticPixels(composite_view,exception); 45020b1a797184d12984eb55d950fb5f532298d9fd0fcristy if (status == MagickFalse) 45033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 45043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 45063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 4508c57f694b2d04975a0e501613e34368c464708c19cristy composite_view=DestroyCacheView(composite_view); 45093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 45103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image == (Image *) NULL) 45113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 45123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=composite_image; 45133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 45143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Composite any children in back-to-front order. 45173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,window_info[id].window,window,0,0, 45193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &x_offset,&y_offset,&child); 45203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset-=(int) crop_info.x; 45213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x_offset < 0) 45223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset=0; 45233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset-=(int) crop_info.y; 45243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y_offset < 0) 45253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset=0; 4526c57f694b2d04975a0e501613e34368c464708c19cristy (void) CompositeImage(image,CopyCompositeOp,composite_image,(ssize_t) 4527e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy x_offset,(ssize_t) y_offset,exception); 45285f257b2f02bdd982d9bbfe612f5bb1711608590ccristy composite_image=DestroyImage(composite_image); 45293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources. 45323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (colormap_info != (ColormapInfo *) NULL) 45343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 45353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy next=colormap_info->next; 4536e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy colormap_info->colors=(XColor *) RelinquishMagickMemory( 4537e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy colormap_info->colors); 45383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=(ColormapInfo *) RelinquishMagickMemory(colormap_info); 45393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=next; 45403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Relinquish resources and restore initial state. 45433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info=(WindowInfo *) RelinquishMagickMemory(window_info); 45453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy max_windows=0; 45463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows=0; 45473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_info=(ColormapInfo *) NULL; 45483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 45493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 45503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 45513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 45523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 45533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 45543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t W i n d o w I n f o % 45593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 45623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetWindowInfo() initializes the XWindowInfo structure. 45653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetWindowInfo method is: 45673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetWindowInfo(Display *display,XVisualInfo *visual_info, 45693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 45703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info,XWindowInfo *window) 45713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% resource_info,window) 45723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 45743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 45763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 45773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 45793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 45803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If map_type is specified, this structure is initialized 45823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% with info from the Standard Colormap. 45833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 45853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o font_info: Specifies a pointer to a XFontStruct structure. 45873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 45893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 45903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4591bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XGetWindowInfo(Display *display,XVisualInfo *visual_info, 45923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap *map_info,XPixelInfo *pixel,XFontStruct *font_info, 45933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XResourceInfo *resource_info,XWindowInfo *window) 45943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 45953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 45963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize window info. 45973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 45983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 45993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 46003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 46013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 46023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 46033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 46043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 46053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->id != (Window) NULL) 46063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 46073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->cursor != (Cursor) NULL) 46083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window->cursor); 46093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->busy_cursor != (Cursor) NULL) 46103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,window->busy_cursor); 46113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->highlight_stipple != (Pixmap) NULL) 46123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->highlight_stipple); 46133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shadow_stipple != (Pixmap) NULL) 46143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->shadow_stipple); 46153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->name == (char *) NULL) 46163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->name=AcquireString(""); 46173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->icon_name == (char *) NULL) 46183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->icon_name=AcquireString(""); 46193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 46203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 46213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 46223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 46233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize these attributes just once. 46243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 46253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->id=(Window) NULL; 46263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->name == (char *) NULL) 46273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->name=AcquireString(""); 46283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->icon_name == (char *) NULL) 46293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->icon_name=AcquireString(""); 46303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->x=XDisplayWidth(display,visual_info->screen) >> 1; 46313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->y=XDisplayWidth(display,visual_info->screen) >> 1; 46323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage=(XImage *) NULL; 46333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image=(XImage *) NULL; 46343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixmap=(Pixmap) NULL; 46353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap=(Pixmap) NULL; 46363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->mapped=MagickFalse; 46373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->stasis=MagickFalse; 46383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickTrue; 46393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->segment_info=(void *) NULL; 46403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 46413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 46423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 46433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 46443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 46453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->segment_info == (void *) NULL) 46463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->segment_info=AcquireQuantumMemory(2,sizeof(*segment_info)); 46473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 46483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmid=(-1); 46493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmaddr=(char *) NULL; 46503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 46513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 46523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 46533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 46543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 46553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 46563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize these attributes every time function is called. 46573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 46583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->screen=visual_info->screen; 46593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->root=XRootWindow(display,visual_info->screen); 46603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->visual=visual_info->visual; 46613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->storage_class=(unsigned int) visual_info->klass; 46623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->depth=(unsigned int) visual_info->depth; 46633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->visual_info=visual_info; 46643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->map_info=map_info; 46653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixel_info=pixel; 46663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->font_info=font_info; 46673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->cursor=XCreateFontCursor(display,XC_left_ptr); 46683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->busy_cursor=XCreateFontCursor(display,XC_watch); 46693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->geometry=(char *) NULL; 46703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->icon_geometry=(char *) NULL; 46713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->icon_geometry != (char *) NULL) 46723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CloneString(&window->icon_geometry,resource_info->icon_geometry); 46733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->crop_geometry=(char *) NULL; 4674bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy window->flags=(size_t) PSize; 46753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width=1; 46763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height=1; 46773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->min_width=1; 46783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->min_height=1; 46793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->width_inc=1; 46803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->height_inc=1; 46813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->border_width=resource_info->border_width; 46823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->annotate_context=pixel->annotate_context; 46833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->highlight_context=pixel->highlight_context; 46843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->widget_context=pixel->widget_context; 46853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shadow_stipple=(Pixmap) NULL; 46863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->highlight_stipple=(Pixmap) NULL; 46873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->use_pixmap=MagickTrue; 46883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->immutable=MagickFalse; 46893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shape=MagickFalse; 46903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->data=0; 4691c57f694b2d04975a0e501613e34368c464708c19cristy window->mask=(int) (CWBackingStore | CWBackPixel | CWBackPixmap | 46923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CWBitGravity | CWBorderPixel | CWColormap | CWCursor | CWDontPropagate | 46933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy CWEventMask | CWOverrideRedirect | CWSaveUnder | CWWinGravity); 46943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.background_pixel=pixel->background_color.pixel; 46953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.background_pixmap=(Pixmap) NULL; 46963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.bit_gravity=ForgetGravity; 46973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.backing_store=WhenMapped; 46983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.save_under=MagickTrue; 46993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.border_pixel=pixel->border_color.pixel; 47003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.colormap=map_info->colormap; 47013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.cursor=window->cursor; 47023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.do_not_propagate_mask=NoEventMask; 47033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.event_mask=NoEventMask; 47043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.override_redirect=MagickFalse; 47053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->attributes.win_gravity=NorthWestGravity; 47063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->orphan=MagickFalse; 47073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 47083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 47093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 47103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X H i g h l i g h t E l l i p s e % 47153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XHighlightEllipse() puts a border on the X server around a region defined by 47213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% highlight_info. 47223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XHighlightEllipse method is: 47243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XHighlightEllipse(Display *display,Window window, 47263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% GC annotate_context,const RectangleInfo *highlight_info) 47273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 47293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 47313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 47323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 47343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_context: Specifies a pointer to a GC structure. 47363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o highlight_info: Specifies a pointer to a RectangleInfo structure. It 47383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any highlighting rectangle. 47393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4741bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XHighlightEllipse(Display *display,Window window, 47423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC annotate_context,const RectangleInfo *highlight_info) 47433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 47443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 47453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 47463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 47473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_context != (GC) NULL); 47483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(highlight_info != (RectangleInfo *) NULL); 47493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((highlight_info->width < 4) || (highlight_info->height < 4)) 47503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 47513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawArc(display,window,annotate_context,(int) highlight_info->x, 47523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info->y,(unsigned int) highlight_info->width-1, 47533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-1,0,360*64); 47543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawArc(display,window,annotate_context,(int) highlight_info->x+1, 47553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info->y+1,(unsigned int) highlight_info->width-3, 47563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-3,0,360*64); 47573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 47583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 47593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 47603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X H i g h l i g h t L i n e % 47653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 47683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XHighlightLine() puts a border on the X server around a region defined by 47713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% highlight_info. 47723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XHighlightLine method is: 47743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XHighlightLine(Display *display,Window window,GC annotate_context, 47763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XSegment *highlight_info) 47773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 47793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 47813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 47823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 47843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_context: Specifies a pointer to a GC structure. 47863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o highlight_info: Specifies a pointer to a RectangleInfo structure. It 47883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any highlighting rectangle. 47893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 47903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4791bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XHighlightLine(Display *display,Window window, 47923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC annotate_context,const XSegment *highlight_info) 47933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 47943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 47953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 47963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 47973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_context != (GC) NULL); 47983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(highlight_info != (XSegment *) NULL); 47993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawLine(display,window,annotate_context,highlight_info->x1, 48003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info->y1,highlight_info->x2,highlight_info->y2); 48013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 48023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 48043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X H i g h l i g h t R e c t a n g l e % 48093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XHighlightRectangle() puts a border on the X server around a region defined 48153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% by highlight_info. 48163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XHighlightRectangle method is: 48183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XHighlightRectangle(Display *display,Window window, 48203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% GC annotate_context,const RectangleInfo *highlight_info) 48213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 48233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 48253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 48263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window structure. 48283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o annotate_context: Specifies a pointer to a GC structure. 48303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o highlight_info: Specifies a pointer to a RectangleInfo structure. It 48323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any highlighting rectangle. 48333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 4835bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XHighlightRectangle(Display *display,Window window, 48363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC annotate_context,const RectangleInfo *highlight_info) 48373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 48383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 48393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 48403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 48413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(annotate_context != (GC) NULL); 48423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(highlight_info != (RectangleInfo *) NULL); 48433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((highlight_info->width < 4) || (highlight_info->height < 4)) 48443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 48453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,window,annotate_context,(int) highlight_info->x, 48463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info->y,(unsigned int) highlight_info->width-1, 48473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-1); 48483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,window,annotate_context,(int) highlight_info->x+ 48493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1,(int) highlight_info->y+1,(unsigned int) highlight_info->width-3, 48503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info->height-3); 48513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 48523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 48543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X I m p o r t I m a g e % 48593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 48623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XImportImage() reads an image from an X window. 48653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XImportImage method is: 48673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48686710d8414f0ed06e4eaf9346366be72e2b4719efcristy% Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info, 48696710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 48703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 48723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: the image info. 48743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage_info: Specifies a pointer to an XImportInfo structure. 48763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 48776710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 48786710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 48793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 48803ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport Image *XImportImage(const ImageInfo *image_info, 48816710d8414f0ed06e4eaf9346366be72e2b4719efcristy XImportInfo *ximage_info,ExceptionInfo *exception) 48823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 48833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 48843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colormaps; 48853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Display 48873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *display; 48883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 48903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image; 48913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 48933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colormaps, 48943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows, 48953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 48963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 48973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 48983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 48993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 49013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 49023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 49043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 49053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client, 49063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy prior_target, 49073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root, 49083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target; 49093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextProperty 49113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 49123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Open X server connection. 49153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info != (const ImageInfo *) NULL); 49173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info->signature == MagickSignature); 49183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image_info->debug != MagickFalse) 49193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 49203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename); 49213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(ximage_info != (XImportInfo *) NULL); 49223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay(image_info->server_name); 49233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 49243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToOpenXServer", 49263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDisplayName(image_info->server_name)); 49273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 49283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set our forgiving exception handler. 49313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetErrorHandler(XError); 49333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select target window. 49353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x=0; 49373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y=0; 49383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.width=0; 49393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.height=0; 49403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root=XRootWindow(display,XDefaultScreen(display)); 49413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=(Window) NULL; 49423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image_info->filename != (char *) NULL) && 49433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*image_info->filename != '\0')) 49443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare(image_info->filename,"root") == 0) 49463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=root; 49473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 49483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select window by ID or name. 49513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (isdigit((unsigned char) *image_info->filename) != 0) 49533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=XWindowByID(display,root,(Window) 49543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol(image_info->filename,(char **) NULL,0)); 49553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 49563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=XWindowByName(display,root,image_info->filename); 49573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 49583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError, 49593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "NoWindowWithSpecifiedIDExists",image_info->filename); 49603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy If target window is not defined, interactively select one. 49643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy prior_target=target; 49663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 49673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=XSelectWindow(display,&crop_info); 49683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target == (Window) NULL) 49693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToReadXWindowImage", 49703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename); 49713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client=target; /* obsolete */ 49723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target != root) 49733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 49753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy d; 49763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetGeometry(display,target,&root,&x,&x,&d,&d,&d,&d); 49783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 49793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for ( ; ; ) 49813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 49823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 49833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy parent; 49843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 49853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Find window manager frame. 49873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,target,&root,&parent,&children,&d); 49893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status != False) && (children != (Window *) NULL)) 49903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((char *) children); 49913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (parent == (Window) NULL) || 49923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (parent == root)) 49933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 49943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=parent; 49953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 49963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 49973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get client window. 49983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 49993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy client=XClientWindow(display,target); 50003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->frame == MagickFalse) 50013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=client; 50023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage_info->frame == MagickFalse) && 50033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (prior_target != MagickFalse)) 50043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=prior_target; 50053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->screen) 50083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 50103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 50113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 50133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child; 50143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowAttributes 50163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_attributes; 50173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Obtain window image directly from screen. 50203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowAttributes(display,target,&window_attributes); 50223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 50233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError, 50253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToReadXWindowAttributes",image_info->filename); 50263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCloseDisplay(display); 50273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 50283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XTranslateCoordinates(display,target,root,0,0,&x,&y,&child); 5030c57f694b2d04975a0e501613e34368c464708c19cristy crop_info.x=(ssize_t) x; 5031c57f694b2d04975a0e501613e34368c464708c19cristy crop_info.y=(ssize_t) y; 5032bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.width=(size_t) window_attributes.width; 5033bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy crop_info.height=(size_t) window_attributes.height; 5034553743c2f2d6c29405dcfab6390a1c505c79fececristy if (ximage_info->borders != 0) 50353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Include border in image. 50383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.x-=window_attributes.border_width; 50403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.y-=window_attributes.border_width; 50413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.width+=window_attributes.border_width << 1; 50423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info.height+=window_attributes.border_width << 1; 50433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target=root; 50453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy If WM_COLORMAP_WINDOWS property is set or multiple colormaps, descend. 50483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_windows=0; 50503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWMColormapWindows(display,target,&children,&number_windows); 50513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == True) && (number_windows > 0)) 50523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->descend=MagickTrue; 50543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree ((char *) children); 50553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormaps=XListInstalledColormaps(display,target,&number_colormaps); 50573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_colormaps > 0) 50583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (number_colormaps > 1) 50603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->descend=MagickTrue; 50613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((char *) colormaps); 50623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 50633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Alert the user not to alter the screen. 50653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->silent == MagickFalse) 50673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XBell(display,0); 50683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Get image by window id. 50703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XGrabServer(display); 50723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=XGetWindowImage(display,target,ximage_info->borders, 50736710d8414f0ed06e4eaf9346366be72e2b4719efcristy ximage_info->descend ? 1U : 0U,exception); 50743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XUngrabServer(display); 50753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image == (Image *) NULL) 50763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToReadXWindowImage", 50773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename) 50783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 50793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image->filename,image_info->filename, 50813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MaxTextExtent); 50823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info.width != 0) && (crop_info.height != 0)) 50833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 50853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *clone_image, 50863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *crop_image; 50873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 50883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 50893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Crop image as defined by the cropping rectangle. 50903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 50916710d8414f0ed06e4eaf9346366be72e2b4719efcristy clone_image=CloneImage(image,0,0,MagickTrue,exception); 50923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (clone_image != (Image *) NULL) 50933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50946710d8414f0ed06e4eaf9346366be72e2b4719efcristy crop_image=CropImage(clone_image,&crop_info,exception); 50953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_image != (Image *) NULL) 50963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 50973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=DestroyImage(image); 50983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image=crop_image; 50993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWMName(display,target,&window_name); 51033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == True) 51043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image_info->filename != (char *) NULL) && 51063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (*image_info->filename == '\0')) 51073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image->filename,(char *) window_name.value, 51083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (size_t) window_name.nitems+1); 51093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) window_name.value); 51103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage_info->silent == MagickFalse) 51133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 51153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Alert the user we're done. 51163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 51173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XBell(display,0); 51183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XBell(display,0); 51193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCloseDisplay(display); 51213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(image); 51223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 51233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 51243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 51253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 51263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X I n i t i a l i z e W i n d o w s % 51303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 51333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 51343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XInitializeWindows() initializes the XWindows structure. 51363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XInitializeWindows method is: 51383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindows *XInitializeWindows(Display *display, 51403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info) 51413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 51433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: XInitializeWindows returns a pointer to a XWindows structure. 51453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 51473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 51483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 51503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 51513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 5152bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XWindows *XInitializeWindows(Display *display, 51533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XResourceInfo *resource_info) 51543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 51553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 51563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 51573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 51583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 51593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 51603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 51613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 51623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate windows structure. 51633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 516473bd4a51b419e914565bdf204bf1540dc4c8ee26cristy windows=(XWindows *) AcquireMagickMemory(sizeof(*windows)); 51653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows == (XWindows *) NULL) 51663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"MemoryAllocationFailed", 51683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "..."); 51693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XWindows *) NULL); 51703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ResetMagickMemory(windows,0,sizeof(*windows)); 51723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info=(XPixelInfo *) AcquireMagickMemory( 51733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*windows->pixel_info)); 51743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_pixel=(XPixelInfo *) AcquireMagickMemory( 51753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*windows->icon_pixel)); 51763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources=(XResourceInfo *) AcquireMagickMemory( 51773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*windows->icon_resources)); 51783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->pixel_info == (XPixelInfo *) NULL) || 51793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_pixel == (XPixelInfo *) NULL) || 51803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_resources == (XResourceInfo *) NULL)) 51813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 51823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"MemoryAllocationFailed", 51833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "..."); 51843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((XWindows *) NULL); 51853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 51863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 51873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize windows structure. 51883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 51893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->display=display; 51903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_protocols=XInternAtom(display,"WM_PROTOCOLS",MagickFalse); 51913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_delete_window=XInternAtom(display,"WM_DELETE_WINDOW",MagickFalse); 51923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_take_focus=XInternAtom(display,"WM_TAKE_FOCUS",MagickFalse); 51933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_protocols=XInternAtom(display,"IM_PROTOCOLS",MagickFalse); 51943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_remote_command= 51953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XInternAtom(display,"IM_REMOTE_COMMAND",MagickFalse); 51963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_update_widget=XInternAtom(display,"IM_UPDATE_WIDGET",MagickFalse); 51973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_update_colormap= 51983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XInternAtom(display,"IM_UPDATE_COLORMAP",MagickFalse); 51993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_former_image=XInternAtom(display,"IM_FORMER_IMAGE",MagickFalse); 52003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_next_image=XInternAtom(display,"IM_NEXT_IMAGE",MagickFalse); 52013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_retain_colors=XInternAtom(display,"IM_RETAIN_COLORS",MagickFalse); 52023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_exit=XInternAtom(display,"IM_EXIT",MagickFalse); 52033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->dnd_protocols=XInternAtom(display,"DndProtocol",MagickFalse); 52040157aeadef2fce908277168097a160a8f15a6952cristy#if defined(MAGICKCORE_WINDOWS_SUPPORT) 52053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSynchronize(display,IsWindows95()); 52063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 52073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 52083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 52093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSynchronize(display,MagickTrue); 52103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Version: %s", 5211bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy GetMagickVersion((size_t *) NULL)); 52123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Protocols:"); 52133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " Window Manager: 0x%lx",windows->wm_protocols); 52153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " delete window: 0x%lx",windows->wm_delete_window); 52173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," take focus: 0x%lx", 52183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->wm_take_focus); 52193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," ImageMagick: 0x%lx", 52203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_protocols); 52213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " remote command: 0x%lx",windows->im_remote_command); 52233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " update widget: 0x%lx",windows->im_update_widget); 52253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " update colormap: 0x%lx",windows->im_update_colormap); 52273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " former image: 0x%lx",windows->im_former_image); 52293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," next image: 0x%lx", 52303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_next_image); 52313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " retain colors: 0x%lx",windows->im_retain_colors); 52333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," exit: 0x%lx", 52343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->im_exit); 52353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," Drag and Drop: 0x%lx", 52363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->dnd_protocols); 52373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 52383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate standard colormap. 52403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->map_info=XAllocStandardColormap(); 52423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_map=XAllocStandardColormap(); 52433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->map_info == (XStandardColormap *) NULL) || 52443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_map == (XStandardColormap *) NULL)) 52453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 52463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed","..."); 52473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->map_info->colormap=(Colormap) NULL; 52483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_map->colormap=(Colormap) NULL; 5249f2faecf9facdbbb14fcba373365f9f691a9658e0cristy windows->pixel_info->pixels=(unsigned long *) NULL; 52503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info->annotate_context=(GC) NULL; 52513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info->highlight_context=(GC) NULL; 52523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pixel_info->widget_context=(GC) NULL; 52533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->font_info=(XFontStruct *) NULL; 52543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_pixel->annotate_context=(GC) NULL; 5255f2faecf9facdbbb14fcba373365f9f691a9658e0cristy windows->icon_pixel->pixels=(unsigned long *) NULL; 52563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate visual. 52583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows->icon_resources=(*resource_info); 52603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources->visual_type=(char *) "default"; 52613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_resources->colormap=SharedColormap; 52623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info= 52633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestVisualInfo(display,windows->map_info,resource_info); 52643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->icon_visual= 52653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestVisualInfo(display,windows->icon_map,windows->icon_resources); 52663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->visual_info == (XVisualInfo *) NULL) || 52673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->icon_visual == (XVisualInfo *) NULL)) 52683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToGetVisual", 52693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->visual_type); 52703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 52713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 52723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Visual:"); 52733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," visual id: 0x%lx", 52743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->visualid); 52753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," class: %s", 52763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualClassName(windows->visual_info->klass)); 52773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," depth: %d planes", 52783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->depth); 52793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " size of colormap: %d entries",windows->visual_info->colormap_size); 52813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue masks: 0x%lx 0x%lx 0x%lx", 52833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->red_mask,windows->visual_info->green_mask, 52843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->blue_mask); 52853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 52863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " significant bits in color: %d bits", 52873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->visual_info->bits_per_rgb); 52883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 52893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate class and manager hints. 52913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 52923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->class_hints=XAllocClassHint(); 52933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->manager_hints=XAllocWMHints(); 52943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->class_hints == (XClassHint *) NULL) || 52953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->manager_hints == (XWMHints *) NULL)) 52963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 52973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "MemoryAllocationFailed","..."); 52983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 52993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine group leader if we have one. 53003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 53013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,windows->visual_info->screen); 53023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->group_leader.id=(Window) NULL; 53033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->window_group != (char *) NULL) 53043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 53053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (isdigit((unsigned char) *resource_info->window_group) != 0) 53063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->group_leader.id=XWindowByID(display,root_window,(Window) 53073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol((char *) resource_info->window_group,(char **) NULL,0)); 53083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->group_leader.id == (Window) NULL) 53093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->group_leader.id= 53103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowByName(display,root_window,resource_info->window_group); 53113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 53123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(windows); 53133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 53143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 53163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e C u r s o r % 53213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 53243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeCursor() creates a crosshairs X11 cursor. 53273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeCursor method is: 53293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Cursor XMakeCursor(Display *display,Window window,Colormap colormap, 53313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *background_color,char *foreground_color) 53323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 53343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 53363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 53373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies the ID of the window for which the cursor is 53393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% assigned. 53403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o colormap: Specifies the ID of the colormap from which the background 53423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% and foreground color will be retrieved. 53433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o background_color: Specifies the color to use for the cursor background. 53453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o foreground_color: Specifies the color to use for the cursor foreground. 53473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 53483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 5349bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Cursor XMakeCursor(Display *display,Window window, 53503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap colormap,char *background_color,char *foreground_color) 53513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 53523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_height 17 53533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_x_hot 8 53543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_y_hot 8 53553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define scope_width 17 53563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static const unsigned char 53583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_bits[] = 53593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 53603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x80, 0x03, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 53613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x7f, 53623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xfc, 0x01, 0x01, 0x00, 0x01, 0x7f, 0xfc, 0x01, 0x80, 0x02, 0x00, 53633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 53643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0x80, 0x02, 0x00, 0x80, 0x03, 0x00 53653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }, 53663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_mask_bits[] = 53673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 53683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xc0, 0x07, 0x00, 0xc0, 0x07, 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 53693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 0x00, 0xff, 0xfe, 0x01, 0x7f, 53703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xfc, 0x01, 0x03, 0x80, 0x01, 0x7f, 0xfc, 0x01, 0xff, 0xfe, 0x01, 53713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0xc0, 0x06, 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 0x00, 0xc0, 0x06, 53723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 0x00, 0xc0, 0x07, 0x00, 0xc0, 0x07, 0x00 53733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy }; 53743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cursor 53763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cursor; 53773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 53793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask, 53803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source; 53813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 53833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 53843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground; 53853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 53863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 53873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 53883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(colormap != (Colormap) NULL); 53893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(background_color != (char *) NULL); 53903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(foreground_color != (char *) NULL); 53913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",background_color); 53923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy source=XCreateBitmapFromData(display,window,(char *) scope_bits,scope_width, 53933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_height); 53943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask=XCreateBitmapFromData(display,window,(char *) scope_mask_bits, 53953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_width,scope_height); 53963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((source == (Pixmap) NULL) || (mask == (Pixmap) NULL)) 53973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 53983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToCreatePixmap","..."); 53993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Cursor) NULL); 54003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 54013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,background_color,&background); 54023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XParseColor(display,colormap,foreground_color,&foreground); 54033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cursor=XCreatePixmapCursor(display,source,mask,&foreground,&background, 54043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scope_x_hot,scope_y_hot); 54053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,source); 54063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,mask); 54073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(cursor); 54083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 54093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 54113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e I m a g e % 54163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 54193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeImage() creates an X11 image. If the image size differs from the X11 54223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% image size, the image is first resized. 54233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeImage method is: 54253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XMakeImage(Display *display, 54273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XResourceInfo *resource_info,XWindowInfo *window,Image *image, 5428051718b74ad68f8584cdac01d0192974ec777f1bcristy% unsigned int width,unsigned int height,ExceptionInfo *exception) 54293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 54313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 54333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 54343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 54363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 54383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 54403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o width: Specifies the width in pixels of the rectangular area to 54423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% display. 54433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 54443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o height: Specifies the height in pixels of the rectangular area to 54453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% display. 54463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5447051718b74ad68f8584cdac01d0192974ec777f1bcristy% o exception: return any errors or warnings in this structure. 5448051718b74ad68f8584cdac01d0192974ec777f1bcristy% 54493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 5450bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XMakeImage(Display *display, 54513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,XWindowInfo *window,Image *image, 5452051718b74ad68f8584cdac01d0192974ec777f1bcristy unsigned int width,unsigned int height,ExceptionInfo *exception) 54533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 54543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define CheckOverflowException(length,width,height) \ 54553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (((height) != 0) && ((length)/((size_t) height) != ((size_t) width))) 54563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 54583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth, 54593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 54603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_t 54623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length; 54633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 54653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *matte_image, 54663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 54673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 54693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 54703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 54713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 54723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(width != 0); 54733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(height != 0); 54743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->width == 0) || (window->height == 0)) 54753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 54763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 54773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Apply user transforms to the image. 54783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 54793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->busy_cursor); 54803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 54813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy depth=(int) window->depth; 54823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->destroy) 54833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=DestroyImage(window->image); 54843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=image; 54853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->destroy=MagickFalse; 54863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != (Image *) NULL) 54873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 54883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->crop_geometry != (char *) NULL) 54893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 54903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 54913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *crop_image; 54923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 54943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info; 54953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 54963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 54973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Crop image. 54983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 54993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image->page.x=0; 55003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image->page.y=0; 55013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ParsePageGeometry(window->image,window->crop_geometry, 55026710d8414f0ed06e4eaf9346366be72e2b4719efcristy &crop_info,exception); 55036710d8414f0ed06e4eaf9346366be72e2b4719efcristy crop_image=CropImage(window->image,&crop_info,exception); 55043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (crop_image != (Image *) NULL) 55053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != image) 55073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=DestroyImage(window->image); 55083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=crop_image; 55093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->destroy=MagickTrue; 55103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((width != (unsigned int) window->image->columns) || 55133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (height != (unsigned int) window->image->rows)) 55143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 55163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *resize_image; 55173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 55183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 55193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Resize image. 55203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 55213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resize_image=NewImageList(); 55223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixel_info->colors != 0) 55236710d8414f0ed06e4eaf9346366be72e2b4719efcristy resize_image=SampleImage(window->image,width,height,exception); 55243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 55256710d8414f0ed06e4eaf9346366be72e2b4719efcristy resize_image=ThumbnailImage(window->image,width,height,exception); 55263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resize_image != (Image *) NULL) 55273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != image) 55293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=DestroyImage(window->image); 55303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->image=resize_image; 55313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->destroy=MagickTrue; 55323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) window->image->columns; 5535bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy assert((size_t) width == window->image->columns); 55363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) window->image->rows; 5537bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy assert((size_t) height == window->image->rows); 55383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 55403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create X image. 55413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 55423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 55433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format=(depth == 1) ? XYBitmap : ZPixmap; 55443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 55453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 55483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 55493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 55503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 55513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 55523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 55533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XShmCreateImage(display,window->visual,(unsigned int) depth,format, 55543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,&segment_info[1],width,height); 55553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 55563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 55573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=(size_t) ximage->bytes_per_line*ximage->height; 55583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (CheckOverflowException(length,ximage->bytes_per_line,ximage->height)) 55593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 55603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=shmget(IPC_PRIVATE,length,IPC_CREAT | 0777); 55623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) shmat(segment_info[1].shmid,0,0); 55643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmid < 0) 55653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 55663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory != MagickFalse) 55673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[1].shmid,IPC_RMID,0); 55683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 55693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage != (XImage *) NULL) 55713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 55723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 55733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmaddr) 55743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[1].shmaddr); 55763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 55773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmid >= 0) 55793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[1].shmid,IPC_RMID,0); 55813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 55823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 55853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 55863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 55873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate X image pixel data. 55883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 55893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 55903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory) 55913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 55923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 55933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 55943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 55953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 55963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 55973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 55983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 55993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xerror_alert=MagickFalse; 56003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 56013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->data=segment_info[1].shmaddr; 56023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].readOnly=MagickFalse; 56033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XShmAttach(display,&segment_info[1]); 56043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 56053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 56063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == False) || (xerror_alert != MagickFalse)) 56073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->shared_memory=MagickFalse; 56093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 56103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmDetach(display,&segment_info[1]); 56113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage != (XImage *) NULL) 56123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->data=NULL; 56143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 56153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 56163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmid >= 0) 56183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[1].shmaddr != NULL) 56203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[1].shmaddr); 56213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[1].shmid,IPC_RMID,0); 56223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmid=(-1); 56233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[1].shmaddr=(char *) NULL; 56243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 56283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 56293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=XCreateImage(display,window->visual,(unsigned int) depth,format,0, 56303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,width,height,XBitmapPad(display),0); 56313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage == (XImage *) NULL) 56323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 56343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Unable to create X image. 56353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 56363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 56373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 56383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=(size_t) ximage->bytes_per_line*ximage->height; 56403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 56413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"XImage:"); 56433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," width, height: %dx%d", 56443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->width,ximage->height); 56453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," format: %d", 56463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->format); 56473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," byte order: %d", 56483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->byte_order); 56493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 56503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " bitmap unit, bit order, pad: %d %d %d",ximage->bitmap_unit, 56513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bitmap_bit_order,ximage->bitmap_pad); 56523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," depth: %d", 56533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->depth); 56543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," bytes per line: %d", 56553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bytes_per_line); 56563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," bits per pixel: %d", 56573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bits_per_pixel); 56583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 56593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue masks: 0x%lx 0x%lx 0x%lx",ximage->red_mask, 56603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->green_mask,ximage->blue_mask); 56613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 56633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format != XYBitmap) 56653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->data=(char *) AcquireQuantumMemory((size_t) 56663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bytes_per_line,(size_t) ximage->height); 56673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 56683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->data=(char *) AcquireQuantumMemory((size_t) 56693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bytes_per_line*ximage->depth,(size_t) ximage->height); 56703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->data == (char *) NULL) 56723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 56743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Unable to allocate pixel data. 56753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 56763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(ximage); 56773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=(XImage *) NULL; 56783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 56793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 56803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 56813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage != (XImage *) NULL) 56823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 56843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Destroy previous X image. 56853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 56863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy length=(size_t) window->ximage->bytes_per_line*window->ximage->height; 56873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 56883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->segment_info != (XShmSegmentInfo *) NULL) 56893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 56913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 56923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 56933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 56943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[0].shmid >= 0) 56953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 56963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 56973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XShmDetach(display,&segment_info[0]); 56983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 56993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (segment_info[0].shmaddr != (char *) NULL) 57003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmdt(segment_info[0].shmaddr); 57013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) shmctl(segment_info[0].shmid,IPC_RMID,0); 57023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmid=(-1); 57033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0].shmaddr=(char *) NULL; 57043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage->data=(char *) NULL; 57053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 57083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage->data != (char *) NULL) 57093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy free(window->ximage->data); 57103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage->data=(char *) NULL; 57113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(window->ximage); 57123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage=(XImage *) NULL; 57133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 57153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->segment_info != (XShmSegmentInfo *) NULL) 57163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShmSegmentInfo 57183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *segment_info; 57193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 57203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info=(XShmSegmentInfo *) window->segment_info; 57213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy segment_info[0]=segment_info[1]; 57223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 57243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage=ximage; 57253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image=(XImage *) NULL; 57263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->shape != MagickFalse) && (window->image != (Image *) NULL)) 57273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->image->matte != MagickFalse) && 5728c57f694b2d04975a0e501613e34368c464708c19cristy ((int) width <= XDisplayWidth(display,window->screen)) && 5729c57f694b2d04975a0e501613e34368c464708c19cristy ((int) height <= XDisplayHeight(display,window->screen))) 57303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create matte image. 57333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image=XCreateImage(display,window->visual,1,XYBitmap,0, 57353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,width,height,XBitmapPad(display),0); 57363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 57373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Matte Image:"); 57393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 57403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " width, height: %dx%d",matte_image->width,matte_image->height); 57413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image != (XImage *) NULL) 57433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate matte image pixel data. 57463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image->data=(char *) AcquireQuantumMemory((size_t) 57483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image->bytes_per_line*matte_image->depth, 57493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (size_t) matte_image->height); 57503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image->data == (char *) NULL) 57513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(matte_image); 57533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy matte_image=(XImage *) NULL; 57543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_image != (XImage *) NULL) 57583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free matte image. 57613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_image->data != (char *) NULL) 57633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy free(window->matte_image->data); 57643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image->data=(char *) NULL; 57653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDestroyImage(window->matte_image); 57663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image=(XImage *) NULL; 57673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image=matte_image; 57693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 57703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->matte_pixmap); 57723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap=(Pixmap) NULL; 57733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 57743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shape != MagickFalse) 57753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShapeCombineMask(display,window->id,ShapeBounding,0,0,None,ShapeSet); 57763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 57773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->stasis=MagickFalse; 57793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert pixels to X image data. 57813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->image != (Image *) NULL) 57833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->byte_order == LSBFirst) || ((ximage->format == XYBitmap) && 57853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ximage->bitmap_bit_order == LSBFirst))) 57863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeImageLSBFirst(resource_info,window,window->image,ximage, 5787e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy matte_image,exception); 57883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 57893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XMakeImageMSBFirst(resource_info,window,window->image,ximage, 5790e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy matte_image,exception); 57913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 57923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_image != (XImage *) NULL) 57933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 57943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 57953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create matte pixmap. 57963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 57973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap=XCreatePixmap(display,window->id,width,height,1); 57983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 57993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 58003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 58013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy graphics_context; 58023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 58043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 58053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 58073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Copy matte image to matte pixmap. 58083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 58094c08aed51c5899665ade97263692328eea4af106cristy context_values.background=0; 58104c08aed51c5899665ade97263692328eea4af106cristy context_values.foreground=1; 58113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy graphics_context=XCreateGC(display,window->matte_pixmap, 5812bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy (size_t) (GCBackground | GCForeground),&context_values); 58133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,window->matte_pixmap,graphics_context, 58143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_image,0,0,0,0,width,height); 58153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,graphics_context); 58163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 58173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shape != MagickFalse) 58183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XShapeCombineMask(display,window->id,ShapeBounding,0,0, 58193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->matte_pixmap,ShapeSet); 58203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 58213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 58223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 58233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XMakePixmap(display,resource_info,window); 58243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 58253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restore cursor. 58263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 58273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 58283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 58293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 58303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 58323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 58333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X M a k e I m a g e L S B F i r s t % 58373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 58403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 58413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeImageLSBFirst() initializes the pixel data of an X11 Image. The X image 58433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% pixels are copied in least-significant bit and byte first order. The 58443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% server's scanline pad is respected. Rather than using one or two general 58453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% cases, many special cases are found here to help speed up the image 58463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% conversion. 58473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeImageLSBFirst method is: 58493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5850e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% void XMakeImageLSBFirst(Display *display,XWindows *windows, 5851e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% ExceptionInfo *exception) 58523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 58543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 58563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 58583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 58603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage: Specifies a pointer to a XImage structure; returned from 58623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 58633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 58643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o matte_image: Specifies a pointer to a XImage structure; returned from 58653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 58663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 5867e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% o exception: return any errors or warnings in this structure. 5868e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% 58693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 58703ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void XMakeImageLSBFirst(const XResourceInfo *resource_info, 5871e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy const XWindowInfo *window,Image *image,XImage *ximage,XImage *matte_image, 5872e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy ExceptionInfo *exception) 58733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 5874c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 5875c57f694b2d04975a0e501613e34368c464708c19cristy *canvas_view; 5876c57f694b2d04975a0e501613e34368c464708c19cristy 58773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 58783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *canvas; 58793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 58813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 58823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58834c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 58843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 58853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 58873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 58883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 58903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 58913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 58933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit, 58943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte; 58953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 58963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 58973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad; 58983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 5899f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 59003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel, 59013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pixels; 59023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap 59043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info; 59053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 59073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 59083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 59093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 59103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 59113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=image; 5912bab87c3357f708174fd2d8ab87a0d7dbb3f70e31cristy if ((window->immutable == MagickFalse) && 591354666e85e8e3b0eca47d318178a186ebb2901a73cristy (image->storage_class == DirectClass) && (image->matte != MagickFalse)) 59143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 59163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size[MaxTextExtent]; 59173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 59193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pattern; 59203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 59223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image_info; 59233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=AcquireImageInfo(); 59253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image_info->filename, 59263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture != (char *) NULL ? 59273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture : "pattern:checkerboard", 59283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MaxTextExtent); 5929b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",(double) 5930e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy image->columns,(double) image->rows); 59313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->size=ConstantString(size); 59326710d8414f0ed06e4eaf9346366be72e2b4719efcristy pattern=ReadImage(image_info,exception); 59333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=DestroyImageInfo(image_info); 59343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pattern != (Image *) NULL) 59353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59366710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas=CloneImage(image,0,0,MagickTrue,exception); 59373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != (Image *) NULL) 5938e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) CompositeImage(canvas,DstOverCompositeOp,pattern,0,0, 5939e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy exception); 59403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pattern=DestroyImage(pattern); 59413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 59423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 59433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (ximage->bytes_per_line-((ximage->width* 59443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage->bits_per_pixel) >> 3)); 59453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info=window->map_info; 59463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixels=window->pixel_info->pixels; 59473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) ximage->data; 59483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 5949c57f694b2d04975a0e501613e34368c464708c19cristy canvas_view=AcquireCacheView(canvas); 59503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 59513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned short 59533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy polarity; 59543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 59563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 59573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground; 59583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 59593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 59603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert canvas to big-endian bitmap. 59613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 59623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 59633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->foreground_color) < 59643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->background_color) ? 0x80 : 0x00); 59653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 59663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->background_color) < 59673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->foreground_color) ? 0x80 : 0x00); 5968101ab708b0574518ac5715da4d3915400e9df79acristy polarity=(unsigned short) ((GetPixelInfoIntensity( 59693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &canvas->colormap[0])) < ((Quantum) QuantumRange/2) ? 1 : 0); 59703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas->colors == 2) 5971101ab708b0574518ac5715da4d3915400e9df79acristy polarity=GetPixelInfoIntensity(&canvas->colormap[0]) < 5972101ab708b0574518ac5715da4d3915400e9df79acristy GetPixelInfoIntensity(&canvas->colormap[1]); 59733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 59743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 5975c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 59766710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 59774c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 59783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 59793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 59803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 59813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 59823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte>>=1; 59844c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelIndex(canvas,p) == (Quantum) polarity) 59853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 59863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 59873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 59883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 59893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 59903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 59913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 59923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 59933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 59943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 5995ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 59963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 59973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 59983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte >> (8-bit); 59993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 60003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 60033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixel_info->colors != 0) 60043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 60053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 60073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 60093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 60103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 60113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 60123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 2 bit color-mapped X canvas. 60133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 60143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 60153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6016c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 60176710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 60184c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 60193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 60223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60234c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)] & 0x0f; 60243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 60253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 60273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 60293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 60333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 60353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 60393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 60413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 60453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 6); 60473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 60483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6052ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 60533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 60553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 60593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 60613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 60623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 60633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 60643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit color-mapped X canvas. 60653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 60663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 60673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6068c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 60696710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 60704c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 60713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 60743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60754c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)] & 0xf; 60763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 60773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 60793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 60813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 60823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 60853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 60863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 60873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 60883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 60893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6092ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 60933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 60953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 60973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 60983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 60993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 61003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 61023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit color-mapped X canvas. 61033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 61043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 61053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info->dither) 61063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61076710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 61083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 61113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6112c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 61136710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 61144c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 61153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 61173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61184c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)]; 61193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6120ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 61213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 61233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 61273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 61293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 61303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 61323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 61333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 6135bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy channel[sizeof(size_t)]; 61363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 61383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to multi-byte color-mapped X canvas. 61393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 61403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 61413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 61423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6143c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 61446710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 61454c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 61463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 61483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61494c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)]; 61503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 61513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy channel[k]=(unsigned char) pixel; 61533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 61543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 61563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=channel[k]; 6157ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 61583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 61603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 61653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 61663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 61683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 61703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 61713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 61723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 61733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to contiguous 2 bit continuous-tone X canvas. 61743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 61753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 61763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 6178c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 61796710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 61804c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 61813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 61833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61844c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 61853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 61863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 61873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 61893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 61913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 61923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 61943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 61953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 61963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 61973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 61983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 61993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 62013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 62033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 62043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 62073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 6); 62093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 62103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 62113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6214ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 62153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 62173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 62213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 62233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 62243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 62253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 62263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to contiguous 4 bit continuous-tone X canvas. 62273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 62283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 62293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6230c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 62316710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 62324c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 62333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 62353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 62363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62374c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 62383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 62393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 62403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 62423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) pixel; 62443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 62453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 62483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 62503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 62513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 62523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6255ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 62563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 62583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 62623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 62633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 62653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to contiguous 8 bit continuous-tone X canvas. 62663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 62673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 62683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info->dither) 62693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62706710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 62713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 62743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6275c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 62766710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 62774c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 62783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 62803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62814c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 62823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6283ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 62843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 62863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 62883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 62893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 62903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 62923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 62933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 65536L) && (map_info->green_mult == 256) && 62943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 1)) 62953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 62963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 62973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 62983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 62993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 63003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6301c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 63026710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 63034c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 63043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 63053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 63063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 63073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 63103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6313ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 63144c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 6315ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 63164c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6317ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 63184c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 63193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6320ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 63233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63264c08aed51c5899665ade97263692328eea4af106cristy *q++=ScaleQuantumToChar((Quantum) 63274c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p)); 63284c08aed51c5899665ade97263692328eea4af106cristy *q++=ScaleQuantumToChar((Quantum) 63294c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p)); 63304c08aed51c5899665ade97263692328eea4af106cristy *q++=ScaleQuantumToChar((Quantum) 63314c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p)); 63323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6333ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 63383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 63393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 63403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 1) && (map_info->green_mult == 256) && 63413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 65536L)) 63423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 63453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 63473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6348c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 63496710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 63504c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 63513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 63523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 63533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 63543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 63573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6360ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 63614c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 6362ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 63634c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6364ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 63654c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 63663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6367ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 63703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 63723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6373ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar((Quantum) 63744c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p)); 6375ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar((Quantum) 63764c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p)); 6377ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar((Quantum) 63784c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p)); 63793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6380ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 63813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 63843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 63853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 63863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 63873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 63883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 63893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 63903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 63913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 63923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 6393bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy channel[sizeof(size_t)]; 63943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 63953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 63963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to multi-byte continuous-tone X canvas. 63973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 63983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 63993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 64003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6401c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 64026710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 64034c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 64043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 6405c57f694b2d04975a0e501613e34368c464708c19cristy for (x=0; x < (int) canvas->columns; x++) 64063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64074c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 64083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 64093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy channel[k]=(unsigned char) pixel; 64113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 64123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 64143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=channel[k]; 6415ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 64163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 64183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 64213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image != (XImage *) NULL) 64243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 64263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize matte canvas. 64273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 64283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (matte_image->bytes_per_line- 64293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((matte_image->width*matte_image->bits_per_pixel) >> 3)); 64303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) matte_image->data; 64313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 64323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6433c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 64346710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 64354c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 64363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 64373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 64383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 64393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 64403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte>>=1; 64424c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelAlpha(canvas,p) > (QuantumRange/2)) 64433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=0x80; 64443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 64453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 64463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 64473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 64483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 64493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 64503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6451ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 64523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 64543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte >> (8-bit); 64553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 64563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 64573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6458c57f694b2d04975a0e501613e34368c464708c19cristy canvas_view=DestroyCacheView(canvas_view); 64593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != image) 64603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=DestroyImage(canvas); 64613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 64623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 64633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 64643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 64653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy+ X M a k e I m a g e M S B F i r s t % 64693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 64723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 64733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeImageMSBFirst() initializes the pixel data of an X11 Image. The X 64753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% image pixels are copied in most-significant bit and byte first order. The 64763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% server's scanline pad is also respected. Rather than using one or two 64773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% general cases, many special cases are found here to help speed up the image 64783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% conversion. 64793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeImageMSBFirst method is: 64813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6482e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% XMakeImageMSBFirst(resource_info,window,image,ximage,matte_image, 6483e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% ExceptionInfo *exception) 64843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 64863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 64883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 64903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 64923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage: Specifies a pointer to a XImage structure; returned from 64943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 64953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 64963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o matte_image: Specifies a pointer to a XImage structure; returned from 64973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XCreateImage. 64983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 6499e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% o exception: return any errors or warnings in this structure. 6500e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy% 65013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 65023ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic void XMakeImageMSBFirst(const XResourceInfo *resource_info, 6503e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy const XWindowInfo *window,Image *image,XImage *ximage,XImage *matte_image, 6504e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy ExceptionInfo *exception) 65053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 6506c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 6507c57f694b2d04975a0e501613e34368c464708c19cristy *canvas_view; 6508c57f694b2d04975a0e501613e34368c464708c19cristy 65093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 65103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *canvas; 65113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 65133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 65143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 65163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 65173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65184c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 65193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 65203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 65223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 65233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 65253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit, 65263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte; 65273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 65293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad; 65303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 6531f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 65323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel, 65333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pixels; 65343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XStandardColormap 65363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *map_info; 65373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 65393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 65403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image != (Image *) NULL); 65413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image->debug != MagickFalse) 65423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); 65433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=image; 654454666e85e8e3b0eca47d318178a186ebb2901a73cristy if ((window->immutable != MagickFalse) && 654554666e85e8e3b0eca47d318178a186ebb2901a73cristy (image->storage_class == DirectClass) && (image->matte != MagickFalse)) 65463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 65473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 65483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size[MaxTextExtent]; 65493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 65513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pattern; 65523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ImageInfo 65543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *image_info; 65553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=AcquireImageInfo(); 65573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(image_info->filename, 65583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture != (char *) NULL ? 65593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->image_info->texture : "pattern:checkerboard", 65603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MaxTextExtent); 6561b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",(double) 6562e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy image->columns,(double) image->rows); 65633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->size=ConstantString(size); 65646710d8414f0ed06e4eaf9346366be72e2b4719efcristy pattern=ReadImage(image_info,exception); 65653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info=DestroyImageInfo(image_info); 65663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pattern != (Image *) NULL) 65673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 65686710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas=CloneImage(image,0,0,MagickTrue,exception); 65693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != (Image *) NULL) 6570e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy (void) CompositeImage(canvas,DstOverCompositeOp,pattern,0,0, 6571e941a75fe8bf344bc5c06a7f74bb5173c87db115cristy exception); 65723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pattern=DestroyImage(pattern); 65733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 65743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 65754c08aed51c5899665ade97263692328eea4af106cristy scanline_pad=(unsigned int) (ximage->bytes_per_line-((ximage->width* 65764c08aed51c5899665ade97263692328eea4af106cristy ximage->bits_per_pixel) >> 3)); 65773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info=window->map_info; 65783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixels=window->pixel_info->pixels; 65793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) ximage->data; 65803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 6581c57f694b2d04975a0e501613e34368c464708c19cristy canvas_view=AcquireCacheView(canvas); 65823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 65833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 65843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned short 65853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy polarity; 65863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 65883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 65893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground; 65903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 65913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 65923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert canvas to big-endian bitmap. 65933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 65943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 65953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->foreground_color) < 65963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->background_color) ? 0x01 : 0x00); 65973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 65983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&window->pixel_info->background_color) < 65993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&window->pixel_info->foreground_color) ? 0x01 : 0x00); 6600101ab708b0574518ac5715da4d3915400e9df79acristy polarity=(unsigned short) ((GetPixelInfoIntensity( 66013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &canvas->colormap[0])) < ((Quantum) QuantumRange/2) ? 1 : 0); 66023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas->colors == 2) 6603101ab708b0574518ac5715da4d3915400e9df79acristy polarity=GetPixelInfoIntensity(&canvas->colormap[0]) < 6604101ab708b0574518ac5715da4d3915400e9df79acristy GetPixelInfoIntensity(&canvas->colormap[1]); 66053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 66063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6607c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 66086710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 66094c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 66103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 66123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 66133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 66143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte<<=1; 66164c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelIndex(canvas,p) == (Quantum) polarity) 66173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 66183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 66193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 66203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 66213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 66223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 66243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 66253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 66263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6627ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 66283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 66303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte << (8-bit); 66313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 66323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 66353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixel_info->colors != 0) 66363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 66373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 66393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 66413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 66423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 66433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 66443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 2 bit color-mapped X canvas. 66453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 66463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 66473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6648c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 66496710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 66504c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 66513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 66533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 66543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66554c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) 66564c08aed51c5899665ade97263692328eea4af106cristy GetPixelIndex(canvas,p)] & 0xf; 66573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 66583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 66603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 6); 66623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 66633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 66663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 66683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 66693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 66723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 66743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 66753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 66783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 66803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 66813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 66823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6685ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 66863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 66883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 66903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 66913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 66923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 66933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 66943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 66953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 66963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 66973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit color-mapped X canvas. 66983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 66993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 67003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6701c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 67026710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 67034c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 67043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 67063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 67073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67084c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) 67094c08aed51c5899665ade97263692328eea4af106cristy GetPixelIndex(canvas,p)] & 0xf; 67103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 67113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 67133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 4); 67153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 67163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 67193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 67213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 67223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 67233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6726ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 67273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 67293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 67333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 67343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 67363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit color-mapped X canvas. 67373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 67383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 67393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info->dither) 67403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67416710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 67423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 67453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6746c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 67476710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 67484c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 67493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 67513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67526710d8414f0ed06e4eaf9346366be72e2b4719efcristy pixel=pixels[(ssize_t) GetPixelIndex(canvas,p)]; 67533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6754ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 67553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 67573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 67613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 67633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 67643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 67663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 67673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 6769bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy channel[sizeof(size_t)]; 67703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 67713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 67723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit color-mapped X canvas. 67733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 67743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 67753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 67763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6777c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 67786710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 67794c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 67803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=0; x < (int) canvas->columns; x++) 67823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67834c08aed51c5899665ade97263692328eea4af106cristy pixel=pixels[(ssize_t) 67844c08aed51c5899665ade97263692328eea4af106cristy GetPixelIndex(canvas,p)]; 67853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=(int) bytes_per_pixel-1; k >= 0; k--) 67863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 67873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy channel[k]=(unsigned char) pixel; 67883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 67893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 67913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=channel[k]; 6792ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 67933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 67953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 67973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 67993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 68003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 68013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 68033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 68053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 68063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 68073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 68083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit continuous-tone X canvas. 68093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 68103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 68113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6812c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 68136710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 68144c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 68153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 68183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68194c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 68203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 68213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 68223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 68243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 6); 68263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 68303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 4); 68323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 2: 68363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) (pixel << 2); 68383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 3: 68423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 68443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 68453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6849ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 68503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 68523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 4: 68563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 68583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble; 68593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 68603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 68613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 4 bit continuous-tone X canvas. 68623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 68633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 68643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6865c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 68666710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 68674c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 68683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 68713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68724c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 68733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel&=0xf; 68743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (nibble) 68753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 0: 68773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=(unsigned char) (pixel << 4); 68793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble++; 68803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 1: 68833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q|=(unsigned char) pixel; 68853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q++; 68863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy nibble=0; 68873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 6890ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 68913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 68933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 68953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 68963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 68973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 68983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 68993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 8 bit continuous-tone X canvas. 69013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->color_recovery && 69033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info->dither) 69043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69056710d8414f0ed06e4eaf9346366be72e2b4719efcristy XDitherImage(canvas,ximage,exception); 69063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 69093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6910c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 69116710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 69124c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 69133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69164c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 69173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(unsigned char) pixel; 6918ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 69213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 69253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 69273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 69283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 65536L) && (map_info->green_mult == 256) && 69293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 1)) 69303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 69333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 69353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6936c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 69376710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 69384c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 69393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 69413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 69423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 69453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6949ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 69504c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 6951ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 69524c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 6953ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 69544c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 6955ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 69583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 69624c08aed51c5899665ade97263692328eea4af106cristy *q++=ScaleQuantumToChar((Quantum) 69634c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p)); 69644c08aed51c5899665ade97263692328eea4af106cristy *q++=ScaleQuantumToChar((Quantum) 69654c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p)); 69664c08aed51c5899665ade97263692328eea4af106cristy *q++=ScaleQuantumToChar((Quantum) 69674c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p)); 6968ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 69693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 69723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 69733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((ximage->bits_per_pixel == 32) && (map_info->red_max == 255) && 69743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max == 255) && (map_info->blue_max == 255) && 69753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_mult == 1) && (map_info->green_mult == 256) && 69763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_mult == 65536L)) 69773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to 32 bit continuous-tone X canvas. 69803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 69823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 6983c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 69846710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 69854c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 69863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 69873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((red_gamma != 1.0) || (green_gamma != 1.0) || 69883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (blue_gamma != 1.0)) 69893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 69913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Gamma correct canvas. 69923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 69933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 69943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 69953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 6996ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XBlueGamma( 69974c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p))); 6998ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XGreenGamma( 69994c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p))); 7000ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar(XRedGamma( 70014c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p))); 7002ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 70033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy continue; 70053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 70073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=0; 7009ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar((Quantum) 70104c08aed51c5899665ade97263692328eea4af106cristy GetPixelBlue(canvas,p)); 7011ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar((Quantum) 70124c08aed51c5899665ade97263692328eea4af106cristy GetPixelGreen(canvas,p)); 7013ccf844f01bcfb63e8c6260bc986878089bb4c85bcristy *q++=ScaleQuantumToChar((Quantum) 70144c08aed51c5899665ade97263692328eea4af106cristy GetPixelRed(canvas,p)); 7015ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 70163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 70203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 70223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k; 70233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 70253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel; 70263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 7028bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy channel[sizeof(size_t)]; 70293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 70313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Convert to multi-byte continuous-tone X canvas. 70323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 70333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) (ximage->bits_per_pixel >> 3); 70343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 70353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7036c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y, 70376710d8414f0ed06e4eaf9346366be72e2b4719efcristy canvas->columns,1,exception); 70384c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 70393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 70403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 70413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70424c08aed51c5899665ade97263692328eea4af106cristy pixel=XGammaPixel(canvas,map_info,p); 70433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=(int) bytes_per_pixel-1; k >= 0; k--) 70443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy channel[k]=(unsigned char) pixel; 70463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel>>=8; 70473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < (int) bytes_per_pixel; k++) 70493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=channel[k]; 7050ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 70513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 70533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 70563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (matte_image != (XImage *) NULL) 70593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 70613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize matte canvas. 70623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 70633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (matte_image->bytes_per_line- 70643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((matte_image->width*matte_image->bits_per_pixel) >> 3)); 70653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) matte_image->data; 70663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) canvas->rows; y++) 70673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7068c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewVirtualPixels(canvas_view,0,(ssize_t) y,canvas->columns,1, 70696710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 70704c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 70713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 70723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 70733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 70743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=(int) canvas->columns-1; x >= 0; x--) 70753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte<<=1; 70774c08aed51c5899665ade97263692328eea4af106cristy if (GetPixelAlpha(canvas,p) > (QuantumRange/2)) 70783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=0x01; 70793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit++; 70803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit == 8) 70813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 70823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 70833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bit=0; 70843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 70853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7086ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(canvas); 70873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (bit != 0) 70893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte << (8-bit); 70903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 70913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 70923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7093c57f694b2d04975a0e501613e34368c464708c19cristy canvas_view=DestroyCacheView(canvas_view); 70943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (canvas != image) 70953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy canvas=DestroyImage(canvas); 70963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 70973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 70983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 70993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 71003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 71013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 71023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 71033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e M a g n i f y I m a g e % 71043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 71053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 71063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 71073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 71083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeMagnifyImage() magnifies a region of an X image and displays it. 71103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeMagnifyImage method is: 71123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71136710d8414f0ed06e4eaf9346366be72e2b4719efcristy% void XMakeMagnifyImage(Display *display,XWindows *windows, 71146710d8414f0ed06e4eaf9346366be72e2b4719efcristy% ExceptionInfo *exception) 71153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 71173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 71193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 71203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 71223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 71236710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 71246710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 71253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 71266710d8414f0ed06e4eaf9346366be72e2b4719efcristyMagickPrivate void XMakeMagnifyImage(Display *display,XWindows *windows, 71276710d8414f0ed06e4eaf9346366be72e2b4719efcristy ExceptionInfo *exception) 71283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 71293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 71303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy tuple[MaxTextExtent]; 71313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 71333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 71343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71354c08aed51c5899665ade97263692328eea4af106cristy PixelInfo 71363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel; 71373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 71393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 71403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7141bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 71423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 71433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 71453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p, 71463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q; 71473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71489d314ff2c17a77996c05413c2013880387e50f0ecristy ssize_t 71499d314ff2c17a77996c05413c2013880387e50f0ecristy n; 71509d314ff2c17a77996c05413c2013880387e50f0ecristy 71513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static unsigned int 71523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy previous_magnify = 0; 71533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XWindowInfo 71553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window; 71563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 71583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 71593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy j, 71603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy k, 71613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy l, 71623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify, 71633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad, 71643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 71653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XImage 71673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *ximage; 71683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 71703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Check boundary conditions. 71713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 71723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 71733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 71743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 71753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify=1; 7176bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (n=1; n < (ssize_t) windows->magnify.data; n++) 71773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify<<=1; 71783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((magnify*windows->image.ximage->width) < windows->magnify.width) 71793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify<<=1; 71803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((magnify*windows->image.ximage->height) < windows->magnify.height) 71813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify<<=1; 71823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (magnify > windows->magnify.width) 71833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify>>=1; 71843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (magnify > windows->magnify.height) 71853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify>>=1; 71863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magnify != previous_magnify) 71873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 71883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 71893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 71903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextProperty 71923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 71933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 71943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 71953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy New magnify factor: update magnify window name. 71963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 71973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i=0; 71983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while ((1 << i) <= (int) magnify) 71993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i++; 7200b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(windows->magnify.name,MaxTextExtent, 7201e8c25f9b4c9fb72cad6db08eeda58c7c5784014ecristy "Magnify %.20gX",(double) i); 72023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XStringListToTextProperty(&windows->magnify.name,1,&window_name); 72033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 72043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetWMName(display,windows->magnify.id,&window_name); 72063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetWMIconName(display,windows->magnify.id,&window_name); 72073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) window_name.value); 72083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 72093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 72103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy previous_magnify=magnify; 72113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage=windows->image.ximage; 72123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) windows->magnify.ximage->width; 72133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) windows->magnify.ximage->height; 72143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->magnify.x < 0) || 72153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->magnify.x >= windows->image.ximage->width)) 72163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.x=windows->image.ximage->width >> 1; 72173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=windows->magnify.x-((width/magnify) >> 1); 72183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 0) 72193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 72203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 72213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x > (int) (ximage->width-(width/magnify))) 72223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=ximage->width-width/magnify; 72233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((windows->magnify.y < 0) || 72243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (windows->magnify.y >= windows->image.ximage->height)) 72253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.y=windows->image.ximage->height >> 1; 72263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=windows->magnify.y-((height/magnify) >> 1); 72273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y < 0) 72283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 72293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 72303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y > (int) (ximage->height-(height/magnify))) 72313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=ximage->height-height/magnify; 72323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=(unsigned char *) windows->magnify.ximage->data; 72333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy scanline_pad=(unsigned int) (windows->magnify.ximage->bytes_per_line- 72343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((width*windows->magnify.ximage->bits_per_pixel) >> 3)); 72353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->bits_per_pixel < 8) 72363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned char 72383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background, 72393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte, 72403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground, 72413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit, 72423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit; 72433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 72443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 72453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy plane; 72463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 72473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelInfo 72483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *pixel_info; 72493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 72503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel_info=windows->magnify.pixel_info; 72513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bitmap_bit_order) 72523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case LSBFirst: 72543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify little-endian bitmap. 72573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=0x00; 72593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=0x80; 72603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 72613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 72633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->foreground_color) < 72643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->background_color) ? 0x80 : 0x00); 72653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 72663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->background_color) < 72673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->foreground_color) ? 0x80 : 0x00); 72683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->magnify.depth > 1) 72693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Swap(background,foreground); 72703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7271bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 72723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 72753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 72773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 72793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 72803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=(unsigned char) (x*ximage->bits_per_pixel) & 0x07; 72813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 72823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 72833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 72843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 72873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 72893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 72913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate each bit plane. 72923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 72933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (plane=0; (int) plane < ximage->bits_per_pixel; plane++) 72943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 72953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte>>=1; 72963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*p & (0x01 << (p_bit+plane))) 72973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 72983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 72993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 73003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit++; 73013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit == 8) 73023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 73043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 73053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 73063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit+=ximage->bits_per_pixel; 73103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p_bit == 8) 73113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 73133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=0; 73143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit != 0) 73163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte >> (8-q_bit); 73173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 73183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 73213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 73233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case MSBFirst: 73253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 73263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify big-endian bitmap. 73293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=0x00; 73313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=0x01; 73323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (ximage->format == XYBitmap) 73333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy background=(unsigned char) 73353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->foreground_color) < 73363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->background_color) ? 0x01 : 0x00); 73373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy foreground=(unsigned char) 73383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (XPixelIntensity(&pixel_info->background_color) < 73393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XPixelIntensity(&pixel_info->foreground_color) ? 0x01 : 0x00); 73403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->magnify.depth > 1) 73413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Swap(background,foreground); 73423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 7343bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 73443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 73473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 73493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 73513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 73523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=(unsigned char) (x*ximage->bits_per_pixel) & 0x07; 73533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 73543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 73553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 73563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 73593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 73613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 73633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate each bit plane. 73643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 73653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (plane=0; (int) plane < ximage->bits_per_pixel; plane++) 73663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte<<=1; 73683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (*p & (0x80 >> (p_bit+plane))) 73693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=foreground; 73703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 73713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte|=background; 73723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit++; 73733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit == 8) 73743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=byte; 73763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q_bit=0; 73773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy byte=0; 73783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit+=ximage->bits_per_pixel; 73823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p_bit == 8) 73833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 73843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 73853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p_bit=0; 73863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (q_bit != 0) 73883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q=byte << (8-q_bit); 73893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 73903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 73933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 73953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 73983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 73993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (ximage->bits_per_pixel) 74003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 6: 74023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case 8: 74033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify 8 bit X image. 74063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7407bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 74083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 74113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 74133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 74153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 74163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 74173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 74203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 74223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(*p); 74233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 74243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 74263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 74283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 74303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 74323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register unsigned int 74343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel, 74353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy m; 74363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 74373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Magnify multi-byte X image. 74393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy bytes_per_pixel=(unsigned int) ximage->bits_per_pixel >> 3; 7441bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) height; i+=magnify) 74423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify rows. 74453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (j=0; j < magnify; j++) 74473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=(unsigned char *) ximage->data+y*ximage->bytes_per_line+ 74493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((x*ximage->bits_per_pixel) >> 3); 74503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (k=0; k < width; k+=magnify) 74513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Propogate pixel magnify columns. 74543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (l=0; l < magnify; l++) 74563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (m=0; m < bytes_per_pixel; m++) 74573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *q++=(*(p+m)); 74583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p+=bytes_per_pixel; 74593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q+=scanline_pad; 74613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y++; 74633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 74653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 74673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Copy X image to magnify pixmap. 74693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 74703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=windows->magnify.x-((width/magnify) >> 1); 74713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x < 0) 74723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=(int) ((width >> 1)-windows->magnify.x*magnify); 74733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (x > (int) (ximage->width-(width/magnify))) 74753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=(int) ((ximage->width-windows->magnify.x)*magnify-(width >> 1)); 74763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 74783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=windows->magnify.y-((height/magnify) >> 1); 74793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y < 0) 74803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=(int) ((height >> 1)-windows->magnify.y*magnify); 74813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (y > (int) (ximage->height-(height/magnify))) 74833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=(int) ((ximage->height-windows->magnify.y)*magnify-(height >> 1)); 74843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 74853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 74863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((x != 0) || (y != 0)) 74873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFillRectangle(display,windows->magnify.pixmap, 74883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,0,0,width,height); 74893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,windows->magnify.pixmap, 74903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,windows->magnify.ximage,0,0,x,y,width-x, 74913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height-y); 74923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((magnify > 1) && ((magnify <= (width >> 1)) && 74933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (magnify <= (height >> 1)))) 74943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 74953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 74963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info; 74973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 74983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 74993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Highlight center pixel. 75003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 7501bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy highlight_info.x=(ssize_t) windows->magnify.width >> 1; 7502bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy highlight_info.y=(ssize_t) windows->magnify.height >> 1; 75033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info.width=magnify; 75043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy highlight_info.height=magnify; 75053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,windows->magnify.pixmap, 75063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.highlight_context,(int) highlight_info.x, 75073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info.y,(unsigned int) highlight_info.width-1, 75083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info.height-1); 75093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (magnify > 2) 75103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,windows->magnify.pixmap, 75113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,(int) highlight_info.x+1, 75123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) highlight_info.y+1,(unsigned int) highlight_info.width-3, 75133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) highlight_info.height-3); 75143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 75153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 75163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Show center pixel color. 75173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 75183aa9375ebfc21a5356d6b1754bcd1b162ad666c4cristy (void) GetOneVirtualPixelInfo(windows->image.image,TileVirtualPixelMethod, 75195201002e1ba0118594060d26142b48bdfb1320a2cristy (ssize_t) windows->magnify.x,(ssize_t) windows->magnify.y,&pixel,exception); 7520b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(tuple,MaxTextExtent,"%d,%d: ", 75213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.x,windows->magnify.y); 75223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,"(",MaxTextExtent); 7523ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,tuple); 75243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7525ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,tuple); 75263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7527ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,tuple); 75283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel.colorspace == CMYKColorspace) 75293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 75303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7531ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,BlackPixelChannel,X11Compliance,tuple); 75323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 75333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel.matte != MagickFalse) 75343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 75353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 7536ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy ConcatenateColorComponent(&pixel,AlphaPixelChannel,X11Compliance,tuple); 75373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 75383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(tuple,")",MaxTextExtent); 75393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) windows->magnify.font_info->ascent+ 75403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.font_info->descent; 75413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=windows->magnify.font_info->max_bounds.width >> 1; 75423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=windows->magnify.font_info->ascent+(height >> 2); 75433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,windows->magnify.pixmap, 75443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple)); 75453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GetColorTuple(&pixel,MagickTrue,tuple); 75463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y+=height; 75473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,windows->magnify.pixmap, 75483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple)); 7549269c9413034627692b2a7d0a352f9dee4e8eada8cristy (void) QueryColorname(windows->image.image,&pixel,SVGCompliance,tuple, 75506710d8414f0ed06e4eaf9346366be72e2b4719efcristy exception); 75513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y+=height; 75523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawImageString(display,windows->magnify.pixmap, 75533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.annotate_context,x,y,tuple,(int) strlen(tuple)); 75543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 75553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Refresh magnify window. 75563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 75573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window=windows->magnify; 75583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window.x=0; 75593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy magnify_window.y=0; 75603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRefreshWindow(display,&magnify_window,(XEvent *) NULL); 75613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 75623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 75633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 75643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 75653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e P i x m a p % 75693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 75723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 75733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakePixmap() creates an X11 pixmap. 75753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakePixmap method is: 75773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XMakeStandardColormap(Display *display,XVisualInfo *visual_info, 75793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XResourceInfo *resource_info,Image *image,XStandardColormap *map_info, 75803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XPixelInfo *pixel) 75813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 75833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 75853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 75873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 75883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 75903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 75913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 75923ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType XMakePixmap(Display *display, 75933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XResourceInfo *resource_info,XWindowInfo *window) 75943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 75953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 75963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 75973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 75983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 75993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 76003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 76013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 76023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 76033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixmap != (Pixmap) NULL) 76043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 76053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Destroy previous X pixmap. 76073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreePixmap(display,window->pixmap); 76093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixmap=(Pixmap) NULL; 76103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 76113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->use_pixmap == MagickFalse) 76123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 76133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage == (XImage *) NULL) 76143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 76153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Display busy cursor. 76173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->busy_cursor); 76193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 76203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Create pixmap. 76223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) window->ximage->width; 76243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) window->ximage->height; 76253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->pixmap=XCreatePixmap(display,window->id,width,height,window->depth); 76263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixmap == (Pixmap) NULL) 76273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 76283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Unable to allocate pixmap. 76303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 76323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 76333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 76343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Copy X image to pixmap. 76363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 76383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory) 76393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XShmPutImage(display,window->pixmap,window->annotate_context, 76403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,0,0,0,0,width,height,MagickTrue); 76413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 76423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 76433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,window->pixmap,window->annotate_context, 76443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,0,0,0,0,width,height); 76453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 76463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 76473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Pixmap:"); 76483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," width, height: %ux%u", 76493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width,height); 76503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 76513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 76523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Restore cursor. 76533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 76543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,window->id,window->cursor); 76553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 76563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 76573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 76583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 76593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 76603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e S t a n d a r d C o l o r m a p % 76643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 76673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 76683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeStandardColormap() creates an X11 Standard Colormap. 76703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeStandardColormap method is: 76723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76736710d8414f0ed06e4eaf9346366be72e2b4719efcristy% void XMakeStandardColormap(Display *display,XVisualInfo *visual_info, 76746710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XResourceInfo *resource_info,Image *image,XStandardColormap *map_info, 76756710d8414f0ed06e4eaf9346366be72e2b4719efcristy% XPixelInfo *pixel,ExceptionInfo *exception) 76763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 76783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 76803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 76813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_info: Specifies a pointer to a X11 XVisualInfo structure; 76833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% returned from XGetVisualInfo. 76843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 76863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image: the image. 76883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o map_info: If a Standard Colormap type is specified, this structure is 76903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% initialized with info from the Standard Colormap. 76913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o pixel: Specifies a pointer to a XPixelInfo structure. 76933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 76946710d8414f0ed06e4eaf9346366be72e2b4719efcristy% o exception: return any errors or warnings in this structure. 76956710d8414f0ed06e4eaf9346366be72e2b4719efcristy% 76963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 76973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 76983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 76993ed852eea50f9d4cd633efb8c2b054b8e33c253cristyextern "C" { 77003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 77013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77023ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic inline MagickRealType DiversityPixelIntensity( 77033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const DiversityPacket *pixel) 77043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickRealType 77063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy intensity; 77073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy intensity=0.299*pixel->red+0.587*pixel->green+0.114*pixel->blue; 77093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(intensity); 77103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77123ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int IntensityCompare(const void *x,const void *y) 77133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPacket 77153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_1, 77163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_2; 77173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 77193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity; 77203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_1=(DiversityPacket *) x; 77223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_2=(DiversityPacket *) y; 77233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity=(int) (DiversityPixelIntensity(color_2)- 77243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPixelIntensity(color_1)); 77253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(diversity); 77263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77283ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic int PopularityCompare(const void *x,const void *y) 77293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPacket 77313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_1, 77323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *color_2; 77333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_1=(DiversityPacket *) x; 77353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color_2=(DiversityPacket *) y; 77363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((int) color_2->count-(int) color_1->count); 77373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(__cplusplus) || defined(c_plusplus) 77403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 77423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7743bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic inline Quantum ScaleXToQuantum(const size_t x, 7744bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy const size_t scale) 77453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Quantum) (((MagickRealType) QuantumRange*x)/scale+0.5)); 77473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 77483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7749bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XMakeStandardColormap(Display *display, 77503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XVisualInfo *visual_info,XResourceInfo *resource_info,Image *image, 77516710d8414f0ed06e4eaf9346366be72e2b4719efcristy XStandardColormap *map_info,XPixelInfo *pixel,ExceptionInfo *exception) 77523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 77533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 77543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 77553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7756bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy register ssize_t 77573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 77583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 77603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 77613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 7762bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy size_t 77633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors, 77643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors; 77653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned short 77673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value; 77683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 77703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color, 77713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *colors, 77723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 77733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 77753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 77763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(visual_info != (XVisualInfo *) NULL); 77773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(map_info != (XStandardColormap *) NULL); 77783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 77793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(pixel != (XPixelInfo *) NULL); 77803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (resource_info->map_type != (char *) NULL) 77813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 77823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 77833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Standard Colormap is already defined (i.e. xstdcmap). 77843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 77854c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,resource_info,image, 77863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel); 77873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=(unsigned int) (map_info->base_pixel+ 77883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->red_max+1)*(map_info->green_max+1)*(map_info->blue_max+1)); 77893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((map_info->red_max*map_info->green_max*map_info->blue_max) != 0) 77903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->matte == MagickFalse) && 77913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (resource_info->color_recovery == MagickFalse) && 77923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->quantize_info->dither && 77933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (number_colors < MaxColormapSize)) 77943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 77953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image 77963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *affinity_image; 77973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 77984c08aed51c5899665ade97263692328eea4af106cristy register Quantum 7799c47d1f8ecfe7d04f0f003cca0fe175658bbf0fb2cristy *restrict q; 78003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 78013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Improve image appearance with error diffusion. 78033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78046710d8414f0ed06e4eaf9346366be72e2b4719efcristy affinity_image=AcquireImage((ImageInfo *) NULL,exception); 78053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (affinity_image == (Image *) NULL) 78063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 78073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToDitherImage",image->filename); 78083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affinity_image->columns=number_colors; 78093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affinity_image->rows=1; 78103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize colormap image. 78123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy q=QueueAuthenticPixels(affinity_image,0,0,affinity_image->columns, 78143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1,exception); 78154c08aed51c5899665ade97263692328eea4af106cristy if (q != (Quantum *) NULL) 78163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7817bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 78183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78194c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(affinity_image,0,q); 78203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->red_max != 0) 78214c08aed51c5899665ade97263692328eea4af106cristy SetPixelRed(affinity_image, 78224c08aed51c5899665ade97263692328eea4af106cristy ScaleXToQuantum((size_t) (i/map_info->red_mult), 78234c08aed51c5899665ade97263692328eea4af106cristy map_info->red_max),q); 78244c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(affinity_image,0,q); 78253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->green_max != 0) 78264c08aed51c5899665ade97263692328eea4af106cristy SetPixelGreen(affinity_image, 78274c08aed51c5899665ade97263692328eea4af106cristy ScaleXToQuantum((size_t) ((i/map_info->green_mult) % 78284c08aed51c5899665ade97263692328eea4af106cristy (map_info->green_max+1)),map_info->green_max),q); 78294c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(affinity_image,0,q); 78303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 78314c08aed51c5899665ade97263692328eea4af106cristy SetPixelBlue(affinity_image, 78324c08aed51c5899665ade97263692328eea4af106cristy ScaleXToQuantum((size_t) (i % map_info->green_mult), 78334c08aed51c5899665ade97263692328eea4af106cristy map_info->blue_max),q); 78344c08aed51c5899665ade97263692328eea4af106cristy SetPixelAlpha(affinity_image, 78354c08aed51c5899665ade97263692328eea4af106cristy TransparentAlpha,q); 7836ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy q+=GetPixelChannels(affinity_image); 78373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) SyncAuthenticPixels(affinity_image,exception); 78393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) RemapImage(resource_info->quantize_info,image, 7840018f07f7333b25743d0afff892450cebdb905c1acristy affinity_image,exception); 78413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78424c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,resource_info,image, 78433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel); 7844574cc26500992189f637cd1cdf93d0654e7df7aecristy (void) SetImageStorageClass(image,DirectClass,exception); 78453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy affinity_image=DestroyImage(affinity_image); 78463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 78483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "Standard Colormap:"); 78513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " colormap id: 0x%lx",map_info->colormap); 78533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue max: %lu %lu %lu",map_info->red_max, 78553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max,map_info->blue_max); 78563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 78573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue mult: %lu %lu %lu",map_info->red_mult, 78583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_mult,map_info->blue_mult); 78593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 78613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass != DirectColor) && 78633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass != TrueColor)) 78643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((image->storage_class == DirectClass) || 78653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((int) image->colors > visual_info->colormap_size)) 78663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy QuantizeInfo 78683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy quantize_info; 78693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 78703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Image has more colors than the visual supports. 78723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy quantize_info=(*resource_info->quantize_info); 7874bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy quantize_info.number_colors=(size_t) visual_info->colormap_size; 7875018f07f7333b25743d0afff892450cebdb905c1acristy (void) QuantizeImage(&quantize_info,image,exception); 78763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 78773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Free previous and create new colormap. 78793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeStandardColormap(display,visual_info,map_info,pixel); 78813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XDefaultColormap(display,visual_info->screen); 78823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->visual != XDefaultVisual(display,visual_info->screen)) 78833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XCreateColormap(display,XRootWindow(display,visual_info->screen), 78843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->visual,visual_info->klass == DirectColor ? 78853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AllocAll : AllocNone); 78863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colormap == (Colormap) NULL) 78873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError,"UnableToCreateColormap", 78883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->filename); 78893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize the map and pixel info structures. 78913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGetMapInfo(visual_info,colormap,map_info); 78934c08aed51c5899665ade97263692328eea4af106cristy XGetPixelInfo(display,visual_info,map_info,resource_info,image,pixel); 78943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 78953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocating colors in server colormap is based on visual class. 78963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 78973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (visual_info->klass) 78983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 78993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticGray: 79003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticColor: 79013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard Colormap for StaticGray or StaticColor visual. 79043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=image->colors; 79063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory((size_t) 79073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,sizeof(*colors)); 79083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 79093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 79103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 79113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 79123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 7913bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 79143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=ScaleQuantumToShort(XRedGamma(image->colormap[i].red)); 79163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=ScaleQuantumToShort(XGreenGamma(image->colormap[i].green)); 79173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=ScaleQuantumToShort(XBlueGamma(image->colormap[i].blue)); 79183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != StaticColor) 79193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 79213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 79223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 79233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 79243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XAllocColor(display,colormap,&color); 79263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 79273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XCopyColormapAndFree(display,colormap); 79293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&color); 79303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[i]=color.pixel; 79323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 79333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 79353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 79363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case GrayScale: 79373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PseudoColor: 79383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 79393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 79403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_type; 79413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard Colormap for GrayScale or PseudoColor visual. 79443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=image->colors; 79463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory((size_t) 79473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,sizeof(*colors)); 79483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 79493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 79503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 79513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Preallocate our GUI colors. 79533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->foreground_color); 79553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->background_color); 79563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->border_color); 79573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->matte_color); 79583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->highlight_color); 79593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->shadow_color); 79603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->depth_color); 79613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->trough_color); 79623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 79633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&pixel->pen_colors[i]); 79643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine if image colors will "fit" into X server colormap. 79663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_type=resource_info->colormap; 7968f2faecf9facdbbb14fcba373365f9f691a9658e0cristy status=XAllocColorCells(display,colormap,MagickFalse,(unsigned long *) 79693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy NULL,0,pixel->pixels,(unsigned int) image->colors); 79703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != False) 79713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap_type=PrivateColormap; 79723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colormap_type == SharedColormap) 79733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 7974c57f694b2d04975a0e501613e34368c464708c19cristy CacheView 7975c57f694b2d04975a0e501613e34368c464708c19cristy *image_view; 7976c57f694b2d04975a0e501613e34368c464708c19cristy 79773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy DiversityPacket 79783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *diversity; 79793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 79813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 79823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 79843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 79853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned short 79873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index; 79883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 79903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *server_colors; 79913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 79923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 79933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard colormap for shared GrayScale or PseudoColor visual. 79943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 79953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity=(DiversityPacket *) AcquireQuantumMemory(image->colors, 79963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sizeof(*diversity)); 79973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (diversity == (DiversityPacket *) NULL) 79983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 79993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 8000bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 80013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8002e42f658533644aecb733785ffd91b286d6778deacristy diversity[i].red=ClampToQuantum(image->colormap[i].red); 8003e42f658533644aecb733785ffd91b286d6778deacristy diversity[i].green=ClampToQuantum(image->colormap[i].green); 8004e42f658533644aecb733785ffd91b286d6778deacristy diversity[i].blue=ClampToQuantum(image->colormap[i].blue); 80053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[i].index=(unsigned short) i; 80063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[i].count=0; 80073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8008c57f694b2d04975a0e501613e34368c464708c19cristy image_view=AcquireCacheView(image); 80093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (y=0; y < (int) image->rows; y++) 80103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8011c57f694b2d04975a0e501613e34368c464708c19cristy register int 80123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x; 80133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 80144c08aed51c5899665ade97263692328eea4af106cristy register const Quantum 8015c57f694b2d04975a0e501613e34368c464708c19cristy *restrict p; 80163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8017c57f694b2d04975a0e501613e34368c464708c19cristy p=GetCacheViewAuthenticPixels(image_view,0,(ssize_t) y, 8018c57f694b2d04975a0e501613e34368c464708c19cristy image->columns,1,exception); 80194c08aed51c5899665ade97263692328eea4af106cristy if (p == (const Quantum *) NULL) 80203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 8021c57f694b2d04975a0e501613e34368c464708c19cristy for (x=(int) image->columns-1; x >= 0; x--) 80224c08aed51c5899665ade97263692328eea4af106cristy { 80234c08aed51c5899665ade97263692328eea4af106cristy diversity[(ssize_t) GetPixelIndex(image,p)].count++; 8024ed2315769b26818ed9d0c1291dc0457f0d8da0a4cristy p+=GetPixelChannels(image); 80254c08aed51c5899665ade97263692328eea4af106cristy } 80263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8027c57f694b2d04975a0e501613e34368c464708c19cristy image_view=DestroyCacheView(image_view); 80283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Sort colors by decreasing intensity. 80303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy qsort((void *) diversity,image->colors,sizeof(*diversity), 80323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy IntensityCompare); 8033bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; ) 80343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[i].count<<=4; /* increase this colors popularity */ 8036dfe2b6658f367de8f84405263f62768fb853adafcristy i+=MagickMax((int) (image->colors >> 4),2); 80373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity[image->colors-1].count<<=4; 80393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy qsort((void *) diversity,image->colors,sizeof(*diversity), 80403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PopularityCompare); 80413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate colors. 80433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 80453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 8046bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 80473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=diversity[i].index; 80493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red= 80503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XRedGamma(image->colormap[index].red)); 80513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green= 80523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XGreenGamma(image->colormap[index].green)); 80533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue= 80543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XBlueGamma(image->colormap[index].blue)); 80553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != PseudoColor) 80563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 80583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 80593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 80603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 80613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XAllocColor(display,colormap,&color); 80633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 80643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 80653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[index]=color.pixel; 80663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 80673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Read X server colormap. 80703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 80713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_colors=(XColor *) AcquireQuantumMemory((size_t) 80723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,sizeof(*server_colors)); 80733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (server_colors == (XColor *) NULL) 80743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 80753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 80763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (x=visual_info->colormap_size-1; x >= 0; x--) 8077bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy server_colors[x].pixel=(size_t) x; 80783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display,colormap,server_colors, 80793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) MagickMin((unsigned int) visual_info->colormap_size,256)); 80803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 80813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select remaining colors from X server colormap. 80823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8083bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (; i < (ssize_t) image->colors; i++) 80843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy index=diversity[i].index; 80863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red= 80873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XRedGamma(image->colormap[index].red)); 80883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green= 80893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XGreenGamma(image->colormap[index].green)); 80903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue= 80913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ScaleQuantumToShort(XBlueGamma(image->colormap[index].blue)); 80923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != PseudoColor) 80933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 80943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 80953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 80963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 80973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 80983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 80993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,server_colors,(unsigned int) 81003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy visual_info->colormap_size,&color); 81013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[index]=color.pixel; 81023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 81033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) image->colors < visual_info->colormap_size) 81053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Fill up colors array-- more choices for pen colors. 81083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors=MagickMin((unsigned int) 81103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->colormap_size-image->colors),256); 8111bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) retain_colors; i++) 81123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=server_colors[i]; 81133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors+=retain_colors; 81143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy server_colors=(XColor *) RelinquishMagickMemory(server_colors); 81163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy diversity=(DiversityPacket *) RelinquishMagickMemory(diversity); 81173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 81183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard colormap for private GrayScale or PseudoColor visual. 81213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 81233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Not enough colormap entries in the colormap-- Create a new colormap. 81263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XCreateColormap(display, 81283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XRootWindow(display,visual_info->screen),visual_info->visual, 81293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy AllocNone); 81303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colormap == (Colormap) NULL) 81313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 81323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 81333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap=colormap; 81343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) image->colors < visual_info->colormap_size) 81353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Retain colors from the default colormap to help lessens the 81383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy effects of colormap flashing. 81393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors=MagickMin((unsigned int) 81413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->colormap_size-image->colors),256); 81423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors+image->colors; 8143bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) retain_colors; i++) 81443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 8145c57f694b2d04975a0e501613e34368c464708c19cristy p->pixel=(unsigned long) i; 81463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 81473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryColors(display, 81493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultColormap(display,visual_info->screen), 81503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors+image->colors,(int) retain_colors); 81513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Transfer colors from default to private colormap. 81533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColorCells(display,colormap,MagickFalse, 8155f2faecf9facdbbb14fcba373365f9f691a9658e0cristy (unsigned long *) NULL,0,pixel->pixels,(unsigned int) 81563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy retain_colors); 81573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors+image->colors; 8158bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) retain_colors; i++) 81593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p->pixel=pixel->pixels[i]; 81613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 81623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XStoreColors(display,colormap,colors+image->colors, 81643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) retain_colors); 81653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors+=retain_colors; 81663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColorCells(display,colormap,MagickFalse, 8168f2faecf9facdbbb14fcba373365f9f691a9658e0cristy (unsigned long *) NULL,0,pixel->pixels,(unsigned int) 81693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image->colors); 81703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 81723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Store the image colormap. 81733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 81743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 81753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 8176bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) image->colors; i++) 81773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=ScaleQuantumToShort(XRedGamma(image->colormap[i].red)); 81793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=ScaleQuantumToShort(XGreenGamma(image->colormap[i].green)); 81803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=ScaleQuantumToShort(XBlueGamma(image->colormap[i].blue)); 81813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (visual_info->klass != PseudoColor) 81823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gray_value=(unsigned short) XPixelIntensity(&color); 81843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=gray_value; 81853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=gray_value; 81863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=gray_value; 81873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=pixel->pixels[i]; 81893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 81903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XStoreColors(display,colormap,colors,(int) image->colors); 81923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 81933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 81943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case TrueColor: 81953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case DirectColor: 81963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 81973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 81983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickBooleanType 81993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy linear_colormap; 82003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 82013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Define Standard Colormap for TrueColor or DirectColor visual. 82033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_colors=(unsigned int) ((map_info->red_max*map_info->red_mult)+ 82053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->green_max*map_info->green_mult)+ 82063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (map_info->blue_max*map_info->blue_mult)+1); 82073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy linear_colormap=(number_colors > 4096) || 82083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (((int) (map_info->red_max+1) == visual_info->colormap_size) && 82093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((int) (map_info->green_max+1) == visual_info->colormap_size) && 82103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((int) (map_info->blue_max+1) == visual_info->colormap_size)) ? 82113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickTrue : MagickFalse; 82123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (linear_colormap != MagickFalse) 8213bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy number_colors=(size_t) visual_info->colormap_size; 82143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allocate color array. 82163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) AcquireQuantumMemory(number_colors,sizeof(*colors)); 82183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (colors == (XColor *) NULL) 82193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(ResourceLimitFatalError, 82203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "UnableToCreateColormap",image->filename); 82213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize linear color ramp. 82233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=colors; 82253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.flags=(char) (DoRed | DoGreen | DoBlue); 82263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (linear_colormap != MagickFalse) 8227bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 82283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=(unsigned short) 0; 82303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 8231bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.blue=(unsigned short) ((size_t) 82323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*(i % map_info->green_mult))/map_info->blue_max)); 82333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=color.blue; 82343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=color.blue; 82353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=XStandardPixel(map_info,&color); 82363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 82373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 8239bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 82403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.red=(unsigned short) 0; 82423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->red_max != 0) 8243bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.red=(unsigned short) ((size_t) 82443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*(i/map_info->red_mult))/map_info->red_max)); 82453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.green=(unsigned int) 0; 82463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->green_max != 0) 8247bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.green=(unsigned short) ((size_t) 82483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*((i/map_info->green_mult) % (map_info->green_max+1)))/ 82493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max)); 82503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.blue=(unsigned short) 0; 82513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (map_info->blue_max != 0) 8252bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy color.blue=(unsigned short) ((size_t) 82533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ((65535L*(i % map_info->green_mult))/map_info->blue_max)); 82543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color.pixel=XStandardPixel(map_info,&color); 82553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p++=color; 82563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass == DirectColor) && 82583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (colormap != XDefaultColormap(display,visual_info->screen))) 82593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XStoreColors(display,colormap,colors,(int) number_colors); 82603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 8261bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy for (i=0; i < (ssize_t) number_colors; i++) 82623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllocColor(display,colormap,&colors[i]); 82633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 82643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((visual_info->klass != DirectColor) && 82673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (visual_info->klass != TrueColor)) 82683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set foreground, background, border, etc. pixels. 82713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->foreground_color); 82743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->background_color); 82763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixel->background_color.pixel == pixel->foreground_color.pixel) 82773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 82783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 82793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Foreground and background colors must differ. 82803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 82813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.red=(~pixel->foreground_color.red); 82823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.green= 82833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~pixel->foreground_color.green); 82843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->background_color.blue= 82853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (~pixel->foreground_color.blue); 82863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->background_color); 82883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 82893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->border_color); 82913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->matte_color); 82933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->highlight_color); 82953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->shadow_color); 82973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 82983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->depth_color); 82993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 83003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->trough_color); 83013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < MaxNumberPens; i++) 83023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 83033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XBestPixel(display,colormap,colors,(unsigned int) number_colors, 83043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &pixel->pen_colors[i]); 83053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixel->pixels[image->colors+i]=pixel->pen_colors[i].pixel; 83063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 8307c57f694b2d04975a0e501613e34368c464708c19cristy pixel->colors=(ssize_t) (image->colors+MaxNumberPens); 83083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 83093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colors=(XColor *) RelinquishMagickMemory(colors); 83103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (IsEventLogging()) 83113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 83123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(),"Standard Colormap:"); 83133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule()," colormap id: 0x%lx", 83143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->colormap); 83153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 83163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue max: %lu %lu %lu",map_info->red_max, 83173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_max,map_info->blue_max); 83183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(X11Event,GetMagickModule(), 83193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy " red, green, blue mult: %lu %lu %lu",map_info->red_mult, 83203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy map_info->green_mult,map_info->blue_mult); 83213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 83223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 83233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 83253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a k e W i n d o w % 83303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 83333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 83343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMakeWindow() creates an X11 window. 83363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMakeWindow method is: 83383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XMakeWindow(Display *display,Window parent,char **argv,int argc, 83403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XClassHint *class_hint,XWMHints *manager_hints, 83413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowInfo *window_info) 83423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 83443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 83463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 83473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o parent: Specifies the parent window_info. 83493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o argv: Specifies the application's argument list. 83513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o argc: Specifies the number of arguments. 83533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o class_hint: Specifies a pointer to a X11 XClassHint structure. 83553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o manager_hints: Specifies a pointer to a X11 XWMHints structure. 83573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window_info: Specifies a pointer to a X11 XWindowInfo structure. 83593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 83603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8361bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XMakeWindow(Display *display,Window parent,char **argv, 83623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int argc,XClassHint *class_hint,XWMHints *manager_hints, 83633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowInfo *window_info) 83643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 83653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define MinWindowSize 64 83663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 83683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy atom_list[2]; 83693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 83713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gravity; 83723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XTextProperty 83743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_name, 83753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 83763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 83783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 83793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSizeHints 83813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *size_hints; 83823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 83833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 83843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Set window info hints. 83853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 83863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 83873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 83883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window_info != (XWindowInfo *) NULL); 83893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints=XAllocSizeHints(); 83903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (size_hints == (XSizeHints *) NULL) 83913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToMakeXWindow",argv[0]); 8392dfe2b6658f367de8f84405263f62768fb853adafcristy size_hints->flags=(int) window_info->flags; 83933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->x=window_info->x; 83943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->y=window_info->y; 83953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->width=(int) window_info->width; 83963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->height=(int) window_info->height; 83973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->immutable != MagickFalse) 83983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 83993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 84003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window size cannot be changed. 84013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 84023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_width=size_hints->width; 84033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_height=size_hints->height; 84043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->max_width=size_hints->width; 84053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->max_height=size_hints->height; 84063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PMinSize; 84073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PMaxSize; 84083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 84103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 84123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window size can be changed. 84133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 84143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_width=(int) window_info->min_width; 84153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->min_height=(int) window_info->min_height; 84163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PResizeInc; 84173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->width_inc=(int) window_info->width_inc; 84183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->height_inc=(int) window_info->height_inc; 84193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(PRE_R4_ICCCM) 84203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PBaseSize; 84213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->base_width=size_hints->width_inc; 84223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->base_height=size_hints->height_inc; 84233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 84243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy gravity=NorthWestGravity; 84263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->geometry != (char *) NULL) 84273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 84293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default_geometry[MaxTextExtent], 84303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy geometry[MaxTextExtent]; 84313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 84333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags; 84343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 84363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 84373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 84393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy User specified geometry. 84403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8441b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(default_geometry,MaxTextExtent,"%dx%d", 84423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->width,size_hints->height); 84433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(geometry,window_info->geometry,MaxTextExtent); 84443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=geometry; 84453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (strlen(p) != 0) 84463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((isspace((int) ((unsigned char) *p)) == 0) && (*p != '%')) 84483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p++; 84493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 84503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(p,p+1,MaxTextExtent); 84513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=XWMGeometry(display,window_info->screen,geometry,default_geometry, 84533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->border_width,size_hints,&size_hints->x,&size_hints->y, 84543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &size_hints->width,&size_hints->height,&gravity); 84553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & WidthValue) && (flags & HeightValue)) 84563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=USSize; 84573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & XValue) && (flags & YValue)) 84583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=USPosition; 84603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->x=size_hints->x; 84613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->y=size_hints->y; 84623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 84643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined(PRE_R4_ICCCM) 84653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->win_gravity=gravity; 84663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=PWinGravity; 84673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 84683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id == (Window) NULL) 84693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->id=XCreateWindow(display,parent,window_info->x,window_info->y, 84703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) size_hints->width,(unsigned int) size_hints->height, 84713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->border_width,(int) window_info->depth,InputOutput, 8472c57f694b2d04975a0e501613e34368c464708c19cristy window_info->visual,(unsigned long) window_info->mask, 8473c57f694b2d04975a0e501613e34368c464708c19cristy &window_info->attributes); 84743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 84753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 84763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy MagickStatusType 84773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask; 84783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 84803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sans_event; 84813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindowChanges 84833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes; 84843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 84853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 84863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window already exists; change relevant attributes. 84873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 8488c57f694b2d04975a0e501613e34368c464708c19cristy (void) XChangeWindowAttributes(display,window_info->id,(unsigned long) 8489c57f694b2d04975a0e501613e34368c464708c19cristy window_info->mask,&window_info->attributes); 84903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask=ConfigureNotify; 84913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,window_info->id,(int) mask,&sans_event)) ; 84923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.x=window_info->x; 84933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.y=window_info->y; 84943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.width=(int) window_info->width; 84953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_changes.height=(int) window_info->height; 84963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask=(MagickStatusType) (CWWidth | CWHeight); 84973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->flags & USPosition) 84983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask|=CWX | CWY; 84993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XReconfigureWMWindow(display,window_info->id,window_info->screen, 85003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask,&window_changes); 85013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->id == (Window) NULL) 85033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToCreateWindow", 85043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->name); 85053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XStringListToTextProperty(&window_info->name,1,&window_name); 85063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 85073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToCreateTextProperty", 85083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->name); 85093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XStringListToTextProperty(&window_info->icon_name,1,&icon_name); 85103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 85113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerFatalError,"UnableToCreateTextProperty", 85123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->icon_name); 85133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->icon_geometry != (char *) NULL) 85143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 85163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags, 85173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 85183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 85193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 85213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy User specified icon geometry. 85223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 85233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints->flags|=USPosition; 85243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy flags=XWMGeometry(display,window_info->screen,window_info->icon_geometry, 85253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (char *) NULL,0,size_hints,&manager_hints->icon_x, 85263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &manager_hints->icon_y,&width,&height,&gravity); 85273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((flags & XValue) && (flags & YValue)) 85283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy manager_hints->flags|=IconPositionHint; 85293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XSetWMProperties(display,window_info->id,&window_name,&icon_name,argv,argc, 85313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy size_hints,manager_hints,class_hint); 85323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_name.value != (void *) NULL) 85333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) window_name.value); 85353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name.value=(unsigned char *) NULL; 85363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name.nitems=0; 85373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (icon_name.value != (void *) NULL) 85393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) icon_name.value); 85413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_name.value=(unsigned char *) NULL; 85423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy icon_name.nitems=0; 85433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy atom_list[0]=XInternAtom(display,"WM_DELETE_WINDOW",MagickFalse); 85453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy atom_list[1]=XInternAtom(display,"WM_TAKE_FOCUS",MagickFalse); 85463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetWMProtocols(display,window_info->id,atom_list,2); 85473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) size_hints); 85483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->shape != MagickFalse) 85493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHAPE) 85513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 85523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy error_base, 85533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event_base; 85543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 85563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Can we apply a non-rectangular shaping mask? 85573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 85583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy error_base=0; 85593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event_base=0; 85603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XShapeQueryExtension(display,&error_base,&event_base) == 0) 85613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shape=MagickFalse; 85623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 85633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shape=MagickFalse; 85643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 85653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window_info->shared_memory) 85673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 85683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 85693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 85703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Can we use shared memory with this window? 85713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 85723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XShmQueryExtension(display) == 0) 85733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shared_memory=MagickFalse; 85743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 85753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->shared_memory=MagickFalse; 85763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 85773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 85783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->image=NewImageList(); 85793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_info->destroy=MagickFalse; 85803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 85813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 85823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 85833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 85843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X M a g i c k P r o g r e s s M o n i t o r % 85883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 85913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 85923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XMagickProgressMonitor() displays the progress a task is making in 85943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% completing a task. 85953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XMagickProgressMonitor method is: 85973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 85983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XMagickProgressMonitor(const char *task, 85993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const MagickOffsetType quantum,const MagickSizeType span, 86003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void *client_data) 86013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 86033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o task: Identifies the task in progress. 86053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o quantum: Specifies the quantum position within the span which represents 86073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% how much progress has been made in completing a task. 86083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o span: Specifies the span relative to completing a task. 86103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o client_data: Pointer to any client data. 86123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 86143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86153ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic const char *GetLocaleMonitorMessage(const char *text) 86163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 86173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 86183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy message[MaxTextExtent], 86193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy tag[MaxTextExtent]; 86203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char 86223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *locale_message; 86233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register char 86253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p; 86263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickMemory(tag,text,MaxTextExtent); 86283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy p=strrchr(tag,'/'); 86293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (p != (char *) NULL) 86303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *p='\0'; 8631b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); 86323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy locale_message=GetLocaleMessage(message); 86333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (locale_message == message) 86343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(text); 86353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(locale_message); 86363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 86373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 8638bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate MagickBooleanType XMagickProgressMonitor(const char *tag, 86393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const MagickOffsetType quantum,const MagickSizeType span, 86403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy void *magick_unused(client_data)) 86413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 86423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 86433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 86443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=XSetWindows((XWindows *) ~0); 86463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows == (XWindows *) NULL) 86473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 86483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows->info.mapped != MagickFalse) 86493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XProgressMonitorWidget(windows->display,windows, 86503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GetLocaleMonitorMessage(tag),quantum,span); 86513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 86523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 86533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 86553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X Q u e r y C o l o r D a t a b a s e % 86603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 86633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 86643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86659950d57e1124b73f684fb5946e206994cefda628cristy% XQueryColorCompliance() looks up a RGB values for a color given in the target 86663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% string. 86673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XQueryColorDatabase method is: 86693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86709950d57e1124b73f684fb5946e206994cefda628cristy% MagickBooleanType XQueryColorCompliance(const char *target,XColor *color) 86713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 86733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o target: Specifies the color to lookup in the X color database. 86753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 8676101ab708b0574518ac5715da4d3915400e9df79acristy% o color: A pointer to an PixelInfo structure. The RGB value of the target 86773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% color is returned as this value. 86783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 86793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 86809950d57e1124b73f684fb5946e206994cefda628cristyMagickPrivate MagickBooleanType XQueryColorCompliance(const char *target, 86813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor *color) 86823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 86833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Colormap 86843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap; 86853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static Display 86873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *display = (Display *) NULL; 86883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 86903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 86913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XColor 86933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy xcolor; 86943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 86953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 86963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize color return value. 86973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 86983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(color != (XColor *) NULL); 86993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->red=0; 87003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->green=0; 87013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->blue=0; 87023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->flags=(char) (DoRed | DoGreen | DoBlue); 87033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((target == (char *) NULL) || (*target == '\0')) 87043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target="#ffffffffffff"; 87053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 87063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Let the X server define the color for us. 87073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 87083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 87093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay((char *) NULL); 87103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 87113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 87123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer",target); 87133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 87143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 87153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy colormap=XDefaultColormap(display,XDefaultScreen(display)); 87163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XParseColor(display,colormap,(char *) target,&xcolor); 87173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 87183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"ColorIsNotKnownToServer",target) 87193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 87203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 87213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->red=xcolor.red; 87223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->green=xcolor.green; 87233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->blue=xcolor.blue; 87243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy color->flags=xcolor.flags; 87253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 87263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(status != False ? MagickTrue : MagickFalse); 87273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 87283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 87303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X Q u e r y P o s i t i o n % 87353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XQueryPosition() gets the pointer coordinates relative to a window. 87413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XQueryPosition method is: 87433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XQueryPosition(Display *display,const Window window,int *x,int *y) 87453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 87473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 87493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 87503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a Window. 87523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o x: Return the x coordinate of the pointer relative to the origin of the 87543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 87553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o y: Return the y coordinate of the pointer relative to the origin of the 87573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window. 87583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8760bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XQueryPosition(Display *display,const Window window,int *x,int *y) 87613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 87623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 87633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_root, 87643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_root; 87653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 87673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy mask; 87683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 87703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 87713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 87733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 87743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 87753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(x != (int *) NULL); 87763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(y != (int *) NULL); 87773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XQueryPointer(display,window,&root_window,&root_window,&x_root,&y_root, 87783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x,y,&mask); 87793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 87803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 87813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 87823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X R e f r e s h W i n d o w % 87873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 87903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XRefreshWindow() refreshes an image in a X window. 87933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XRefreshWindow method is: 87953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XRefreshWindow(Display *display,const XWindowInfo *window, 87973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const XEvent *event) 87983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 87993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 88003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 88023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 88033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 88053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o event: Specifies a pointer to a XEvent structure. If it is NULL, 88073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the entire image is refreshed. 88083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 88093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 8810bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XRefreshWindow(Display *display,const XWindowInfo *window, 88113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const XEvent *event) 88123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 88133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 88143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x, 88153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y; 88163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 88183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height, 88193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width; 88203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 88223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 88233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (XWindowInfo *) NULL); 88243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->ximage == (XImage *) NULL) 88253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 88263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (event != (XEvent *) NULL) 88273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Determine geometry from expose event. 88303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=event->xexpose.x; 88323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=event->xexpose.y; 88333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) event->xexpose.width; 88343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) event->xexpose.height; 88353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 88373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 88393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy sans_event; 88403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Refresh entire window; discard outstanding expose events. 88433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x=0; 88453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y=0; 88463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=window->width; 88473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=window->height; 88483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckTypedWindowEvent(display,window->id,Expose,&sans_event)) ; 8849a0e5ad575fbabf93f14a3748ae501376928998fccristy if (window->matte_pixmap != (Pixmap) NULL) 8850a0e5ad575fbabf93f14a3748ae501376928998fccristy { 8851a0e5ad575fbabf93f14a3748ae501376928998fccristy#if defined(MAGICKCORE_HAVE_SHAPE) 8852a0e5ad575fbabf93f14a3748ae501376928998fccristy if (window->shape != MagickFalse) 8853a0e5ad575fbabf93f14a3748ae501376928998fccristy XShapeCombineMask(display,window->id,ShapeBounding,0,0, 8854a0e5ad575fbabf93f14a3748ae501376928998fccristy window->matte_pixmap,ShapeSet); 8855a0e5ad575fbabf93f14a3748ae501376928998fccristy#endif 8856a0e5ad575fbabf93f14a3748ae501376928998fccristy } 88573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Check boundary conditions. 88603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->ximage->width-(x+window->x)) < (int) width) 88623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy width=(unsigned int) (window->ximage->width-(x+window->x)); 88633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((window->ximage->height-(y+window->y)) < (int) height) 88643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy height=(unsigned int) (window->ximage->height-(y+window->y)); 88653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 88663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Refresh image. 88673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 88683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 8869a0e5ad575fbabf93f14a3748ae501376928998fccristy (void) XSetClipMask(display,window->annotate_context,window->matte_pixmap); 88703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->pixmap != (Pixmap) NULL) 88713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->depth > 1) 88733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCopyArea(display,window->pixmap,window->id, 88743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->annotate_context,x+window->x,y+window->y,width,height,x,y); 88753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 88763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCopyPlane(display,window->pixmap,window->id, 88773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->highlight_context,x+window->x,y+window->y,width,height,x,y, 88783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 1L); 88793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 88813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 88823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HAVE_SHARED_MEMORY) 88833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory) 88843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XShmPutImage(display,window->id,window->annotate_context, 88853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,x+window->x,y+window->y,x,y,width,height,MagickTrue); 88863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 88873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->shared_memory == MagickFalse) 88883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XPutImage(display,window->id,window->annotate_context, 88893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window->ximage,x+window->x,y+window->y,x,y,width,height); 88903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 88913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window->matte_pixmap != (Pixmap) NULL) 88923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetClipMask(display,window->annotate_context,None); 88933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFlush(display); 88943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 88953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 88963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 88973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 88983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 88993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X R e m o t e C o m m a n d % 89023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 89063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XRemoteCommand() forces a remote display(1) to display the specified 89083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% image filename. 89093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XRemoteCommand method is: 89113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% MagickBooleanType XRemoteCommand(Display *display,const char *window, 89133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *filename) 89143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 89163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 89183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 89193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies the name or id of an X window. 89213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o filename: the name of the image filename to display. 89233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 89253ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport MagickBooleanType XRemoteCommand(Display *display, 89263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *window,const char *filename) 89273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 89283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 89293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_atom; 89303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 89313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 89323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window, 89333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window; 89343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 89353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(filename != (char *) NULL); 89363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); 89373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 89383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy display=XOpenDisplay((char *) NULL); 89393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (display == (Display *) NULL) 89403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 89413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToOpenXServer",filename); 89423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 89433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 89443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_atom=XInternAtom(display,"IM_PROTOCOLS",MagickFalse); 89453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=(Window) NULL; 89463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 89473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window != (char *) NULL) 89483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 89493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 89503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search window hierarchy and identify any clients by name or ID. 89513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 89523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (isdigit((unsigned char) *window) != 0) 89533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=XWindowByID(display,root_window,(Window) 89543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy strtol((char *) window,(char **) NULL,0)); 89553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (remote_window == (Window) NULL) 89563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=XWindowByName(display,root_window,window); 89573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 89583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (remote_window == (Window) NULL) 89593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_window=XWindowByProperty(display,root_window,remote_atom); 89603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (remote_window == (Window) NULL) 89613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 89623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowException(XServerError,"UnableToConnectToRemoteDisplay", 89633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename); 89643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 89653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 89663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 89673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Send remote command. 89683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 89693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy remote_atom=XInternAtom(display,"IM_REMOTE_COMMAND",MagickFalse); 89703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XChangeProperty(display,remote_window,remote_atom,XA_STRING,8, 89713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy PropModeReplace,(unsigned char *) filename,(int) strlen(filename)); 89723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSync(display,MagickFalse); 89733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickTrue); 89743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 89753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 89763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 89773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 89783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X R e t a i n W i n d o w C o l o r s % 89823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 89853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 89863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XRetainWindowColors() sets X11 color resources on a window. This preserves 89883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the colors associated with an image displayed on the window. 89893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XRetainWindowColors method is: 89913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XRetainWindowColors(Display *display,const Window window) 89933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 89953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 89973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 89983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 89993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: Specifies a pointer to a XWindowInfo structure. 90003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 90023ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XRetainWindowColors(Display *display,const Window window) 90033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 90043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 90053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property; 90063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Pixmap 90083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixmap; 90093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 90113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Put property on the window. 90123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 90133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 90143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 90153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 90163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy property=XInternAtom(display,"_XSETROOT_ID",MagickFalse); 90173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (property == (Atom) NULL) 90183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 90193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToCreateProperty", 90203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy "_XSETROOT_ID"); 90213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 90223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 90233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy pixmap=XCreatePixmap(display,window,1,1,1); 90243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (pixmap == (Pixmap) NULL) 90253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 90263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToCreateBitmap",""); 90273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 90283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 90293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XChangeProperty(display,window,property,XA_PIXMAP,32,PropModeReplace, 90303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned char *) &pixmap,1); 90313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XSetCloseDownMode(display,RetainPermanent); 90323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 90333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 90353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 90363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 90373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 90383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 90393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X S e l e c t W i n d o w % 90403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 90413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 90423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 90433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 90443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSelectWindow() allows a user to select a window using the mouse. If the 90463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% mouse moves, a cropping rectangle is drawn and the extents of the rectangle 90473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% is returned in the crop_info structure. 90483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XSelectWindow function is: 90503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% target_window=XSelectWindow(display,crop_info) 90523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 90543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: XSelectWindow returns the window id. 90563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 90583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 90593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o crop_info: Specifies a pointer to a RectangleInfo structure. It 90613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% contains the extents of any cropping rectangle. 90623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 90633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 90643ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic Window XSelectWindow(Display *display,RectangleInfo *crop_info) 90653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 90663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define MinimumCropArea (unsigned int) 9 90673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Cursor 90693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_cursor; 90703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GC 90723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy annotate_context; 90733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 90753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses, 90763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset, 90773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset; 90783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 90803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 90813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 90833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window, 90843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window; 90853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XEvent 90873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event; 90883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XGCValues 90903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values; 90913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 90923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 90933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Initialize graphic context. 90943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 90953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 90963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 90973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(crop_info != (RectangleInfo *) NULL); 90983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root_window=XRootWindow(display,XDefaultScreen(display)); 90993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.background=XBlackPixel(display,XDefaultScreen(display)); 91003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.foreground=XWhitePixel(display,XDefaultScreen(display)); 91013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.function=GXinvert; 91023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.plane_mask= 91033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.background ^ context_values.foreground; 91043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy context_values.subwindow_mode=IncludeInferiors; 9105bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy annotate_context=XCreateGC(display,root_window,(size_t) (GCBackground | 91063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GCForeground | GCFunction | GCSubwindowMode),&context_values); 91073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (annotate_context == (GC) NULL) 91083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(MagickFalse); 91093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 91103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Grab the pointer using target cursor. 91113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 91123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_cursor=XMakeCursor(display,root_window,XDefaultColormap(display, 91133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XDefaultScreen(display)),(char * ) "white",(char * ) "black"); 91143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGrabPointer(display,root_window,MagickFalse,(unsigned int) 91153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask),GrabModeSync, 91163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy GrabModeAsync,root_window,target_cursor,CurrentTime); 91173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status != GrabSuccess) 91183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 91193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ThrowXWindowFatalException(XServerError,"UnableToGrabMouse",""); 91203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 91213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 91233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Select a window. 91243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 91253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->width=0; 91263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->height=0; 91273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses=0; 91283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=(Window) NULL; 91293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset=0; 91303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset=0; 91313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy do 91323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 91333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width*crop_info->height) >= MinimumCropArea) 91343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,root_window,annotate_context, 91353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) crop_info->x,(int) crop_info->y,(unsigned int) crop_info->width-1, 91363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) crop_info->height-1); 91373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 91383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Allow another event. 91393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 91403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XAllowEvents(display,SyncPointer,CurrentTime); 91413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWindowEvent(display,root_window,ButtonPressMask | 91423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ButtonReleaseMask | ButtonMotionMask,&event); 91433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width*crop_info->height) >= MinimumCropArea) 91443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XDrawRectangle(display,root_window,annotate_context, 91453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (int) crop_info->x,(int) crop_info->y,(unsigned int) crop_info->width-1, 91463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (unsigned int) crop_info->height-1); 91473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (event.type) 91483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 91493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case ButtonPress: 91503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 91513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=XGetSubwindow(display,event.xbutton.subwindow, 91523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy event.xbutton.x,event.xbutton.y); 91533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (target_window == (Window) NULL) 91543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=root_window; 91553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy x_offset=event.xbutton.x_root; 91563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy y_offset=event.xbutton.y_root; 9157ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->x=(ssize_t) x_offset; 9158ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->y=(ssize_t) y_offset; 91593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->width=0; 91603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->height=0; 91613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses++; 91623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 91633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case ButtonRelease: 91653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 91663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy presses--; 91673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 91683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case MotionNotify: 91703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 91713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 91723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Discard pending button motion events. 91733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 91743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy while (XCheckMaskEvent(display,ButtonMotionMask,&event)) ; 9175ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->x=(ssize_t) event.xmotion.x; 9176ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->y=(ssize_t) event.xmotion.y; 91773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 91783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Check boundary conditions. 91793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 91803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) crop_info->x < x_offset) 9181ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->width=(size_t) (x_offset-crop_info->x); 91823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 91833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9184ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->width=(size_t) (crop_info->x-x_offset); 9185ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->x=(ssize_t) x_offset; 91863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((int) crop_info->y < y_offset) 9188ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->height=(size_t) (y_offset-crop_info->y); 91893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 91903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 9191ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->height=(size_t) (crop_info->y-y_offset); 9192ecd0ab5350482e4a2ea003705e3e0b2120b66384cristy crop_info->y=(ssize_t) y_offset; 91933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy default: 91963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 91973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 91983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } while ((target_window == (Window) NULL) || (presses > 0)); 91993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XUngrabPointer(display,CurrentTime); 92003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeCursor(display,target_cursor); 92013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFreeGC(display,annotate_context); 92023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width*crop_info->height) < MinimumCropArea) 92033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 92043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->width=0; 92053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy crop_info->height=0; 92063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 92073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((crop_info->width != 0) && (crop_info->height != 0)) 92083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy target_window=root_window; 92093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(target_window); 92103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 92113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 92133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X S e t C u r s o r S t a t e % 92183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSetCursorState() sets the cursor state to busy, otherwise the cursor are 92243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% reset to their default. 92253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XXSetCursorState method is: 92273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSetCursorState(display,windows,const MagickStatusType state) 92293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 92313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a connection to an X server; returned from 92333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 92343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows: Specifies a pointer to a XWindows structure. 92363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o state: An unsigned integer greater than 0 sets the cursor state 92383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% to busy, otherwise the cursor are reset to their default. 92393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9241bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XSetCursorState(Display *display,XWindows *windows, 92423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const MagickStatusType state) 92433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 92443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 92453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 92463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(windows != (XWindows *) NULL); 92473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (state) 92483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 92493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->image.id, 92503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->image.busy_cursor); 92513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->pan.id, 92523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->pan.busy_cursor); 92533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->magnify.id, 92543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.busy_cursor); 92553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->command.id, 92563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->command.busy_cursor); 92573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 92583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy else 92593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 92603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->image.id, 92613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->image.cursor); 92623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->pan.id,windows->pan.cursor); 92633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->magnify.id, 92643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->magnify.cursor); 92653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->command.id, 92663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->command.cursor); 92673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XCheckDefineCursor(display,windows->command.id, 92683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->widget.cursor); 92693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XWithdrawWindow(display,windows->info.id,windows->info.screen); 92703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 92713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows->info.mapped=MagickFalse; 92723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 92733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 92743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 92753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X S e t W i n d o w s % 92803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 92833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 92843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XSetWindows() sets the X windows structure if the windows info is specified. 92863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% Otherwise the current windows structure is returned. 92873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XSetWindows method is: 92893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindows *XSetWindows(XWindows *windows_info) 92913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 92933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o windows_info: Initialize the Windows structure with this information. 92953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 92963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9297bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate XWindows *XSetWindows(XWindows *windows_info) 92983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 92993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy static XWindows 93003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows = (XWindows *) NULL; 93013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 93023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (windows_info != (XWindows *) ~0) 93033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 93043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=(XWindows *) RelinquishMagickMemory(windows); 93053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=windows_info; 93063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 93073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(windows); 93083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 93093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 93103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 93113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X U s e r P r e f e r e n c e s % 93153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 93193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 93203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XUserPreferences() saves the preferences in a configuration file in the 93213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% users' home directory. 93223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 93233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XUserPreferences method is: 93243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 93253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XUserPreferences(XResourceInfo *resource_info) 93263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 93273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 93283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 93293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o resource_info: Specifies a pointer to a X11 XResourceInfo structure. 93303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 93313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9332bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XUserPreferences(XResourceInfo *resource_info) 93333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 93343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(X11_PREFERENCES_PATH) 93353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 93363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy cache[MaxTextExtent], 93373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy filename[MaxTextExtent], 93383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy specifier[MaxTextExtent]; 93393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 93403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char 9341104cea817534e8601291610f22e496c10f8f9ddbcristy *client_name, 93423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *value; 93433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 93443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmDatabase 93453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy preferences_database; 93463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 93473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 93483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Save user preferences to the client configuration file. 93493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 93503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(resource_info != (XResourceInfo *) NULL); 9351104cea817534e8601291610f22e496c10f8f9ddbcristy client_name=GetClientName(); 93523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy preferences_database=XrmGetStringDatabase(""); 9353b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.backdrop",client_name); 93543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->backdrop ? "True" : "False"; 93553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9356b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.colormap",client_name); 93573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->colormap == SharedColormap ? "Shared" : "Private"; 93583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9359b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.confirmExit", 9360104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 93613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->confirm_exit ? "True" : "False"; 93623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9363b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.confirmEdit", 9364104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 93653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->confirm_edit ? "True" : "False"; 93663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9367b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.displayWarnings", 9368104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 93693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->display_warnings ? "True" : "False"; 93703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9371b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.dither",client_name); 93723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->quantize_info->dither ? "True" : "False"; 93733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9374b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.gammaCorrect", 9375104cea817534e8601291610f22e496c10f8f9ddbcristy client_name); 93763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->gamma_correct ? "True" : "False"; 93773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9378b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.undoCache",client_name); 9379b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(cache,MaxTextExtent,"%.20g",(double) 93803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy resource_info->undo_cache); 93813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,cache); 9382b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(specifier,MaxTextExtent,"%s.usePixmap",client_name); 93833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy value=resource_info->use_pixmap ? "True" : "False"; 93843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutStringResource(&preferences_database,specifier,(char *) value); 9385b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy (void) FormatLocaleString(filename,MaxTextExtent,"%s%src", 9386104cea817534e8601291610f22e496c10f8f9ddbcristy X11_PREFERENCES_PATH,client_name); 93873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ExpandFilename(filename); 93883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XrmPutFileDatabase(preferences_database,filename); 93893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 93903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 93913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 93923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 93933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 93943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X V i s u a l C l a s s N a m e % 93983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 93993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XVisualClassName() returns the visual class name as a character string. 94043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XVisualClassName method is: 94063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% char *XVisualClassName(const int visual_class) 94083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 94103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o visual_type: XVisualClassName returns the visual class as a character 94123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% string. 94133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o class: Specifies the visual class. 94153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 94173ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic const char *XVisualClassName(const int visual_class) 94183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 94193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy switch (visual_class) 94203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 94213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticGray: return("StaticGray"); 94223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case GrayScale: return("GrayScale"); 94233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case StaticColor: return("StaticColor"); 94243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case PseudoColor: return("PseudoColor"); 94253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case TrueColor: return("TrueColor"); 94263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy case DirectColor: return("DirectColor"); 94273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 94283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return("unknown visual class"); 94293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 94303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 94313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 94323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W a r n i n g % 94373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWarning() displays a warning reason in a Notice widget. 94433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWarning method is: 94453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XWarning(const unsigned int warning,const char *reason, 94473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% const char *description) 94483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 94503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o warning: Specifies the numeric warning category. 94523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o reason: Specifies the reason to display before terminating the 94543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% program. 94553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o description: Specifies any description to the reason. 94573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9459bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate void XWarning(const ExceptionType magick_unused(warning), 94603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *reason,const char *description) 94613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 94623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy char 94633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy text[MaxTextExtent]; 94643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 94653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XWindows 94663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *windows; 94673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 94683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (reason == (char *) NULL) 94693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return; 94703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) CopyMagickString(text,reason,MaxTextExtent); 94713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) ConcatenateMagickString(text,":",MaxTextExtent); 94723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy windows=XSetWindows((XWindows *) ~0); 94733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XNoticeWidget(windows->display,windows,text,(char *) description); 94743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 94753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 94763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 94773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W i n d o w B y I D % 94823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 94853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 94863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowByID() locates a child window with a given ID. If not window with 94883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% the given name is found, 0 is returned. Only the window specified and its 94893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% subwindows are searched. 94903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWindowByID function is: 94923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% child=XWindowByID(display,window,id) 94943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 94963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 94973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o child: XWindowByID returns the window with the specified 94983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% id. If no windows are found, XWindowByID returns 0. 94993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 95013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 95023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o id: Specifies the id of the window to locate. 95043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9506bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Window XWindowByID(Display *display,const Window root_window, 9507bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy const size_t id) 95083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 95093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy RectangleInfo 95103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy rectangle_info; 95113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 95133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 95143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 95163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 95173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 95193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 95203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 95223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 95233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 95243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window; 95253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 95273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 95283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(root_window != (Window) NULL); 95293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (id == 0) 95303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(XSelectWindow(display,&rectangle_info)); 95313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (root_window == id) 9532dfe2b6658f367de8f84405263f62768fb853adafcristy return(root_window); 95333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,root_window,&child,&child,&children, 95343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_children); 95353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 95363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 95373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=(Window) NULL; 95383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_children; i++) 95393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 95403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 95413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search each child and their children. 95423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 95433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=XWindowByID(display,children[i],id); 95443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window != (Window) NULL) 95453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 95463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 95473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (children != (Window *) NULL) 95483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 95493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(window); 95503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 95513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 95533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 95543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W i n d o w B y N a m e % 95583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 95613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 95623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowByName() locates a window with a given name on a display. If no 95643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window with the given name is found, 0 is returned. If more than one window 95653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% has the given name, the first one is returned. Only root and its children 95663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% are searched. 95673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWindowByName function is: 95693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window=XWindowByName(display,root_window,name) 95713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 95733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o window: XWindowByName returns the window id. 95753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 95773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 95783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o root_window: Specifies the id of the root window. 95803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o name: Specifies the name of the window to locate. 95823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 95833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9584bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Window XWindowByName(Display *display,const Window root_window, 95853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const char *name) 95863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 95873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy register int 95883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i; 95893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 95913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 95923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 95943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 95953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 95963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 95973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 95983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 95993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window; 96003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy XTextProperty 96023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window_name; 96033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 96053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(root_window != (Window) NULL); 96063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(name != (char *) NULL); 96073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name); 96083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (XGetWMName(display,root_window,&window_name) != 0) 96093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (LocaleCompare((char *) window_name.value,name) == 0) 96103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(root_window); 96113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,root_window,&child,&child,&children, 96123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy &number_children); 96133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 96143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 96153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=(Window) NULL; 96163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; i < (int) number_children; i++) 96173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 96183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy /* 96193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Search each child and their children. 96203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy */ 96213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy window=XWindowByName(display,children[i],name); 96223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (window != (Window) NULL) 96233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy break; 96243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 96253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (children != (Window *) NULL) 96263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 96273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(window); 96283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 96293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 96313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X W i n d o w B y P r o p e r y % 96363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 96393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XWindowByProperty() locates a child window with a given property. If not 96423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% window with the given name is found, 0 is returned. If more than one window 96433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% has the given property, the first one is returned. Only the window 96443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% specified and its subwindows are searched. 96453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XWindowByProperty function is: 96473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% child=XWindowByProperty(display,window,property) 96493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 96513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o child: XWindowByProperty returns the window id with the specified 96533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% property. If no windows are found, XWindowByProperty returns 0. 96543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o display: Specifies a pointer to the Display structure; returned from 96563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XOpenDisplay. 96573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o property: Specifies the property of the window to locate. 96593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 96603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9661bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Window XWindowByProperty(Display *display,const Window window, 96623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy const Atom property) 96633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 96643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Atom 96653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type; 96663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy int 96683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy format; 96693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Status 96713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status; 96723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned char 96743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *data; 96753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy unsigned int 96773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy i, 96783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_children; 96793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 9680f2faecf9facdbbb14fcba373365f9f691a9658e0cristy unsigned long 96813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy after, 96823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy number_items; 96833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy Window 96853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child, 96863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy *children, 96873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy parent, 96883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy root; 96893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 96903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 96913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(display != (Display *) NULL); 96923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(window != (Window) NULL); 96933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(property != (Atom) NULL); 96943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XQueryTree(display,window,&root,&parent,&children,&number_children); 96953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (status == False) 96963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Window) NULL); 96973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy type=(Atom) NULL; 96983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child=(Window) NULL; 96993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; (i < number_children) && (child == (Window) NULL); i++) 97003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy { 97013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy status=XGetWindowProperty(display,children[i],property,0L,0L,MagickFalse, 97023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (Atom) AnyPropertyType,&type,&format,&number_items,&after,&data); 97033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (data != NULL) 97043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) data); 97053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if ((status == Success) && (type != (Atom) NULL)) 97063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child=children[i]; 97073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy } 97083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy for (i=0; (i < number_children) && (child == (Window) NULL); i++) 97093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy child=XWindowByProperty(display,children[i],property); 97103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (children != (Window *) NULL) 97113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) XFree((void *) children); 97123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return(child); 97133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 97143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#else 97153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 97173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X I m p o r t I m a g e % 97223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XImportImage() reads an image from an X window. 97283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XImportImage method is: 97303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9731a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% Image *XImportImage(const ImageInfo *image_info,XImportInfo *ximage_info, 9732a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% ExceptionInfo *exception) 97333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 97353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o image_info: the image info.. 97373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage_info: Specifies a pointer to an XImportInfo structure. 97393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 9740a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% o exception: return any errors or warnings in this structure. 9741a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy% 97423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 9743bcbda3fd7d9f3084869f5cebabceb0324c3b2cd7cristyMagickPrivate Image *XImportImage(const ImageInfo *image_info, 9744a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy XImportInfo *ximage_info,ExceptionInfo *exception) 97453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 97463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info != (const ImageInfo *) NULL); 97473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(image_info->signature == MagickSignature); 97483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy if (image_info->debug != MagickFalse) 97493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 97503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy image_info->filename); 97513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(ximage_info != (XImportInfo *) NULL); 9752a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy assert(exception != (ExceptionInfo *) NULL); 9753a0dc96a5df0a380c9ef855cc7f2a5f264bec8af3cristy assert(exception->signature == MagickSignature); 97543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy return((Image *) NULL); 97553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 97563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif 97573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy 97583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/* 97593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 9763576974eba31c1fac74b2492a74862b2fcd50f21ccristy+ X C o m p o n e n t G e n e s i s % 9764576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 9765576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 9766576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 9767576974eba31c1fac74b2492a74862b2fcd50f21ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9768576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 9769576974eba31c1fac74b2492a74862b2fcd50f21ccristy% XComponentGenesis() instantiates the X component. 9770576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 9771576974eba31c1fac74b2492a74862b2fcd50f21ccristy% The format of the XComponentGenesis method is: 9772576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 9773576974eba31c1fac74b2492a74862b2fcd50f21ccristy% MagickBooleanType XComponentGenesis(void) 9774576974eba31c1fac74b2492a74862b2fcd50f21ccristy% 9775576974eba31c1fac74b2492a74862b2fcd50f21ccristy*/ 97765ff4eaf57b3cd47d0371f204f865cbba614674a0cristyMagickPrivate MagickBooleanType XComponentGenesis(void) 9777576974eba31c1fac74b2492a74862b2fcd50f21ccristy{ 9778576974eba31c1fac74b2492a74862b2fcd50f21ccristy return(MagickTrue); 9779576974eba31c1fac74b2492a74862b2fcd50f21ccristy} 9780576974eba31c1fac74b2492a74862b2fcd50f21ccristy 9781576974eba31c1fac74b2492a74862b2fcd50f21ccristy/* 9782576974eba31c1fac74b2492a74862b2fcd50f21ccristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9783576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 9784576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 9785576974eba31c1fac74b2492a74862b2fcd50f21ccristy% % 97863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% X G e t I m p o r t I n f o % 97873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% % 97903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% XGetImportInfo() initializes the XImportInfo structure. 97933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% The format of the XGetImportInfo method is: 97953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% void XGetImportInfo(XImportInfo *ximage_info) 97973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 97983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% A description of each parameter follows: 97993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% o ximage_info: Specifies a pointer to an ImageInfo structure. 98013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy% 98023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/ 98033ed852eea50f9d4cd633efb8c2b054b8e33c253cristyMagickExport void XGetImportInfo(XImportInfo *ximage_info) 98043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ 98053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy assert(ximage_info != (XImportInfo *) NULL); 98063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->frame=MagickFalse; 98073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->borders=MagickFalse; 98083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->screen=MagickFalse; 98093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->descend=MagickTrue; 98103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy ximage_info->silent=MagickFalse; 98113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy} 9812