~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/XIE/dixie/process/pctrgb.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: pctrgb.c,v 1.4 2001/02/09 02:04:22 xorgcvs Exp $ */
 
2
/**** module pctrgb.c ****/
 
3
/******************************************************************************
 
4
 
 
5
Copyright 1993, 1994, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 
 
27
 
 
28
                                NOTICE
 
29
                              
 
30
This software is being provided by AGE Logic, Inc. under the
 
31
following license.  By obtaining, using and/or copying this software,
 
32
you agree that you have read, understood, and will comply with these
 
33
terms and conditions:
 
34
 
 
35
     Permission to use, copy, modify, distribute and sell this
 
36
     software and its documentation for any purpose and without
 
37
     fee or royalty and to grant others any or all rights granted
 
38
     herein is hereby granted, provided that you agree to comply
 
39
     with the following copyright notice and statements, including
 
40
     the disclaimer, and that the same appears on all copies and
 
41
     derivative works of the software and documentation you make.
 
42
     
 
43
     "Copyright 1993, 1994 by AGE Logic, Inc."
 
44
     
 
45
     THIS SOFTWARE IS PROVIDED "AS IS".  AGE LOGIC MAKES NO
 
46
     REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  By way of
 
47
     example, but not limitation, AGE LOGIC MAKE NO
 
48
     REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS
 
49
     FOR ANY PARTICULAR PURPOSE OR THAT THE SOFTWARE DOES NOT
 
50
     INFRINGE THIRD-PARTY PROPRIETARY RIGHTS.  AGE LOGIC 
 
51
     SHALL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE.  IN NO
 
52
     EVENT SHALL EITHER PARTY BE LIABLE FOR ANY INDIRECT,
 
53
     INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS
 
54
     OF PROFITS, REVENUE, DATA OR USE, INCURRED BY EITHER PARTY OR
 
55
     ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT OR
 
56
     BASED ON A WARRANTY, EVEN IF AGE LOGIC LICENSEES
 
57
     HEREUNDER HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
 
58
     DAMAGES.
 
59
    
 
60
     The name of AGE Logic, Inc. may not be used in
 
61
     advertising or publicity pertaining to this software without
 
62
     specific, written prior permission from AGE Logic.
 
63
 
 
64
     Title to this software shall at all times remain with AGE
 
65
     Logic, Inc.
 
66
*****************************************************************************
 
67
  
 
68
        pctrgb.c -- DIXIE routines for managing the ConvertToRGB element
 
69
  
 
70
        Dean Verheiden -- AGE Logic, Inc. August 1993
 
71
  
 
72
*****************************************************************************/
 
73
/* $XFree86: xc/programs/Xserver/XIE/dixie/process/pctrgb.c,v 3.6 2001/12/14 19:58:05 dawes Exp $ */
 
74
 
 
75
#define _XIEC_PCTRGB
 
76
 
 
77
/*
 
78
 *  Include files
 
79
 */
 
80
 
 
81
  /*
 
82
   *  Core X Includes
 
83
   */
 
84
#define NEED_EVENTS
 
85
#include <X.h>
 
86
#include <Xproto.h>
 
87
  /*
 
88
   *  XIE Includes
 
89
   */
 
90
#include <dixie_p.h>
 
91
  /*
 
92
   *  Server XIE Includes
 
93
   */
 
94
#include <corex.h>
 
95
#include <error.h>
 
96
#include <macro.h>
 
97
#include <element.h>
 
98
#include <technq.h>
 
99
#include <difloat.h>
 
100
#include <memory.h>
 
101
 
 
102
/*
 
103
 *  routines internal to this module
 
104
 */
 
105
static Bool PrepPConvertToRGB(floDefPtr flo, peDefPtr ped);
 
106
 
 
107
/*
 
108
 * dixie element entry points
 
109
 */
 
110
static diElemVecRec pConvertToRGBVec = {
 
111
  PrepPConvertToRGB             /* prepare for analysis and execution   */
 
112
  };
 
113
 
 
114
/*------------------------------------------------------------------------
 
115
------------------ routine: make a ConvertToRBG element ----------------
 
116
------------------------------------------------------------------------*/
 
