1
/* $Xorg: iclut.c,v 1.4 2001/02/09 02:04:20 xorgcvs Exp $ */
2
/* AGE Logic - Oct 15 1995 - Larry Hare */
3
/**** module iclut.c ****/
4
/******************************************************************************
6
Copyright 1993, 1994, 1998 The Open Group
8
Permission to use, copy, modify, distribute, and sell this software and its
9
documentation for any purpose is hereby granted without fee, provided that
10
the above copyright notice appear in all copies and that both that
11
copyright notice and this permission notice appear in supporting
14
The above copyright notice and this permission notice shall be included in
15
all copies or substantial portions of the Software.
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
Except as contained in this notice, the name of The Open Group shall not be
25
used in advertising or otherwise to promote the sale, use or other dealings
26
in this Software without prior written authorization from The Open Group.
31
This software is being provided by AGE Logic, Inc. under the
32
following license. By obtaining, using and/or copying this software,
33
you agree that you have read, understood, and will comply with these
36
Permission to use, copy, modify, distribute and sell this
37
software and its documentation for any purpose and without
38
fee or royalty and to grant others any or all rights granted
39
herein is hereby granted, provided that you agree to comply
40
with the following copyright notice and statements, including
41
the disclaimer, and that the same appears on all copies and
42
derivative works of the software and documentation you make.
44
"Copyright 1993, 1994 by AGE Logic, Inc."
46
THIS SOFTWARE IS PROVIDED "AS IS". AGE LOGIC MAKES NO
47
REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way of
48
example, but not limitation, AGE LOGIC MAKE NO
49
REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
50
FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
51
INFRINGE THIRD-PARTY PROPRIETARY RIGHTS. AGE LOGIC
52
SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE. IN NO
53
EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
54
INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
55
OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
56
ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
57
BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
58
HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
61
The name of AGE Logic, Inc. may not be used in
62
advertising or publicity pertaining to this software without
63
specific, written prior permission from AGE Logic.
65
Title to this software shall at all times remain with AGE
67
*****************************************************************************
69
iclut.c -- DIXIE routines for managing the ImportClientLUT element
71
Dean Verheiden -- AGE Logic, Inc. April 1993
72
Ben Fahy -- AGE Logic, Inc. May 1993
74
*****************************************************************************/
75
/* $XFree86: xc/programs/Xserver/XIE/dixie/import/iclut.c,v 3.5 2001/12/14 19:58:00 dawes Exp $ */
102
* routines internal to this module
104
static Bool PrepICLUT(floDefPtr flo, peDefPtr ped);
109
static diElemVecRec iCLUTVec = {
110
PrepICLUT /* prepare for analysis and execution */
113
/*------------------------------------------------------------------------
114
--------------- routine: make an import client lut element -------------
115
------------------------------------------------------------------------*/
116
peDefPtr MakeICLUT(floDefPtr flo, xieTypPhototag tag, xieFlo *pe)
119
ELEMENT(xieFloImportClientLUT);
120
ELEMENT_SIZE_MATCH(xieFloImportClientLUT);
122
if(!(ped = MakePEDef(1, (CARD32)stuff->elemLength<<2, 0)))
123
FloAllocError(flo,tag,xieElemImportClientLUT,return(NULL));
125
ped->diVec = &iCLUTVec;
127
ped->flags.import = TRUE;
128
ped->flags.putData = TRUE;
129
raw = (xieFloImportClientLUT *)ped->elemRaw;
131
* copy the client element parameters (swap if necessary)
133
if( flo->reqClient->swapped ) {
134
raw->elemType = stuff->elemType;
135
raw->elemLength = stuff->elemLength;
136
raw->class = stuff->class;
137
raw->bandOrder = stuff->bandOrder;
138
cpswapl(stuff->length0, raw->length0);
139
cpswapl(stuff->length1, raw->length1);
140
cpswapl(stuff->length2, raw->length2);
141
cpswapl(stuff->levels0, raw->levels0);
142
cpswapl(stuff->levels1, raw->levels1);
143
cpswapl(stuff->levels2, raw->levels2);
146
memcpy((char *)raw, (char *)stuff, sizeof(xieFloImportClientLUT));
149
} /* end MakeICLUT */
152
/*------------------------------------------------------------------------
153
---------------- routine: prepare for analysis and execution -------------
154
------------------------------------------------------------------------*/
155
static Bool PrepICLUT(floDefPtr flo, peDefPtr ped)
157
xieFloImportClientLUT *raw = (xieFloImportClientLUT *)ped->elemRaw;
158
inFloPtr inflo = &ped->inFloLst[IMPORT];
162
* check for data-class, length, and levels errors, and stash attributes
163
* since this is STREAM data, we only have to record the class and band
164
* numbers in the inflos.
166
if(raw->bandOrder != xieValLSFirst && raw->bandOrder != xieValMSFirst)
167
ValueError(flo,ped,raw->bandOrder, return(FALSE));
170
case xieValSingleBand :
173
ValueError(flo,ped,0, return(FALSE));
174
if(raw->levels0 < 2 || raw->levels0 > MAX_LEVELS(1))
175
MatchError(flo,ped, return(FALSE));
179
case xieValTripleBand :
180
if(!raw->length0 || !raw->length1 || !raw->length2)
181
ValueError(flo,ped,0, return(FALSE));
182
if(raw->levels0 < 2 || raw->levels0 > MAX_LEVELS(3) ||
183
raw->levels1 < 2 || raw->levels1 > MAX_LEVELS(3) ||
184
raw->levels2 < 2 || raw->levels2 > MAX_LEVELS(3))
185
MatchError(flo,ped, return(FALSE));
188
inflo->format[1].band = 1;
189
inflo->format[2].band = 2;
190
ped->outFlo.format[1] = inflo->format[1];
191
ped->outFlo.format[2] = inflo->format[2];
192
ped->outFlo.format[1].levels = raw->levels1;
193
ped->outFlo.format[2].levels = raw->levels2;
194
ped->outFlo.format[1].height = raw->length1;
195
ped->outFlo.format[2].height = raw->length2;
199
ValueError(flo,ped,raw->class, return(FALSE));
202
inflo->format[0].band = 0;
203
ped->outFlo.format[0] = inflo->format[0];
204
ped->outFlo.format[0].levels = raw->levels0;
205
ped->outFlo.format[0].height = raw->length0;
207
for (b=0; b < inflo->bands; b++) {
208
formatPtr fmt = &(ped->outFlo.format[b]);
210
inflo->format[b].class = STREAM;
211
ped->swapUnits[b] = LutPitch(fmt->levels);
213
fmt->class = LUT_ARRAY;
214
fmt->interleaved = FALSE;
215
fmt->width = raw->bandOrder; /* see miclut.c, mppoint crazypixel */
218
fmt->pitch = 8 * fmt->height;
221
ped->outFlo.bands = inflo->bands;
224
} /* end PrepICLUT */
226
/* end module iclut.c */