1 /***** 2 * XCC.h : XCC.c public header file: XColorContext routines 3 * 4 * This file Version $Revision: 1.14 $ 5 * 6 * Creation date: Mon Mar 3 00:28:18 GMT+0100 1997 7 * Last modification: $Date: 1997/10/23 00:24:42 $ 8 * By: $Author: newt $ 9 * Current State: $State: Exp $ 10 * 11 * Author: John L. Cwikla 12 * 13 * Copyright 1994,1995 John L. Cwikla 14 * Copyright (C) 1997 by Ripley Software Development 15 * All Rights Reserved 16 * 17 * This file is part of the XmHTML Widget Library. 18 * 19 * See below for John L. Cwikla's original copyright notice and distribution 20 * Policy. 21 * 22 * This library is free software; you can redistribute it and/or 23 * modify it under the terms of the GNU Library General Public 24 * License as published by the Free Software Foundation; either 25 * version 2 of the License, or (at your option) any later version. 26 * 27 * This library is distributed in the hope that it will be useful, 28 * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 * Library General Public License for more details. 31 * 32 * You should have received a copy of the GNU Library General Public 33 * License along with this library; if not, write to the Free 34 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 35 * 36 *****/ 37 /***** 38 * $Id: XCC.h,v 1.6 1995/08/04 17:46:53 cwikla 39 * 40 * Copyright 1994,1995 John L. Cwikla 41 * 42 * Permission to use, copy, modify, distribute, and sell this software 43 * and its documentation for any purpose is hereby granted without fee, 44 * provided that the above copyright notice appears in all copies and that 45 * both that copyright notice and this permission notice appear in 46 * supporting documentation, and that the name of John L. Cwikla or 47 * Wolfram Research, Inc not be used in advertising or publicity 48 * pertaining to distribution of the software without specific, written 49 * prior permission. John L. Cwikla and Wolfram Research, Inc make no 50 * representations about the suitability of this software for any 51 * purpose. It is provided "as is" without express or implied warranty. 52 * 53 * John L. Cwikla and Wolfram Research, Inc disclaim all warranties with 54 * regard to this software, including all implied warranties of 55 * merchantability and fitness, in no event shall John L. Cwikla or 56 * Wolfram Research, Inc be liable for any special, indirect or 57 * consequential damages or any damages whatsoever resulting from loss of 58 * use, data or profits, whether in an action of contract, negligence or 59 * other tortious action, arising out of or in connection with the use or 60 * performance of this software. 61 * 62 * Author: 63 * John L. Cwikla 64 * X Programmer 65 * Wolfram Research Inc. 66 * 67 * cwikla@wri.com 68 * 69 *****/ 70 /***** 71 * $Source: /usr/local/rcs/Newt/XmHTML/RCS/XCC.h,v $ 72 *****/ 73 /***** 74 * ChangeLog 75 * $Log: XCC.h,v $ 76 * Revision 1.14 1997/10/23 00:24:42 newt 77 * XmHTML Beta 1.1.0 release 78 * 79 * Revision 1.13 1997/08/31 17:31:55 newt 80 * log edit 81 * 82 * Revision 1.12 1997/08/30 00:32:02 newt 83 * Fixed palette preparations & changed proto's for XCCGetPixels and 84 * XCCGetPixelsIncremental. 85 * 86 * Revision 1.11 1997/08/01 12:54:41 newt 87 * Proto for XCCGetPixelsIncremental added. 88 * 89 * Revision 1.10 1997/05/28 01:35:04 newt 90 * Updated XCCCreate proto. 91 * 92 * Revision 1.9 1997/04/03 05:29:02 newt 93 * Added XCCFreeColors proto 94 * 95 * Revision 1.8 1997/03/20 08:03:19 newt 96 * XCCGetPixels proto updated 97 * 98 * Revision 1.7 1997/03/02 23:44:25 newt 99 * Expanded copyright marker 100 * 101 *****/ 102 103 #ifndef _xcc_h_ 104 #define _xcc_h_ 105 106 typedef struct _XColorContext *XCC; 107 108 _XFUNCPROTOBEGIN 109 110 extern XCC XCCCreate(Widget w, Visual *_visual, Colormap _colormap); 111 112 /* copy an XCC entirely */ 113 extern XCC XCCCopy(XCC src); 114 115 extern XCC XCCMonoCreate(Display *_dpy, Visual *_visual, Colormap _colormap); 116 117 extern void XCCFree(XCC _xcc); 118 119 extern unsigned long XCCGetPixel(XCC _xcc, unsigned short _red, 120 unsigned short _green, unsigned short _blue, Boolean *failed); 121 122 extern void XCCGetPixels(XCC _xcc, unsigned short *reds, 123 unsigned short *greens, unsigned short *blues, int ncolors, 124 unsigned long *colors, int *nallocated); 125 126 extern void XCCGetPixelsIncremental(XCC _xcc, unsigned short *reds, 127 unsigned short *greens, unsigned short *blues, int ncolors, 128 Boolean *used, unsigned long *colors, int *nallocated); 129 130 extern int XCCGetNumColors(XCC _xcc); 131 132 extern Colormap XCCGetColormap(XCC _xcc); 133 extern Visual *XCCGetVisual(XCC _xcc); 134 extern XVisualInfo *XCCGetVisualInfo(XCC _xcc); 135 extern int XCCGetDepth(XCC _xcc); 136 extern int XCCGetClass(XCC _xcc); 137 extern Display *XCCGetDisplay(XCC _xcc); 138 extern int XCCQueryColor(XCC _xcc, XColor *_color); 139 extern int XCCQueryColors(XCC _xcc, XColor *_colors, int _numColors); 140 141 /* get colorcomponents of the given color */ 142 extern int XCCGetColor(XCC _xcc, unsigned long pixel_val, 143 unsigned short *red, unsigned short *green, unsigned short *blue); 144 145 /***** 146 * Returns visual of either the widget (or any parent that is a subclass of 147 * shell) or the default visual 148 *****/ 149 extern Visual *XCCGetParentVisual(Widget w); 150 151 /***** 152 * Add a palette to the given XCC. All colors will then be mapped onto this 153 * palette. 154 *****/ 155 extern int XCCAddPalette(XCC _xcc, XColor *palette, int num_palette); 156 157 /***** 158 * Initialize dithering: allocate & initialize a precomputed error correction 159 * matrices. 160 *****/ 161 extern void XCCInitDither(XCC _xcc); 162 163 /* and free it again */ 164 extern void XCCFreeDither(XCC _xcc); 165 166 /***** 167 * Pick a color using an installed palette. If a direct match is not found, 168 * a least squares algorithm is used to map the color components. 169 * The failed arg will be True if the mapping failed. In all other cases a 170 * pixel value is returned and the _red, _green and _blue args will contain 171 * the difference between the original and used component (which can be 172 * negative, hence these args are signed). If they are all equal to 0 a 173 * perfect match was found (which I suspect will be seldomly the case). 174 * 175 * The intended use of this routine is dithering. Either using ordered or 176 * Floyd-Steinberg. 177 *****/ 178 unsigned long XCCGetPixelFromPalette(XCC _xcc, unsigned short *_red, 179 unsigned short *_green, unsigned short *_blue, Boolean *failed); 180 181 /***** 182 * Same as above, but this time the *index* into the palette at which the 183 * requested color can be found is returned. Used by the dither algorithms. 184 *****/ 185 extern unsigned char XCCGetIndexFromPalette(XCC _xcc, int *_red, int *_green, 186 int *_blue, Boolean *failed); 187 188 _XFUNCPROTOEND 189 190 /* Don't add anything after this endif! */ 191 #endif /* _xcc_h_ */ 192