mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 12:02:32 +00:00
c1ab39a5e8
2003-05-08 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawable.[ch]: removed gimp_drawable_offsets(). * app/core/gimpitem.[ch]: added gimp_item_offsets(). * app/core/gimpdrawable-blend.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpdrawable-histogram.c * app/core/gimpedit.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-mask-select.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-pick-color.c * app/core/gimpimage-preview.c * app/core/gimpimage-projection.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/paint/gimppaintcore.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpselectioneditor.c * app/widgets/gimptoolbox.c * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb: changed accordingly. * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c: regenerated.
72 lines
2.1 KiB
C
72 lines
2.1 KiB
C
/* The GIMP -- an image manipulation program
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
*
|
|
* gimphistogram module Copyright (C) 1999 Jay Cox <jaycox@earthlink.net>
|
|
*
|
|
* 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
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <glib-object.h>
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
#include "core-types.h"
|
|
|
|
#include "base/gimphistogram.h"
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "gimpdrawable.h"
|
|
#include "gimpimage.h"
|
|
|
|
|
|
void
|
|
gimp_drawable_calculate_histogram (GimpDrawable *drawable,
|
|
GimpHistogram *histogram)
|
|
{
|
|
PixelRegion region;
|
|
PixelRegion mask;
|
|
gint x1, y1, x2, y2;
|
|
gint off_x, off_y;
|
|
gboolean no_mask;
|
|
|
|
g_return_if_fail (drawable != NULL);
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
g_return_if_fail (histogram != NULL);
|
|
|
|
no_mask = (gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) == FALSE);
|
|
pixel_region_init (®ion, gimp_drawable_data (drawable), x1, y1,
|
|
(x2 - x1), (y2 - y1), FALSE);
|
|
|
|
if (! no_mask)
|
|
{
|
|
GimpChannel *sel_mask;
|
|
GimpImage *gimage;
|
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
sel_mask = gimp_image_get_mask (gimage);
|
|
|
|
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
|
pixel_region_init (&mask, gimp_drawable_data (GIMP_DRAWABLE (sel_mask)),
|
|
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
|
|
gimp_histogram_calculate (histogram, ®ion, &mask);
|
|
}
|
|
else
|
|
{
|
|
gimp_histogram_calculate (histogram, ®ion, NULL);
|
|
}
|
|
}
|