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

« back to all changes in this revision

Viewing changes to app/gegl/gimpoperationreplacemode.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:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * gimpoperationreplacemode.c
 
5
 * Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include <gegl-plugin.h>
 
25
 
 
26
#include "gimp-gegl-types.h"
 
27
 
 
28
#include "gimpoperationreplacemode.h"
 
29
 
 
30
 
 
31
static gboolean gimp_operation_replace_mode_process (GeglOperation       *operation,
 
32
                                                     void                *in_buf,
 
33
                                                     void                *aux_buf,
 
34
                                                     void                *out_buf,
 
35
                                                     glong                samples,
 
36
                                                     const GeglRectangle *roi,
 
37
                                                     gint                 level);
 
38
 
 
39
 
 
40
G_DEFINE_TYPE (GimpOperationReplaceMode, gimp_operation_replace_mode,
 
41
               GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
 
42
 
 
43
 
 
44
static void
 
45
gimp_operation_replace_mode_class_init (GimpOperationReplaceModeClass *klass)
 
46
{
 
47
  GeglOperationClass              *operation_class;
 
48
  GeglOperationPointComposerClass *point_class;
 
49
 
 
50
  operation_class = GEGL_OPERATION_CLASS (klass);
 
51
  point_class     = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
 
52
 
 
53
  gegl_operation_class_set_keys (operation_class,
 
54
           "name"       , "gimp:replace-mode",
 
55
           "description", "GIMP replace mode operation",
 
56
           NULL);
 
57
 
 
58
  point_class->process         = gimp_operation_replace_mode_process;
 
59
}
 
60
 
 
61
static void
 
62
gimp_operation_replace_mode_init (GimpOperationReplaceMode *self)
 
63
{
 
64
}
 
65
 
 
66
static gboolean
 
67
gimp_operation_replace_mode_process (GeglOperation       *operation,
 
68
                                     void                *in_buf,
 
69
                                     void                *aux_buf,
 
70
                                     void                *out_buf,
 
71
                                     glong                samples,
 
72
                                     const GeglRectangle *roi,
 
73
                                     gint                 level)
 
74
{
 
75
  gfloat *in    = in_buf;
 
76
  gfloat *layer = aux_buf;
 
77
  gfloat *out   = out_buf;
 
78
 
 
79
  while (samples--)
 
80
    {
 
81
      out[RED]   = in[RED];
 
82
      out[GREEN] = in[GREEN];
 
83
      out[BLUE]  = in[BLUE];
 
84
      out[ALPHA] = in[ALPHA];
 
85
 
 
86
      in    += 4;
 
87
      layer += 4;
 
88
      out   += 4;
 
89
    }
 
90
 
 
91
  return TRUE;
 
92
}