117
peDefPtr MakeConvertToRGB(floDefPtr flo, xieTypPhototag tag, xieFlo *pe)
 
118
{
 
119
  peDefPtr ped;
 
120
  ELEMENT(xieFloConvertToRGB);
 
121
  ELEMENT_AT_LEAST_SIZE(xieFloConvertToRGB);
 
122
  ELEMENT_NEEDS_1_INPUT(src);
 
123
  
 
124
  if(!(ped = MakePEDef(1, (CARD32)stuff->elemLength<<2, 0)))
 
125
    FloAllocError(flo,tag,xieElemConvertToRGB, return(NULL)) ;
 
126
 
 
127
  ped->diVec         = &pConvertToRGBVec;
 
128
  ped->phototag      = tag;
 
129
  ped->flags.process = TRUE;
 
130
  raw = (xieFloConvertToRGB *)ped->elemRaw;
 
131
  /*
 
132
   * copy the client element parameters (swap if necessary)
 
133
   */
 
134
  if( flo->reqClient->swapped ) {
 
135
    raw->elemType   = stuff->elemType;
 
136
    raw->elemLength = stuff->elemLength;
 
137
    cpswaps(stuff->src,       raw->src);
 
138
    cpswaps(stuff->convert,   raw->convert);
 
139
    cpswaps(stuff->lenParams, raw->lenParams);
 
140
  } else
 
141
    memcpy((char *)raw, (char *)stuff, sizeof(xieFloConvertToRGB));
 
142
  /*
 
143
   * copy technique data (if any)
 
144
   */
 
145
  if(!(ped->techVec = FindTechnique(xieValConvertToRGB, raw->convert)) ||
 
146
     !(ped->techVec->copyfnc(flo, ped, &stuff[1], &raw[1], raw->lenParams, 0)))
 
147
    TechniqueError(flo,ped,xieValConvertToRGB,raw->convert,raw->lenParams,
 
148
                   return(ped));
 
149
 
 
150
 /*
 
151
   * assign phototag to inFlo
 
152
   */
 
153
  ped->inFloLst[SRCtag].srcTag = raw->src;
 
154
 
 
155
  return(ped);
 
156
}                               /* end MakePConvertToRGB */
 
157
 
 
158
/*------------------------------------------------------------------------
 
159
------ routine: copy routine for CIELab and CIEXYZ techniques  -----------
 
160
------------------------------------------------------------------------*/
 
161
 
 
162
#undef  sparms
 
163
#define sparms ((xieTecCIELabToRGB *)sParms)
 
164
#undef  rparms
 
165
#define rparms ((xieTecCIELabToRGB *)rParms)
 
166
 
 
167
Bool CopyPConvertToRGBCIE(TECHNQ_COPY_ARGS)
 
168
{
 
169
   pTecCIEToRGBDefPtr pvt;
 
170
 
 
171
   VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, FALSE);
 
172
 
 
173
   if (!(ped->techPvt = (pointer )XieMalloc(sizeof(pTecCIEToRGBDefRec))))
 
174
        FloAllocError(flo, ped->phototag,xieElemConvertToRGB, return(TRUE));
 
175
 
 
176
   pvt = (pTecCIEToRGBDefPtr)ped->techPvt;
 
177
 
 
178
   if( flo->reqClient->swapped ) {
 
179
        swap_floats(&pvt->matrix[0], &sparms->matrix00, 9);
 
180
        cpswaps(sparms->whiteAdjusted,  pvt->whiteAdjusted);
 
181
        cpswaps(sparms->lenWhiteParams, pvt->lenWhiteParams);
 
182
        cpswaps(sparms->gamutCompress,  pvt->gamutCompress);
 
183
        cpswaps(sparms->lenGamutParams, pvt->lenGamutParams);
 
184
   } else {
 
185
        copy_floats(&pvt->matrix[0], &sparms->matrix00, 9);
 
186
        pvt->whiteAdjusted  = sparms->whiteAdjusted;
 
187
        pvt->lenWhiteParams = sparms->lenWhiteParams;
 
188
        pvt->gamutCompress  = sparms->gamutCompress;
 
189
        pvt->lenGamutParams = sparms->lenGamutParams;
 
190
   }
 
