~ubuntu-branches/ubuntu/hardy/ghostscript/hardy

« back to all changes in this revision

Viewing changes to src/gdevpdfk.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2007-11-22 12:17:43 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071122121743-cd70s3ypq0r243mp
Tags: 8.61.dfsg.1-0ubtuntu1
* New upstream release
  o Final 8.61 release
* debian/patches/09_ijs_krgb_support.dpatch: Adapted to upstream changes.
* debian/rules: Updated CUPS-related variables for "make install" calls.
* debian/rules: Remove /usr/include/ghostscript from the ghostscript
  package, they go into lings-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
12
*/
13
13
 
14
 
/* $Id: gdevpdfk.c 8022 2007-06-05 22:23:38Z giles $ */
 
14
/* $Id: gdevpdfk.c 8250 2007-09-25 13:31:24Z giles $ */
15
15
/* Lab and ICCBased color space writing */
16
16
#include "math_.h"
17
17
#include "memory_.h"
30
30
/* ------ CIE space synthesis ------ */
31
31
 
32
32
/* Add a /Range entry to a CIE-based color space dictionary. */
33
 
private int
 
33
static int
34
34
pdf_cie_add_ranges(cos_dict_t *pcd, const gs_range *prange, int n, bool clamp)
35
35
{
36
36
    cos_array_t *pca = cos_array_alloc(pcd->pdev, "pdf_cie_add_ranges");
58
58
}
59
59
 
60
60
/* Transform a CIEBased color to XYZ. */
61
 
private int
 
61
static int
62
62
cie_to_xyz(const double *in, double out[3], const gs_color_space *pcs,
63
63
           const gs_imager_state *pis)
