Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/psi/zfimscale.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* $Id: zfimscale.c 6651 2006-03-13 16:18:19Z raph $ */
18
19
/* This is the ps interpreter interface to the image mask interpolating
20
   filter. */
21
22
#include "memory_.h"
23
#include "ghost.h"
24
#include "oper.h"
25
#include "gsstruct.h"
26
#include "ialloc.h"
27
#include "idict.h"
28
#include "stream.h"
29
#include "strimpl.h"
30
#include "ifilter.h"
31
#include "idparam.h"
32
#include "sisparam.h"
33
#include "simscale.h"
34
35
/* <source> <dict> imscale/filter <file> */
36
37
static int
38
z_imscale_d(i_ctx_t * i_ctx_p)
39
0
{
40
0
    os_ptr op = osp;   /* i_ctx_p->op_stack.stack.p defined in osstack.h */
41
0
    int width, height;
42
0
    stream_imscale_state state;
43
44
0
    check_op(2);
45
    /* extract the key from the parameter dictionary */
46
0
    check_type(*op, t_dictionary);
47
0
    check_dict_read(*op);
48
0
    if (dict_int_param(op, "Width", 0, 1<<24, -1, &width) < 0)
49
0
        return_error(gs_error_rangecheck);
50
0
    if (dict_int_param(op, "Height", 0, 1<<24, -1, &height) < 0)
51
0
        return_error(gs_error_rangecheck);
52
53
0
    state.params.spp_decode = 1;
54
0
    state.params.spp_interp = 1;
55
0
    state.params.BitsPerComponentIn = 1;
56
0
    state.params.MaxValueIn = 1;
57
0
    state.params.WidthIn = width;
58
0
    state.params.HeightIn = height;
59
0
    state.params.BitsPerComponentOut = 1;
60
0
    state.params.MaxValueOut = 1;
61
0
    state.params.WidthOut = width << 2;
62
0
    state.params.HeightOut = height << 2;
63
64
    /* we pass npop=0, since we've no arguments left to consume */
65
    /* we pass 0 instead of the usual rspace(sop) will allocate storage for
66
       filter state from the same memory pool as the stream it's coding. this
67
       causes no trouble because we maintain no pointers */
68
0
    return filter_read(i_ctx_p, 0, &s_imscale_template,
69
0
                       (stream_state *) & state, 0);
70
0
}
71
72
/* Match the above routines to their postscript filter names.
73
   This is how our static routines get called externally. */
74
const op_def zfimscale_op_defs[] = {
75
    op_def_begin_filter(),
76
    {"2ImscaleDecode", z_imscale_d},
77
    op_def_end(0)
78
};