191
 
 
192
   if(!(pvt->whiteTec = FindTechnique(xieValWhiteAdjust, pvt->whiteAdjusted)) ||
 
193
      !(TECH_WADJ_FUNC(pvt->whiteTec)(flo, ped, &sparms[1], pvt->whitePoint, 
 
194
                                  pvt->whiteTec, pvt->lenWhiteParams, 
 
195
                                  pvt->whiteAdjusted == xieValDefault)))
 
196
       TechniqueError(flo,ped,xieValWhiteAdjust,
 
197
                      pvt->whiteAdjusted,pvt->lenWhiteParams, return(TRUE));
 
198
 
 
199
   if(!(pvt->gamutTec = FindTechnique(xieValGamut, pvt->gamutCompress)) ||
 
200
      !(TECH_GAMU_FUNC(pvt->gamutTec)(pvt->lenGamutParams)))
 
201
       TechniqueError(flo,ped,xieValGamut,
 
202
                      pvt->gamutCompress,pvt->lenGamutParams, return(TRUE));
 
203
 
 
204
   return (TRUE);
 
205
}
 
206
 
 
207
/*------------------------------------------------------------------------
 
208
---------- routine: copy routine for YCbCr and YCC techniques ------------
 
209
------------------------------------------------------------------------*/
 
210
 
 
211
#undef  sparms
 
212
#define sparms ((xieTecYCbCrToRGB *)sParms)
 
213
#undef  rparms
 
214
#define rparms ((xieTecYCbCrToRGB *)rParms)
 
215
 
 
216
Bool CopyPConvertToRGBYCbCr(TECHNQ_COPY_ARGS)
 
217
{
 
218
   pTecYCbCrToRGBDefPtr pvt;
 
219
 
 
220
   VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, FALSE);
 
221
 
 
222
   if (!(ped->techPvt = (pointer )XieMalloc(sizeof(pTecYCbCrToRGBDefRec))))
 
223
        FloAllocError(flo, ped->phototag,xieElemConvertToRGB, return(TRUE));
 
224
 
 
225
   pvt = (pTecYCbCrToRGBDefPtr)ped->techPvt;
 
226
 
 
227
   if( flo->reqClient->swapped ) {
 
228
        cpswapl(sparms->levels0, pvt->levels0);
 
229
        cpswapl(sparms->levels1, pvt->levels1);
 
230
        cpswapl(sparms->levels2, pvt->levels2);
 
231
        swap_floats(&pvt->red, &sparms->lumaRed, 3);
 
232
        swap_floats(&pvt->bias0, &sparms->bias0, 3);
 
233
        cpswaps(sparms->gamutCompress,  pvt->gamutCompress);
 
234
        cpswaps(sparms->lenGamutParams, pvt->lenGamutParams);
 
235
   } else {
 
236
        pvt->levels0 = sparms->levels0;
 
237
        pvt->levels1 = sparms->levels1;
 
238
        pvt->levels2 = sparms->levels2;
 
239
        copy_floats(&pvt->red, &sparms->lumaRed, 3);
 
240
        copy_floats(&pvt->bias0, &sparms->bias0, 3);
 
241
        pvt->gamutCompress  = sparms->gamutCompress;
 
242
        pvt->lenGamutParams = sparms->lenGamutParams;
 
243
   }
 
244
 
 
245
   if(!(pvt->gamutTec = FindTechnique(xieValGamut, pvt->gamutCompress)) ||
 
246
      !(TECH_GAMU_FUNC(pvt->gamutTec)(pvt->lenGamutParams)))
 
247
       TechniqueError(flo,ped,xieValGamut,
 
248
                      pvt->gamutCompress,pvt->lenGamutParams, return(TRUE));
 
249
 
 
250
   return (TRUE);
 
251
}
 
252
 
 
253
#undef  sparms
 
254
#define sparms ((xieTecYCCToRGB *)sParms)
 
255
#undef  rparms
 
256
#define rparms ((xieTecYCCToRGB *)rParms)
 
257
 
 
258
Bool CopyPConvertToRGBYCC(TECHNQ_COPY_ARGS)
 