64
64
{
79
79
/* ------ Lab space writing and synthesis ------ */
80
80
 
81
81
/* Transform XYZ values to Lab. */
82
 
private double
 
82
static double
83
83
lab_g_inverse(double v)
84
84
{
85
85
    if (v >= (6.0 * 6.0 * 6.0) / (29 * 29 * 29))
87
87
    else
88
88
        return (v * (841.0 / 108) + 4.0 / 29);
89
89
}
90
 
private void
 
90
static void
91
91
xyz_to_lab(const double xyz[3], double lab[3], const gs_cie_common *pciec)
92
92
{
93
93
    const gs_vector3 *const pWhitePoint = &pciec->points.WhitePoint;
109
109
}
110
110
 
111
111
/* Create a PDF Lab color space corresponding to a CIEBased color space. */
112
 
private int
 
112
static int
113
113
lab_range(gs_range range_out[3] /* only [1] and [2] used */,
114
114
          const gs_color_space *pcs, const gs_cie_common *pciec,
115
115
          const gs_range *ranges, gs_memory_t *mem)
165
165
 * Create a Lab color space for a CIEBased space that can't be represented
166
166
 * directly as a Calxxx or Lab space.
167
167
 */
168
 
private int
 
168
static int
169
169
pdf_convert_cie_to_lab(gx_device_pdf *pdev, cos_array_t *pca,
170
170
                       const gs_color_space *pcs,
171
171
                       const gs_cie_common *pciec, const gs_range *prange)
193
193
 * Create an ICCBased color space object (internal).  The client must write
194
194
 * the profile data on *ppcstrm.
195
195
 */
196
 
private int
 
196
static int
197
197
pdf_make_iccbased(gx_device_pdf *pdev, cos_array_t *pca, int ncomps,
198
198
                  const gs_range *prange /*[4]*/,
199
199
                  const gs_color_space *pcs_alt,
278
278
/*
279
279
 * Finish writing the data stream for an ICCBased color space object.
280
280
 */
281
 
private int
 
281
static int
282
282
pdf_finish_iccbased(cos_stream_t *pcstrm)
283
283
{
284
284
    /*
306
306
    const void *write_data;
307
307
    const gs_range_t *ranges;
308
308
};
309
 
private profile_table_t *
 
309
static profile_table_t *
310
310
add_table(profile_table_t **ppnt, const char *tag, const byte *data,
311
311
          uint length)
312
312
{
319
319
    pnt->ranges = NULL;
320
320
    return pnt;
321
321
}
322
 
private void
 
322
static void
323
323
set_uint32(byte bytes[4], uint value)
324
324
{
325
325
    bytes[0] = (byte)(value >> 24);
327
327
    bytes[2] = (byte)(value >> 8);
328
328
    bytes[3] = (byte)value;
329
329
}
330
 
private void
 
330
static void
331
331
set_XYZ(byte bytes[4], floatp value)
332
332
{
333
333
    set_uint32(bytes, (uint)(int)(value * 65536));
334
334
}
335
 
private void
 
335
static void
336
336
add_table_xyz3(profile_table_t **ppnt, const char *tag, byte bytes[20],
337
337
               const gs_vector3 *pv)
338
338
{
342
342
    set_XYZ(bytes + 16, pv->w);
343
343
    DISCARD(add_table(ppnt, tag, bytes, 20));
344
344
}
345
 
private void
 
345
static void
346
346
set_sample16(byte *p, floatp v)
347
347
{
348
348
    int value = (int)(v * 65535);
355
355
    p[1] = (byte)value;
356
356
}
357
357
/* Create and write a TRC curve table. */
358
 
private int write_trc_abc(cos_stream_t *, const profile_table_t *, gs_memory_t *);
359
 
private int write_trc_lmn(cos_stream_t *, const profile_table_t *, gs_memory_t *);
360
 
private profile_table_t *
 
358
static int write_trc_abc(cos_stream_t *, const profile_table_t *, gs_memory_t *);
 
359
static int write_trc_lmn(cos_stream_t *, const profile_table_t *, gs_memory_t *);
 
360
static profile_table_t *
361
361
add_trc(profile_table_t **ppnt, const char *tag, byte bytes[12],
362
362
        const gs_cie_common *pciec, cie_cache_one_step_t one_step)
363
363
{
372
372
    pnt->write_data = (const gs_cie_abc *)pciec;
373
373
    return pnt;
374
374
}
375
 
private int
 
375
static int
376
376
rgb_to_index(const profile_table_t *pnt)
377
377
{
378
378
    switch (pnt->tag[0]) {
381
381
    case 'b': default: /* others can't happen */ return 2;
382
382
    }
383
383
}
384
 
private double
 
384
static double
385
385
cache_arg(int i, int denom, const gs_range_t *range)
386
386
{
387
387
    double arg = i / (double)denom;
393
393
    return arg;
394
394
}
395
395
 
396
 
private int
 
396
static int
397
397
write_trc_abc(cos_stream_t *pcstrm, const profile_table_t *pnt,
398
398
              gs_memory_t *ignore_mem)
399
399
{
410
410
                             pabc));
411
411
    return cos_stream_add_bytes(pcstrm, samples, gx_cie_cache_size * 2);
412
412
}
413
 
private int
 
413
static int
414
414
write_trc_lmn(cos_stream_t *pcstrm, const profile_table_t *pnt,
415
415
              gs_memory_t *ignore_mem)
416
416
{
437
437
    int num_points;             /* on each axis of LUT */
438
438
    int count;                  /* total # of entries in LUT */
439
439
} icc_a2b0_t;
440
 
private int write_a2b0(cos_stream_t *, const profile_table_t *, gs_memory_t *);
441
 
private profile_table_t *
 
440
static int write_a2b0(cos_stream_t *, const profile_table_t *, gs_memory_t *);
 
441
static profile_table_t *
442
442
add_a2b0(profile_table_t **ppnt, icc_a2b0_t *pa2b, int ncomps,
443
443
         const gs_color_space *pcs)
444
444
{
476
476
    pnt->write_data = pa2b;
477
477
    return pnt;
478
478
}
479
 
private int
 
479
static int
480
480
write_a2b0(cos_stream_t *pcstrm, const profile_table_t *pnt,
481
481
           gs_memory_t *mem)
482
482
{
535
535
 
536
536
    return cos_stream_add_bytes(pcstrm, v01, 3 * 4);
537
537
}
538
 
private int
 
538
static int
539
539
pdf_convert_cie_to_iccbased(gx_device_pdf *pdev, cos_array_t *pca,
540
540
                            const gs_color_space *pcs, const char *dcsname,
541
541
                            const gs_cie_common *pciec, const gs_range *prange,