1 /***** 2 * XCC.h : XCC.c public header file: XColorContext routines 3 * 4 * This file Version $Revision$ 5 * 6 * Creation date: Mon Mar 3 00:28:18 GMT+0100 1997 7 * Last modification: $Date$ 8 * By: $Author$ 9 * Current State: $State$ 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$ 72 *****/ 73 /***** 74 * ChangeLog 75 * $Log$ 76 * Revision 1.1 2011/06/30 16:08:41 rwcox 77 * Cadd 78 * 79 * Revision 1.14 1997/10/23 00:24:42 newt 80 * XmHTML Beta 1.1.0 release 81 * 82 * Revision 1.13 1997/08/31 17:31:55 newt 83 * log edit 84 * 85 * Revision 1.12 1997/08/30 00:32:02 newt 86 * Fixed palette preparations & changed proto's for XCCGetPixels and 87 * XCCGetPixelsIncremental. 88 * 89 * Revision 1.11 1997/08/01 12:54:41 newt 90 * Proto for XCCGetPixelsIncremental added. 91 * 92 * Revision 1.10 1997/05/28 01:35:04 newt 93 * Updated XCCCreate proto. 94 * 95 * Revision 1.9 1997/04/03 05:29:02 newt 96 * Added XCCFreeColors proto 97 * 98 * Revision 1.8 1997/03/20 08:03:19 newt 99 * XCCGetPixels proto updated 100 * 101 * Revision 1.7 1997/03/02 23:44:25 newt 102 * Expanded copyright marker 103 * 104 *****/ 105 106 #ifndef _xcc_h_ 107 #define _xcc_h_ 108 109 typedef struct _XColorContext *XCC; 110 111 _XFUNCPROTOBEGIN 112 113 extern XCC XCCCreate(Widget w, Visual *_visual, Colormap _colormap); 114 115 /* copy an XCC entirely */ 116 extern XCC XCCCopy(XCC src); 117 118 extern XCC XCCMonoCreate(Display *_dpy, Visual *_visual, Colormap _colormap); 119 120 extern void XCCFree(XCC _xcc); 121 122 extern unsigned long XCCGetPixel(XCC _xcc, unsigned short _red, 123 unsigned short _green, unsigned short _blue, Boolean *failed); 124 125 extern void XCCGetPixels(XCC _xcc, unsigned short *reds, 126 unsigned short *greens, unsigned short *blues, int ncolors, 127 unsigned long *colors, int *nallocated); 128 129 extern void XCCGetPixelsIncremental(XCC _xcc, unsigned short *reds, 130 unsigned short *greens, unsigned short *blues, int ncolors, 131 Boolean *used, unsigned long *colors, int *nallocated); 132 133 extern int XCCGetNumColors(XCC _xcc); 134 135 extern Colormap XCCGetColormap(XCC _xcc); 136 extern Visual *XCCGetVisual(XCC _xcc); 137 extern XVisualInfo *XCCGetVisualInfo(XCC _xcc); 138 extern int XCCGetDepth(XCC _xcc); 139 extern int XCCGetClass(XCC _xcc); 140 extern Display *XCCGetDisplay(XCC _xcc); 141 extern int XCCQueryColor(XCC _xcc, XColor *_color); 142 extern int XCCQueryColors(XCC _xcc, XColor *_colors, int _numColors); 143 144 /* get colorcomponents of the given color */ 145 extern int XCCGetColor(XCC _xcc, unsigned long pixel_val, 146 unsigned short *red, unsigned short *green, unsigned short *blue); 147 148 /***** 149 * Returns visual of either the widget (or any parent that is a subclass of 150 * shell) or the default visual 151 *****/ 152 extern Visual *XCCGetParentVisual(Widget w); 153 154 /***** 155 * Add a palette to the given XCC. All colors will then be mapped onto this 156 * palette. 157 *****/ 158 extern int XCCAddPalette(XCC _xcc, XColor *palette, int num_palette); 159 160 /***** 161 * Initialize dithering: allocate & initialize a precomputed error correction 162 * matrices. 163 *****/ 164 extern void XCCInitDither(XCC _xcc); 165 166 /* and free it again */ 167 extern void XCCFreeDither(XCC _xcc); 168 169 /***** 170 * Pick a color using an installed palette. If a direct match is not found, 171 * a least squares algorithm is used to map the color components. 172 * The failed arg will be True if the mapping failed. In all other cases a 173 * pixel value is returned and the _red, _green and _blue args will contain 174 * the difference between the original and used component (which can be 175 * negative, hence these args are signed). If they are all equal to 0 a 176 * perfect match was found (which I suspect will be seldomly the case). 177 * 178 * The intended use of this routine is dithering. Either using ordered or 179 * Floyd-Steinberg. 180 *****/ 181 unsigned long XCCGetPixelFromPalette(XCC _xcc, unsigned short *_red, 182 unsigned short *_green, unsigned short *_blue, Boolean *failed); 183 184 /***** 185 * Same as above, but this time the *index* into the palette at which the 186 * requested color can be found is returned. Used by the dither algorithms. 187 *****/ 188 extern unsigned char XCCGetIndexFromPalette(XCC _xcc, int *_red, int *_green, 189 int *_blue, Boolean *failed); 190 191 _XFUNCPROTOEND 192 193 /* Don't add anything after this endif! */ 194 #endif /* _xcc_h_ */ 195