File: rasterizable.pdb

package info (click to toggle)
gimp 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 222,880 kB
  • sloc: ansic: 870,914; python: 10,965; lisp: 10,857; cpp: 7,355; perl: 4,536; sh: 1,753; xml: 972; yacc: 609; lex: 348; javascript: 150; makefile: 42
file content (153 lines) | stat: -rw-r--r-- 4,402 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# GIMP - The GNU Image Manipulation Program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis

# Rasterizable PDB API
# Copyright (C) 2025 Jehan

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.


sub rasterizable_rasterize {
    $blurb = 'Rasterize the object.';

    $help = <<'HELP';
This procedure makes the item behave like a typical raster layer.


Note that the source information (text contents and properties for a
text layer, source file for a link layer, path and render properties for
a vector layer, etc.) are not actually discarded, and it is possible to
retrieve the original behavior with [method@Gimp.Rasterizable.restore].
HELP

    &jehan_pdb_misc('2025', '3.2');

    @inargs = (
        { name => 'item', type => 'rasterizable',
          desc => 'The rasterizable item' }
    );

    %invoke = (
        code => <<'CODE'
{
  if (! gimp_rasterizable_is_rasterized (GIMP_RASTERIZABLE (item)))
    {
      gimp_rasterizable_rasterize (GIMP_RASTERIZABLE (item), TRUE);
    }
  else
    {
      g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
                   _("This item has already been rasterized."));
      success = FALSE;
    }
}
CODE
    );
}

sub rasterizable_restore {
    $blurb = 'Revert the rasterization of @item.';

    $help = <<'HELP';
Restore the information making the item non-destructive, such as text
contents and properties of a text layer, source file of a link layer,
path and render properties of a vector layer, etc.

This item won't behave anymore like a raster item. In particular, it
will prevent direct modification of its pixels and will be rendered when
its properties are updated.
HELP

    &jehan_pdb_misc('2025', '3.2');

    @inargs = (
        { name => 'item', type => 'rasterizable',
          desc => 'The rasterizable item' }
    );

    %invoke = (
        code => <<'CODE'
{
  if (gimp_rasterizable_is_rasterized (GIMP_RASTERIZABLE (item)))
    {
      gimp_rasterizable_restore (GIMP_RASTERIZABLE (item));
    }
  else
    {
      g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
                   _("This item has not been rasterized."));
      success = FALSE;
    }
}
CODE
    );
}

sub rasterizable_is_rasterized {
    $blurb = 'Return whether @item has been rasterized.';

    $help = <<'HELP';
This procedure returns %TRUE if the specified @item has been previously
rasterized. In this case, you should treat this @item as the generic
raster variant.


For instance, a [class@Gimp.TextLayer] object implements the
%GimpRasterizable interface. If a text layer instance were to return
%TRUE, you should only consider its rendering as returned by
[method@Gimp.Drawable.get_buffer].


On the other hand, if this returned %FALSE, depending on your intents,
you may prefer to use the text contents and its properties with the
various procedures provided by the [class@Gimp.TextLayer] class interface.
HELP

    &jehan_pdb_misc('2025', '3.2');

    @inargs = (
        { name => 'item', type => 'rasterizable',
          desc => 'The rasterizable item' }
    );
    @outargs = (
	{ name => 'is_rasterized', type => 'boolean',
	  desc => 'TRUE if @item is rasterized' }
    );


    %invoke = (
        code => <<'CODE'
{
  is_rasterized = gimp_rasterizable_is_rasterized (GIMP_RASTERIZABLE (item));
}
CODE
    );
}

@headers = qw("core/gimprasterizable.h"
              "gimppdberror.h"
              "gimp-intl.h");

@procs = qw(rasterizable_rasterize
            rasterizable_restore
            rasterizable_is_rasterized);

%exports = (app => [@procs], lib => [@procs]);

$desc = 'Rasterizable procedures';
$doc_title = 'gimprasterizable';
$doc_short_desc = 'Functions for querying and manipulating rasterizable items.';
$doc_long_desc = 'Functions for querying and manipulating rasterizable items.';

1;