gimpdrawable-invert.c 1.74 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * 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 2 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, write to the Free Software
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17
 */
Sven Neumann's avatar
Sven Neumann committed
18

19 20
#include "config.h"

21
#include <glib-object.h>
Sven Neumann's avatar
Sven Neumann committed
22

Michael Natterer's avatar
Michael Natterer committed
23
#include "core-types.h"
Sven Neumann's avatar
Sven Neumann committed
24

Michael Natterer's avatar
Michael Natterer committed
25
#include "base/gimplut.h"
26
#include "base/lut-funcs.h"
Michael Natterer's avatar
Michael Natterer committed
27 28 29
#include "base/pixel-processor.h"
#include "base/pixel-region.h"

30
#include "gimpdrawable.h"
31
#include "gimpdrawable-invert.h"
32

Elliot Lee's avatar
Elliot Lee committed
33

34
void
35
gimp_drawable_invert (GimpDrawable *drawable)
Elliot Lee's avatar
Elliot Lee committed
36
{
37 38 39
  PixelRegion  srcPR, destPR;
  gint         x1, y1, x2, y2;
  GimpLut     *lut;
40

41
  lut = invert_lut_new (gimp_drawable_bytes (drawable));
Elliot Lee's avatar
Elliot Lee committed
42

43 44
  gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
  pixel_region_init (&srcPR, gimp_drawable_data (drawable),
45
		     x1, y1, (x2 - x1), (y2 - y1), FALSE);
46
  pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
47
		     x1, y1, (x2 - x1), (y2 - y1), TRUE);
Elliot Lee's avatar
Elliot Lee committed
48

49 50
  pixel_regions_process_parallel ((p_func)gimp_lut_process, lut, 
				  2, &srcPR, &destPR);
51

52
  gimp_lut_free (lut);
Elliot Lee's avatar
Elliot Lee committed
53

54
  gimp_drawable_merge_shadow (drawable, TRUE);
55

Michael Natterer's avatar
Michael Natterer committed
56 57 58
  gimp_drawable_update (drawable,
			x1, y1,
			(x2 - x1), (y2 - y1));
Elliot Lee's avatar
Elliot Lee committed
59
}