~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to plug-ins/common/semi-flatten.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
/* GIMP - The GNU Image Manipulation Program
6
6
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
7
7
 *
8
 
 * This program is free software; you can redistribute it and/or modify
 
8
 * This program is free software: you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
10
 
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * the Free Software Foundation; either version 3 of the License, or
11
11
 * (at your option) any later version.
12
12
 *
13
13
 * This program is distributed in the hope that it will be useful,
16
16
 * GNU General Public License for more details.
17
17
 *
18
18
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program; if not, write to the Free Software
20
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
20
 */
22
21
 
23
22
#include "config.h"
34
33
 */
35
34
static void   query       (void);
36
35
static void   run         (const gchar      *name,
37
 
                           gint              nparams,
38
 
                           const GimpParam  *param,
39
 
                           gint             *nreturn_vals,
40
 
                           GimpParam       **return_vals);
 
36
                           gint              nparams,
 
37
                           const GimpParam  *param,
 
38
                           gint             *nreturn_vals,
 
39
                           GimpParam       **return_vals);
41
40
 
42
41
static void   semiflatten (GimpDrawable     *drawable);
43
42
 
59
58
{
60
59
  static const GimpParamDef args[] =
61
60
  {
62
 
    { GIMP_PDB_INT32,    "run-mode", "Interactive, non-interactive" },
 
61
    { GIMP_PDB_INT32,    "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
63
62
    { GIMP_PDB_IMAGE,    "image",    "Input image (unused)"         },
64
63
    { GIMP_PDB_DRAWABLE, "drawable", "Input drawable"               }
65
64
  };
66
65
 
67
66
  gimp_install_procedure (PLUG_IN_PROC,
68
 
                          N_("Replace partial transparency with the current background color"),
69
 
                          "This plugin flattens pixels in an RGBA image that "
70
 
                          "aren't completely transparent against the current "
71
 
                          "GIMP background color",
72
 
                          "Adam D. Moss (adam@foxbox.org)",
73
 
                          "Adam D. Moss (adam@foxbox.org)",
74
 
                          "27th January 1998",
75
 
                          N_("_Semi-Flatten"),
76
 
                          "RGBA",
77
 
                          GIMP_PLUGIN,
78
 
                          G_N_ELEMENTS (args), 0,
79
 
                          args, NULL);
 
67
                          N_("Replace partial transparency with the current background color"),
 
68
                          "This plugin flattens pixels in an RGBA image that "
 
69
                          "aren't completely transparent against the current "
 
70
                          "GIMP background color",
 
71
                          "Adam D. Moss (adam@foxbox.org)",
 
72
                          "Adam D. Moss (adam@foxbox.org)",
 
73
                          "27th January 1998",
 
74
                          N_("_Semi-Flatten"),
 
75
                          "RGBA",
 
76
                          GIMP_PLUGIN,
 
77
                          G_N_ELEMENTS (args), 0,
 
78
                          args, NULL);
80
79
 
81
80
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Filters/Web");
82
81
  gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Layer/Transparency/Modify");
92
91
{
93
92
  static GimpParam   values[1];
94
93
  GimpDrawable      *drawable;
95
 
  gint32             image_ID;
96
94
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;
97
 
  GimpRunMode        run_mode;
98
 
 
99
 
  run_mode = param[0].data.d_int32;
100
95
 
101
96
  *nreturn_vals = 1;
102
97
  *return_vals = values;
108
103
 
109
104
  /*  Get the specified drawable  */
110
105
  drawable = gimp_drawable_get (param[2].data.d_drawable);
111
 
  image_ID = param[1].data.d_image;
112
106
 
113
107
  if (status == GIMP_PDB_SUCCESS)
114
108
    {
115
109
      /*  Make sure that the drawable is indexed or RGB color  */
116
110
      if (gimp_drawable_is_rgb (drawable->drawable_id))
117
 
        {
118
 
          gimp_progress_init (_("Semi-Flattening"));
119
 
          gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width ()
120
 
                                       + 1));
121
 
          semiflatten (drawable);
122
 
          gimp_displays_flush ();
123
 
        }
 
111
        {
 
112
          gimp_progress_init (_("Semi-Flattening"));
 
113
          gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width ()
 
114
                                       + 1));
 
115
          semiflatten (drawable);
 
116
          gimp_displays_flush ();
 
117
        }
124
118
      else
125
 
        {
126
 
          status = GIMP_PDB_EXECUTION_ERROR;
127
 
        }
 
119
        {
 
120
          status = GIMP_PDB_EXECUTION_ERROR;
 
121
        }
128
122
    }
129
123
 
130
124
  values[0].data.d_status = status;
134
128
 
135
129
static void
136
130
semiflatten_func (const guchar *src,
137
 
                  guchar       *dest,
138
 
                  gint          bpp,
139
 
                  gpointer      data)
 
131
                  guchar       *dest,
 
132
                  gint          bpp,
 
133
                  gpointer      data)
140
134
{
141
135
  dest[0] = (src[0] * src[3]) / 255 + (bgred * (255 - src[3])) / 255;
142
136
  dest[1] = (src[1] * src[3]) / 255 + (bggreen * (255 - src[3])) / 255;