259
{
 
260
   pTecYCCToRGBDefPtr pvt;
 
261
 
 
262
   VALIDATE_TECHNIQUE_SIZE(ped->techVec, tsize, FALSE);
 
263
 
 
264
   if (!(ped->techPvt = (pointer )XieMalloc(sizeof(pTecYCCToRGBDefRec))))
 
265
        FloAllocError(flo, ped->phototag,xieElemConvertToRGB, return(TRUE));
 
266
 
 
267
   pvt = (pTecYCCToRGBDefPtr)ped->techPvt;
 
268
 
 
269
   if( flo->reqClient->swapped ) {
 
270
        cpswapl(sparms->levels0, pvt->levels0);
 
271
        cpswapl(sparms->levels1, pvt->levels1);
 
272
        cpswapl(sparms->levels2, pvt->levels2);
 
273
        swap_floats(&pvt->red, &sparms->lumaRed, 3);
 
274
        pvt->scale = ConvertFromIEEE(lswapl(sparms->scale));
 
275
        cpswaps(sparms->gamutCompress,  pvt->gamutCompress);
 
276
        cpswaps(sparms->lenGamutParams, pvt->lenGamutParams);
 
277
   } else {
 
278
        pvt->levels0 = sparms->levels0;
 
279
        pvt->levels1 = sparms->levels1;
 
280
        pvt->levels2 = sparms->levels2;
 
281
        copy_floats(&pvt->red, &sparms->lumaRed, 3);
 
282
        pvt->scale = ConvertFromIEEE(sparms->scale);
 
283
        pvt->gamutCompress  = sparms->gamutCompress;
 
284
        pvt->lenGamutParams = sparms->lenGamutParams;
 
285
   }
 
286
 
 
287
   if(!(pvt->gamutTec = FindTechnique(xieValGamut, pvt->gamutCompress)) ||
 
288
      !(TECH_GAMU_FUNC(pvt->gamutTec)(pvt->lenGamutParams)))
 
289
       TechniqueError(flo,ped,xieValGamut,
 
290
                      pvt->gamutCompress,pvt->lenGamutParams, return(TRUE));
 
291
 
 
292
   return (TRUE);
 
293
}
 
294
 
 
295
#undef  sparms
 
296
#undef  rparms
 
297
 
 
298
/*------------------------------------------------------------------------
 
299
-- routine: copy routine for White Adjust None technique ----------
 
300
------------------------------------------------------------------------*/
 
301
Bool CopyPWhiteAdjustNone(
 
302
     floDefPtr  flo,
 
303
     peDefPtr   ped,
 
304
     pointer sparms,
 
305
     double *pvtf,
 
306
     techVecPtr tv,
 
307
     CARD16     tsize,
 
308
     Bool isDefault)
 
309
{
 
310
   return (tsize == 0);
 
311
}
 
312
 
 
313
/*------------------------------------------------------------------------
 
314
-- routine: copy routine for White Adjust CIELabShift technique ----------
 
315
------------------------------------------------------------------------*/
 
316
Bool CopyPWhiteAdjustCIELabShift(
 
317
     floDefPtr  flo,
 
318
     peDefPtr   ped,
 
319
     xieTecWhiteAdjustCIELabShift *sparms,
 
320
     double *pvtf,
 
321
     techVecPtr tv,
 
322
     CARD16     tsize,
 
323
     Bool isDefault)
 
324
{
 
325
   VALIDATE_TECHNIQUE_SIZE(tv, tsize, isDefault);
 
326
 
 
327
   if( flo->reqClient->swapped ) {
 
328
        swap_floats(pvtf, &sparms->whitePoint0, 3);
 
329
   } else {
 
330
        copy_floats(pvtf, &sparms->whitePoint0, 3);
 
331
   }
 
332
 
 
333
   return (TRUE);
 
334
}
 
335
 
 
336
/*------------------------------------------------------------------------
 
337
----------- routine: copy routine for Gamut techniques -------------------
 
338
------------------------------------------------------------------------*/
 
339
Bool CopyPGamut(CARD16 tsize)
 
340
{
 
341
   return (tsize == 0);
 
342
}
 
343
 
 
344
/*------------------------------------------------------------------------
 
345
-- routine: prep routine for RGB to CIElab and CIEXYZ techniques ---------
 
346
------------------------------------------------------------------------*/
 
