Beispiel #1
0
static void
rgb_cs_to_spotn_cm(gx_device * dev, const gs_imager_state *pis,
                                   frac r, frac g, frac b, frac out[])
{
/* TO_DO_DEVICEN  This routine needs to include the effects of the SeparationOrder array */
    xcf_device *xdev = (xcf_device *)dev;
    int n = xdev->separation_names.num_names;
    gcmmhlink_t link = xdev->rgb_icc_link;
    int i;

    if (link != NULL) {
        unsigned short in[3];
        unsigned short tmp[MAX_CHAN];
        int outn = xdev->rgb_profile->num_comps_out;

        in[0] = frac2ushort(r);
        in[1] = frac2ushort(g);
        in[2] = frac2ushort(b);

        gscms_transform_color(dev, link, &(in[0]), &(tmp[0]), 2);

        for (i = 0; i < outn; i++)
            out[i] = ushort2frac(tmp[i]);
        for (; i < n + 4; i++)
            out[i] = 0;
    } else {
        frac cmyk[4];

        color_rgb_to_cmyk(r, g, b, pis, cmyk, dev->memory);
        cmyk_cs_to_spotn_cm(dev, cmyk[0], cmyk[1], cmyk[2], cmyk[3],
                            out);
    }
}
/* Shared function between the single and buffer conversions */
static void
gsicc_nocm_transform_general(gx_device *dev, gsicc_link_t *icclink, 
                             void *inputcolor, void *outputcolor, 
                             int num_bytes_in, int num_bytes_out)
{
    /* Input data is either single byte or 2 byte color values.  The 
       color mapping procs work on frac values so we have to sandwich 
       the transformation between to and from frac conversions.  We are only
       doing at most 4 source colors here */
    nocm_link_t *link = (nocm_link_t*) icclink->link_handle;
    byte num_in = link->num_in;
    byte num_out = link->num_out;
    frac frac_in[4];
    frac frac_out[GX_DEVICE_COLOR_MAX_COMPONENTS];
    int k;

    if (num_bytes_in == 2) {
        unsigned short *data = (unsigned short *) inputcolor;
        for (k = 0; k < num_in; k++) {
            frac_in[k] = ushort2frac(data[k]);
        }
    } else {
        byte *data = (byte *) inputcolor;
        for (k = 0; k < num_in; k++) {
            frac_in[k] = byte2frac(data[k]);
        }
    }
    /* Use the device procedure */
    switch (num_in) {
        case 1:
            (link->cm_procs.map_gray)(dev, frac_in[0], frac_out);
            break;
        case 3:
            (link->cm_procs.map_rgb)(dev, link->pis, frac_in[0], frac_in[1],
                                 frac_in[2], frac_out);
            break;
        case 4:
            (link->cm_procs.map_cmyk)(dev, frac_in[0], frac_in[1], frac_in[2], 
                                 frac_in[3], frac_out);            
            break;
        default:
            break;
    }   
    if (num_bytes_out == 2) {
        unsigned short *data = (unsigned short *) outputcolor;
        for (k = 0; k < num_out; k++) {
            data[k] = frac2ushort(frac_out[k]);
        }
    } else { 
        byte *data = (byte *) outputcolor;
        for (k = 0; k < num_out; k++) {
            data[k] = frac2byte(frac_out[k]);
        }
    }
    return;
}
/* Shared function between the single and buffer conversions.  This is where
   we do the actual replacement.   For now, we make the replacement a 
   negative to show the effect of what using color replacement.  We also use
   the device procs to map to the device value.  */
static void
gsicc_rcm_transform_general(gx_device *dev, gsicc_link_t *icclink, 
                             void *inputcolor, void *outputcolor, 
                             int num_bytes_in, int num_bytes_out)
{
    /* Input data is either single byte or 2 byte color values.  */
    rcm_link_t *link = (rcm_link_t*) icclink->link_handle;
    byte num_in = link->num_in;
    byte num_out = link->num_out;
    frac frac_in[4];
    frac frac_out[GX_DEVICE_COLOR_MAX_COMPONENTS];
    int k;

    /* Make the negative for the demo.... */
    if (num_bytes_in == 2) {
        unsigned short *data = (unsigned short *) inputcolor;
        for (k = 0; k < num_in; k++) {
            frac_in[k] = frac_1 - ushort2frac(data[k]);
        }
    } else {
        byte *data = (byte *) inputcolor;
        for (k = 0; k < num_in; k++) {
            frac_in[k] = frac_1 - byte2frac(data[k]);
        }
    }
    /* Use the device procedure */
    switch (num_in) {
        case 1:
            (link->cm_procs.map_gray)(dev, frac_in[0], frac_out);
            break;
        case 3:
            (link->cm_procs.map_rgb)(dev, NULL, frac_in[0], frac_in[1],
                                 frac_in[2], frac_out);
            break;
        case 4:
            (link->cm_procs.map_cmyk)(dev, frac_in[0], frac_in[1], frac_in[2], 
                                 frac_in[3], frac_out);            
            break;
        default:
            break;
    }   
    if (num_bytes_out == 2) {
        unsigned short *data = (unsigned short *) outputcolor;
        for (k = 0; k < num_out; k++) {
            data[k] = frac2ushort(frac_out[k]);
        }
    } else { 
        byte *data = (byte *) outputcolor;
        for (k = 0; k < num_out; k++) {
            data[k] = frac2byte(frac_out[k]);
        }
    }
    return;
}
Beispiel #4
0
static void
cmyk_cs_to_spotn_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[])
{
/* TO_DO_DEVICEN  This routine needs to include the effects of the SeparationOrder array */
    xcf_device *xdev = (xcf_device *)dev;
    int n = xdev->separation_names.num_names;

    gcmmhlink_t link = xdev->cmyk_icc_link;
    int i;

    if (link != NULL) {
        unsigned short in[4];
        unsigned short tmp[MAX_CHAN];
        int outn = xdev->cmyk_profile->num_comps_out;

        in[0] = frac2ushort(c);
        in[1] = frac2ushort(m);
        in[2] = frac2ushort(y);
        in[3] = frac2ushort(k);

        gscms_transform_color(dev, link, &(in[0]), &(tmp[0]), 2);
        for (i = 0; i < outn; i++)
            out[i] = ushort2frac(tmp[i]);
        for (; i < n + 4; i++)
            out[i] = 0;

    } else {
        /* If no profile given, assume CMYK */
        out[0] = c;
        out[1] = m;
        out[2] = y;
        out[3] = k;
        for(i = 0; i < n; i++)			/* Clear spot colors */
            out[4 + i] = 0;
    }
}