summaryrefslogtreecommitdiff
path: root/pcl/pl/plht.c
blob: 487aa713328a10b89cd04e57265b302d613b2aa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Copyright (C) 2001-2022 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
   CA 94945, U.S.A., +1(415)492-9861, for further information.
*/


/* plht.c - shared halftone resource. */
#include "stdpre.h"
#include "gstypes.h"
#include "gsmemory.h"
#include "gxtmap.h"
#include "gsstate.h"
#include "gxht.h"
#include "gxdevice.h"
#include "plht.h"

int
pl_set_pcl_halftone(gs_gstate * pgs, gs_mapping_proc transfer_proc,
                    int width, int height,
                    gs_string threshold_data, int phase_x, int phase_y)
{

    int code;
    gs_halftone ht;

    /* nothing to do for a contone device */
    if (!gx_device_must_halftone(gs_currentdevice(pgs)))
        return 0;
    code = gs_settransfer(pgs, transfer_proc);
    if (code < 0)
        return code;
    memset(&ht.rc, 0x00, sizeof(ht.rc));
    ht.type = ht_type_threshold;
    ht.objtype = HT_OBJTYPE_DEFAULT;
    ht.params.threshold.width = width;
    ht.params.threshold.height = height;
    ht.params.threshold.thresholds.data = threshold_data.data;
    ht.params.threshold.thresholds.size = threshold_data.size;
    ht.params.threshold.transfer = 0;
    ht.params.threshold.transfer_closure.proc = 0;
    code = gs_sethalftone(pgs, &ht);
    if (code < 0)
        return code;
    return gs_sethalftonephase(pgs, phase_x, phase_y);
}