347
Bool PrepPConvertToRGBCIE(
 
348
     floDefPtr  flo,
 
349
     peDefPtr   ped,
 
350
     xieFloConvertToRGB *raw,
 
351
     xieTecCIELabToRGB *tec)            /* same as xieTecCIEXYZToRGB */
 
352
{
 
353
  pTecCIEToRGBDefPtr pvt = (pTecCIEToRGBDefPtr)ped->techPvt;
 
354
  inFloPtr inf = &ped->inFloLst[SRCtag];
 
355
  outFloPtr src = &inf->srcDef->outFlo;
 
356
  outFloPtr dst = &ped->outFlo;
 
357
  int b;
 
358
 
 
359
  /* grab a copy of the src attributes and propagate them to our input */
 
360
  dst->bands = inf->bands = src->bands;
 
361
  for(b = 0; b < src->bands; b++) {
 
362
        if (IsConstrained(src->format[0].class))
 
363
            return FALSE;       /* must be floats */
 
364
        /* Since we know its floats, structure copy sufficient */
 
365
        dst->format[b] = inf->format[b] = src->format[b];
 
366
  }
 
367
 
 
368
  return(pvt->whiteTec->prepfnc(flo,ped,pvt->whitePoint));
 
369
}
 
370
 
 
371
/*------------------------------------------------------------------------
 
372
-- routine: prep routine for RGB to YCbCr and YCC techniques -------------
 
373
------------------------------------------------------------------------*/
 
374
Bool PrepPConvertToRGBYCbCr(
 
375
     floDefPtr  flo,
 
376
     peDefPtr   ped,
 
377
     xieFloConvertToRGB *raw,
 
378
     xieTecYCbCrToRGB *tec)
 
379
{
 
380
  inFloPtr inf = &ped->inFloLst[SRCtag];
 
381
  outFloPtr src = &inf->srcDef->outFlo;
 
382
  outFloPtr dst = &ped->outFlo;
 
383
  pTecYCbCrToRGBDefPtr pvt = (pTecYCbCrToRGBDefPtr)ped->techPvt;
 
384
  CARD32 *levels = &(pvt->levels0);
 
385
  int b;
 
386
 
 
387
  /* grab a copy of the src attributes and propagate them to our input */
 
388
  dst->bands = inf->bands = src->bands;
 
389
  for(b = 0; b < src->bands; b++) {
 
390
        dst->format[b] = inf->format[b] = src->format[b];
 
391
        if (IsConstrained(dst->format[b].class))
 
392
            dst->format[b].levels = *(levels+b);
 
393
  }
 
394
 
 
395
  /* Set depth, class, stride, and pitch */
 
396
  if (IsConstrained(dst->format[0].class)) {
 
397
      if (UpdateFormatfromLevels(ped) == FALSE)
 
398
        MatchError(flo,ped, return(FALSE));
 
399
  } /* else the structure copy was sufficient */
 
400
 
 
401
  return(TRUE);
 
402
}
 
403
 
 
404
Bool PrepPConvertToRGBYCC(
 
405
     floDefPtr  flo,
 
406
     peDefPtr   ped,
 
407
     xieFloConvertToRGB *raw,
 
408
     xieTecYCCToRGB *tec)
 
409
{
 
410
  inFloPtr inf = &ped->inFloLst[SRCtag];
 
411
  outFloPtr src = &inf->srcDef->outFlo;
 
412
  outFloPtr dst = &ped->outFlo;
 
413
  pTecYCCToRGBDefPtr pvt = (pTecYCCToRGBDefPtr)ped->techPvt;
 
414
  CARD32 *levels = &(pvt->levels0);
 
415
  int b;
 
416
 
 
417
  /* grab a copy of the src attributes and propagate them to our input */
 
418
  dst->bands = inf->bands = src->bands;
 
419
  for(b = 0; b < src->bands; b++) {
 
420
        dst->format[b] = inf->format[b] = src->format[b];
 
421
        if (IsConstrained(dst->format[b].class))
 
422
            dst->format[b].levels = *(levels+b);
 
423
  }
 
424
 
 
425
  /* Set depth, class, stride, and pitch */
 
426
  if (IsConstrained(dst->format[0].class)) {
 
427
      if (UpdateFormatfromLevels(ped) == FALSE)
 
428
        MatchError(flo,ped, return(FALSE));
 
429
  } /* else the structure copy was sufficient */
 
430
 
 
431
  if (pvt->scale < .001) { /* should be about 1.35 or 1.4 */
 
432
        ValueError(flo, ped, tec->scale, return(FALSE));
 
433
  }
 
434
 
 
435
  return(TRUE);
 
436
}
 
