| 1 |
|
| 2 |
/* |
| 3 |
* Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. |
| 4 |
* All Rights Reserved |
| 5 |
* |
| 6 |
* This file is a component of an X Window System-specific implementation |
| 7 |
* of Xcms based on the TekColor Color Management System. Permission is |
| 8 |
* hereby granted to use, copy, modify, sell, and otherwise distribute this |
| 9 |
* software and its documentation for any purpose and without fee, provided |
| 10 |
* that this copyright, permission, and disclaimer notice is reproduced in |
| 11 |
* all copies of this software and in supporting documentation. TekColor |
| 12 |
* is a trademark of Tektronix, Inc. |
| 13 |
* |
| 14 |
* Tektronix makes no representation about the suitability of this software |
| 15 |
* for any purpose. It is provided "as is" and with all faults. |
| 16 |
* |
| 17 |
* TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE, |
| 18 |
* INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 19 |
* PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX BE LIABLE FOR ANY |
| 20 |
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 21 |
* RESULTING FROM LOSS OF USE, DATA, OR PROFITS, WHETHER IN AN ACTION OF |
| 22 |
* CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 23 |
* CONNECTION WITH THE USE OR THE PERFORMANCE OF THIS SOFTWARE. |
| 24 |
* |
| 25 |
* |
| 26 |
* NAME |
| 27 |
* XcmsStCols.c |
| 28 |
* |
| 29 |
* DESCRIPTION |
| 30 |
* Source for XcmsStoreColors |
| 31 |
* |
| 32 |
* |
| 33 |
*/ |
| 34 |
|
| 35 |
#ifdef HAVE_CONFIG_H |
| 36 |
#include <config.h> |
| 37 |
#endif |
| 38 |
#include "Xlibint.h" |
| 39 |
#include "Xcmsint.h" |
| 40 |
#include "Cv.h" |
| 41 |
#include "reallocarray.h" |
| 42 |
|
| 43 |
|
| 44 |
/************************************************************************ |
| 45 |
* * |
| 46 |
* PUBLIC ROUTINES * |
| 47 |
* * |
| 48 |
************************************************************************/ |
| 49 |
|
| 50 |
/* |
| 51 |
* NAME |
| 52 |
* XcmsStoreColors - Store Colors |
| 53 |
* |
| 54 |
* SYNOPSIS |
| 55 |
*/ |
| 56 |
Status |
| 57 |
XcmsStoreColors( |
| 58 |
Display *dpy, |
| 59 |
Colormap colormap, |
| 60 |
XcmsColor *pColors_in, |
| 61 |
unsigned int nColors, |
| 62 |
Bool *pCompressed) |
| 63 |
/* |
| 64 |
* DESCRIPTION |
| 65 |
* Given device-dependent or device-independent color |
| 66 |
* specifications, this routine will convert them to X RGB |
| 67 |
* values then use it in a call to XStoreColors. |
| 68 |
* |
| 69 |
* RETURNS |
| 70 |
* XcmsFailure if failed; |
| 71 |
* XcmsSuccess if it succeeded without gamut compression; |
| 72 |
* XcmsSuccessWithCompression if it succeeded with gamut |
| 73 |
* compression; |
| 74 |
* |
| 75 |
* Since XStoreColors has no return value, this routine |
| 76 |
* does not return color specifications of the colors actually |
| 77 |
* stored. |
| 78 |
*/ |
| 79 |
{ |
| 80 |
XcmsColor Color1; |
| 81 |
XcmsColor *pColors_tmp; |
| 82 |
Status retval; |
| 83 |
|
| 84 |
/* |
| 85 |
* Make copy of array of color specifications so we don't |
| 86 |
* overwrite the contents. |
| 87 |
*/ |
| 88 |
if (nColors > 1) { |
| 89 |
pColors_tmp = Xmallocarray(nColors, sizeof(XcmsColor)); |
| 90 |
if (pColors_tmp == NULL) |
| 91 |
return(XcmsFailure); |
| 92 |
} else { |
| 93 |
pColors_tmp = &Color1; |
| 94 |
} |
| 95 |
memcpy((char *)pColors_tmp, (char *)pColors_in, |
| 96 |
nColors * sizeof(XcmsColor)); |
| 97 |
|
| 98 |
/* |
| 99 |
* Call routine to store colors using the copied color structures |
| 100 |
*/ |
| 101 |
retval = _XcmsSetGetColors (XStoreColors, dpy, colormap, |
| 102 |
pColors_tmp, nColors, XcmsRGBFormat, pCompressed); |
| 103 |
|
| 104 |
/* |
| 105 |
* Free copies as needed. |
| 106 |
*/ |
| 107 |
if (nColors > 1) { |
| 108 |
Xfree(pColors_tmp); |
| 109 |
} |
| 110 |
|
| 111 |
/* |
| 112 |
* Ah, finally return. |
| 113 |
*/ |
| 114 |
return(retval); |
| 115 |
} |