437
 
 
438
/*------------------------------------------------------------------------
 
439
------ routine: prep routine for White Adjust none technique -------------
 
440
------------------------------------------------------------------------*/
 
441
Bool PrepPWhiteAdjustNone(
 
442
     floDefPtr  flo,
 
443
     peDefPtr   ped,
 
444
     double     *pwp)
 
445
{
 
446
  return(TRUE);
 
447
}
 
448
 
 
449
/*------------------------------------------------------------------------
 
450
-- routine: prep routine for White Adjust CIELabShift technique ----------
 
451
------------------------------------------------------------------------*/
 
452
Bool PrepPWhiteAdjustCIELabShift(
 
453
     floDefPtr  flo,
 
454
     peDefPtr   ped,
 
455
     double     *pwp)
 
456
{
 
457
  return(TRUE);
 
458
}
 
459
 
 
460
/*------------------------------------------------------------------------
 
461
------------ routine: prep routine for gamut techniques ------------------
 
462
------------------------------------------------------------------------*/
 
463
Bool PrepPGamut(void)
 
464
{
 
465
  return(TRUE);
 
466
}
 
467
 
 
468
/*------------------------------------------------------------------------
 
469
---------------- routine: prepare for analysis and execution -------------
 
470
------------------------------------------------------------------------*/
 
471
 
 
472
static Bool PrepPConvertToRGB(floDefPtr flo, peDefPtr ped)
 
473
{
 
474
  inFloPtr inf = &ped->inFloLst[SRCtag];
 
475
  outFloPtr src = &inf->srcDef->outFlo;
 
476
  xieFloConvertToRGB *raw = (xieFloConvertToRGB *)ped->elemRaw;
 
477
 
 
478
  /* Input must be triple band and dimensions must match */
 
479
  if (IsntCanonic(src->format[0].class) ||
 
480
      src->bands != 3 ||
 
481
      src->format[0].width  != src->format[1].width ||
 
482
      src->format[1].width  != src->format[2].width ||
 
483
      src->format[0].height != src->format[1].height ||
 
484
      src->format[1].height != src->format[2].height)
 
485
      MatchError(flo,ped, return(FALSE));
 
486
 
 
487
 
 
488
  /*
 
489
  ** Technique Prep routine will complete the normal propagation of src
 
490
  ** attributes, and setup of destination attributes.
 
491
  */
 
492
 
 
493
  if (!(ped->techVec->prepfnc(flo, ped, raw, &raw[1])))
 
494
        TechniqueError(flo,ped,xieValConvertToRGB,
 
495
                       raw->convert,raw->lenParams, return(FALSE));
 
496
 
 
497
 
 
498
  return (TRUE);
 
499
}       
 
500
 
 
501
/*------------------------------------------------------------------------
 
502
---------------------- utility routines for parameters -------------------
 
503
------------------------------------------------------------------------*/
 
504
 
 
505
void
 
506
swap_floats(
 
507
   double       *doubles_out,
 
508
   xieTypFloat  *funny_floats_in,
 
509
   int          cnt)
 
510
{
 
511
   int m;
 
512
   for (m = 0; m < cnt; m++)            
 
513
        doubles_out[m] = ConvertFromIEEE(lswapl(funny_floats_in[m]));
 
514
}
 
515
 
 
516
void
 
517
copy_floats(
 
518
   double       *doubles_out,
 
519
   xieTypFloat  *funny_floats_in,
 
520
   int          cnt)
 
521
{
 
522
   int m;
 
523
   for (m = 0; m < cnt; m++)            
 
524
        doubles_out[m] = ConvertFromIEEE(funny_floats_in[m]);
 
525
}
 
526
 
 
527
/* end module pctrgb.c */