2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-11-01 10:39:34 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-11-01 10:39:34 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-11-01 10:39:34 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-11-01 10:39:34 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2003-11-01 10:39:34 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2019-07-31 16:16:21 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2003-11-01 10:39:34 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2018-05-11 23:56:08 +08:00
|
|
|
#include "core/gimpasync.h"
|
2003-11-01 10:39:34 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2004-12-11 07:07:21 +08:00
|
|
|
#include "core/gimpdrawable-histogram.h"
|
2012-03-25 05:29:53 +08:00
|
|
|
#include "core/gimphistogram.h"
|
2003-11-01 10:39:34 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2004-07-08 08:09:41 +08:00
|
|
|
#include "gimpdocked.h"
|
2003-11-01 10:39:34 +08:00
|
|
|
#include "gimphelp-ids.h"
|
|
|
|
#include "gimphistogrambox.h"
|
|
|
|
#include "gimphistogrameditor.h"
|
|
|
|
#include "gimphistogramview.h"
|
2018-01-06 10:12:23 +08:00
|
|
|
#include "gimppropwidgets.h"
|
2007-05-25 19:42:28 +08:00
|
|
|
#include "gimpsessioninfo-aux.h"
|
2003-11-01 10:39:34 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
PROP_TRC
|
2016-12-27 00:32:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-10-26 16:16:25 +08:00
|
|
|
static void gimp_histogram_editor_docked_iface_init (GimpDockedInterface *iface);
|
2005-12-20 06:37:49 +08:00
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
static void gimp_histogram_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_histogram_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2007-10-26 16:16:25 +08:00
|
|
|
static void gimp_histogram_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info);
|
|
|
|
static GList * gimp_histogram_editor_get_aux_info (GimpDocked *docked);
|
2004-07-08 20:04:15 +08:00
|
|
|
|
2007-10-26 16:16:25 +08:00
|
|
|
static void gimp_histogram_editor_set_image (GimpImageEditor *editor,
|
|
|
|
GimpImage *image);
|
|
|
|
static void gimp_histogram_editor_layer_changed (GimpImage *image,
|
|
|
|
GimpHistogramEditor *editor);
|
2007-11-15 18:26:25 +08:00
|
|
|
static void gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
|
|
|
const GParamSpec *pspec);
|
2016-12-27 00:32:17 +08:00
|
|
|
static void gimp_histogram_editor_buffer_update (GimpHistogramEditor *editor,
|
|
|
|
const GParamSpec *pspec);
|
2007-10-26 16:16:25 +08:00
|
|
|
static void gimp_histogram_editor_update (GimpHistogramEditor *editor);
|
2004-07-08 20:04:15 +08:00
|
|
|
|
2007-10-26 16:16:25 +08:00
|
|
|
static gboolean gimp_histogram_editor_idle_update (GimpHistogramEditor *editor);
|
|
|
|
static gboolean gimp_histogram_menu_sensitivity (gint value,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_histogram_editor_menu_update (GimpHistogramEditor *editor);
|
|
|
|
static void gimp_histogram_editor_name_update (GimpHistogramEditor *editor);
|
|
|
|
static void gimp_histogram_editor_info_update (GimpHistogramEditor *editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2010-10-21 19:15:52 +08:00
|
|
|
static gboolean gimp_histogram_editor_view_draw (GimpHistogramEditor *editor,
|
|
|
|
cairo_t *cr);
|
2005-09-28 08:31:46 +08:00
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpHistogramEditor, gimp_histogram_editor,
|
|
|
|
GIMP_TYPE_IMAGE_EDITOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_histogram_editor_docked_iface_init))
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
#define parent_class gimp_histogram_editor_parent_class
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2005-12-20 06:37:49 +08:00
|
|
|
static GimpDockedInterface *parent_docked_iface = NULL;
|
2003-11-01 10:39:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-07-22 04:27:33 +08:00
|
|
|
gimp_histogram_editor_class_init (GimpHistogramEditorClass *klass)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2016-12-27 00:32:17 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2004-07-08 20:04:15 +08:00
|
|
|
GimpImageEditorClass *image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
object_class->set_property = gimp_histogram_editor_set_property;
|
|
|
|
object_class->get_property = gimp_histogram_editor_get_property;
|
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
image_editor_class->set_image = gimp_histogram_editor_set_image;
|
2016-12-27 00:32:17 +08:00
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_TRC,
|
|
|
|
g_param_spec_enum ("trc",
|
2019-03-15 00:47:39 +08:00
|
|
|
_("Linear/Perceptual"),
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
NULL,
|
|
|
|
GIMP_TYPE_TRC_TYPE,
|
|
|
|
GIMP_TRC_LINEAR,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_editor_init (GimpHistogramEditor *editor)
|
|
|
|
{
|
|
|
|
GimpHistogramView *view;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *menu;
|
2018-05-04 08:19:39 +08:00
|
|
|
GtkWidget *grid;
|
2003-11-01 10:39:34 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
const gchar *gimp_histogram_editor_labels[] =
|
|
|
|
{
|
|
|
|
N_("Mean:"),
|
2005-08-23 07:39:12 +08:00
|
|
|
N_("Std dev:"),
|
2003-11-01 10:39:34 +08:00
|
|
|
N_("Median:"),
|
|
|
|
N_("Pixels:"),
|
|
|
|
N_("Count:"),
|
|
|
|
N_("Percentile:")
|
|
|
|
};
|
|
|
|
|
2017-08-05 23:15:31 +08:00
|
|
|
editor->box = gimp_histogram_box_new ();
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2005-05-27 19:40:06 +08:00
|
|
|
gimp_editor_set_show_name (GIMP_EDITOR (editor), TRUE);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
|
|
|
view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
2018-01-06 10:12:23 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2004-04-18 23:12:42 +08:00
|
|
|
editor->menu = menu = gimp_prop_enum_combo_box_new (G_OBJECT (view),
|
|
|
|
"histogram-channel",
|
|
|
|
0, 0);
|
2014-05-08 03:30:06 +08:00
|
|
|
gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (menu),
|
|
|
|
"gimp-channel");
|
2005-03-01 07:27:12 +08:00
|
|
|
gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (editor->menu),
|
|
|
|
gimp_histogram_menu_sensitivity,
|
|
|
|
editor, NULL);
|
2004-06-13 01:30:28 +08:00
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (editor->menu),
|
|
|
|
view->channel);
|
2004-02-21 20:25:09 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
gimp_help_set_help_data (editor->menu,
|
|
|
|
_("Histogram channel"), NULL);
|
|
|
|
|
2014-05-08 03:30:06 +08:00
|
|
|
menu = gimp_prop_enum_icon_box_new (G_OBJECT (view),
|
|
|
|
"histogram-scale", "gimp-histogram",
|
|
|
|
0, 0);
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
|
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
menu = gimp_prop_enum_icon_box_new (G_OBJECT (editor), "trc",
|
|
|
|
"gimp-color-space",
|
|
|
|
-1, -1);
|
2018-01-06 10:12:23 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
|
2016-12-27 00:32:17 +08:00
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), editor->box, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (GTK_WIDGET (editor->box));
|
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect_swapped (view, "range-changed",
|
2004-07-08 20:04:15 +08:00
|
|
|
G_CALLBACK (gimp_histogram_editor_info_update),
|
|
|
|
editor);
|
|
|
|
g_signal_connect_swapped (view, "notify::histogram-channel",
|
|
|
|
G_CALLBACK (gimp_histogram_editor_info_update),
|
|
|
|
editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2010-10-21 19:15:52 +08:00
|
|
|
g_signal_connect_swapped (view, "draw",
|
|
|
|
G_CALLBACK (gimp_histogram_editor_view_draw),
|
2005-09-28 08:31:46 +08:00
|
|
|
editor);
|
|
|
|
|
2018-05-04 08:19:39 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), grid, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
gint x = (i / 3) * 2;
|
|
|
|
gint y = (i % 3);
|
|
|
|
|
|
|
|
label = gtk_label_new (gettext (gimp_histogram_editor_labels[i]));
|
2005-05-27 19:40:06 +08:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
2005-07-19 17:44:46 +08:00
|
|
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
2005-05-27 19:40:06 +08:00
|
|
|
-1);
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
|
2018-05-04 08:19:39 +08:00
|
|
|
gtk_widget_set_hexpand (label, TRUE);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), label, x, y, 1, 1);
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-07-19 17:44:46 +08:00
|
|
|
editor->labels[i] =
|
|
|
|
label = g_object_new (GTK_TYPE_LABEL,
|
|
|
|
"xalign", 0.0,
|
|
|
|
"yalign", 0.5,
|
|
|
|
"width-chars", i > 2 ? 9 : 5,
|
|
|
|
NULL);
|
2005-05-27 19:40:06 +08:00
|
|
|
gimp_label_set_attributes (GTK_LABEL (editor->labels[i]),
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
-1);
|
2018-05-04 08:19:39 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), label, x + 1, y, 1, 1);
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-08 08:09:41 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_docked_iface_init (GimpDockedInterface *docked_iface)
|
|
|
|
{
|
|
|
|
parent_docked_iface = g_type_interface_peek_parent (docked_iface);
|
|
|
|
|
2005-06-05 06:49:53 +08:00
|
|
|
if (! parent_docked_iface)
|
|
|
|
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
|
|
|
|
|
2004-07-08 08:09:41 +08:00
|
|
|
docked_iface->set_aux_info = gimp_histogram_editor_set_aux_info;
|
|
|
|
docked_iface->get_aux_info = gimp_histogram_editor_get_aux_info;
|
|
|
|
}
|
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (object);
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
case PROP_TRC:
|
|
|
|
editor->trc = g_value_get_enum (value);
|
2016-12-27 00:32:17 +08:00
|
|
|
|
|
|
|
if (editor->histogram)
|
|
|
|
{
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->histogram);
|
2016-12-27 00:32:17 +08:00
|
|
|
gimp_histogram_view_set_histogram (view, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (editor->bg_histogram)
|
|
|
|
{
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->bg_histogram);
|
2016-12-27 00:32:17 +08:00
|
|
|
gimp_histogram_view_set_background (view, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_histogram_editor_update (editor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
case PROP_TRC:
|
|
|
|
g_value_set_enum (value, editor->trc);
|
2016-12-27 00:32:17 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-08 08:09:41 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_set_aux_info (GimpDocked *docked,
|
|
|
|
GList *aux_info)
|
|
|
|
{
|
|
|
|
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (docked);
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
2005-06-05 06:49:53 +08:00
|
|
|
parent_docked_iface->set_aux_info (docked, aux_info);
|
2004-07-08 08:09:41 +08:00
|
|
|
|
|
|
|
gimp_session_info_aux_set_props (G_OBJECT (view), aux_info,
|
|
|
|
"histogram-channel",
|
|
|
|
"histogram-scale",
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
|
|
|
gimp_histogram_editor_get_aux_info (GimpDocked *docked)
|
|
|
|
{
|
|
|
|
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (docked);
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
GList *aux_info;
|
|
|
|
|
2005-06-05 06:49:53 +08:00
|
|
|
aux_info = parent_docked_iface->get_aux_info (docked);
|
2004-07-08 08:09:41 +08:00
|
|
|
|
2005-06-05 06:49:53 +08:00
|
|
|
return g_list_concat (aux_info,
|
|
|
|
gimp_session_info_aux_new_from_props (G_OBJECT (view),
|
|
|
|
"histogram-channel",
|
|
|
|
"histogram-scale",
|
|
|
|
NULL));
|
2004-07-08 08:09:41 +08:00
|
|
|
}
|
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2004-07-08 20:04:15 +08:00
|
|
|
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (image_editor);
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image_editor->image)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
|
|
|
if (editor->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (editor->idle_id);
|
|
|
|
editor->idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2019-01-05 04:13:43 +08:00
|
|
|
editor->update_pending = FALSE;
|
|
|
|
|
2012-05-14 07:44:41 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (image_editor->image,
|
|
|
|
gimp_histogram_editor_update,
|
|
|
|
editor);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (image_editor->image,
|
2003-11-01 10:39:34 +08:00
|
|
|
gimp_histogram_editor_layer_changed,
|
|
|
|
editor);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (image_editor->image,
|
2003-11-01 21:58:06 +08:00
|
|
|
gimp_histogram_editor_menu_update,
|
|
|
|
editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2008-07-22 16:53:40 +08:00
|
|
|
if (editor->histogram)
|
|
|
|
{
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->histogram);
|
2008-07-22 16:53:40 +08:00
|
|
|
gimp_histogram_view_set_histogram (view, NULL);
|
|
|
|
}
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2008-07-22 16:53:40 +08:00
|
|
|
if (editor->bg_histogram)
|
|
|
|
{
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->bg_histogram);
|
2008-07-22 16:53:40 +08:00
|
|
|
gimp_histogram_view_set_background (view, NULL);
|
|
|
|
}
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, image);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_connect_object (image, "mode-changed",
|
2003-11-01 21:58:06 +08:00
|
|
|
G_CALLBACK (gimp_histogram_editor_menu_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2020-03-26 07:33:11 +08:00
|
|
|
g_signal_connect_object (image, "selected-layers-changed",
|
2003-11-01 21:58:06 +08:00
|
|
|
G_CALLBACK (gimp_histogram_editor_layer_changed),
|
|
|
|
editor, 0);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_signal_connect_object (image, "mask-changed",
|
2004-12-11 07:07:21 +08:00
|
|
|
G_CALLBACK (gimp_histogram_editor_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
2003-11-09 06:48:25 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_histogram_editor_layer_changed (image, editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2004-09-25 20:48:41 +08:00
|
|
|
gimp_histogram_editor_new (void)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2004-09-25 20:48:41 +08:00
|
|
|
return g_object_new (GIMP_TYPE_HISTOGRAM_EDITOR, NULL);
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_histogram_editor_layer_changed (GimpImage *image,
|
2003-11-01 10:39:34 +08:00
|
|
|
GimpHistogramEditor *editor)
|
|
|
|
{
|
|
|
|
if (editor->drawable)
|
|
|
|
{
|
2016-12-27 00:32:17 +08:00
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
|
|
|
if (editor->histogram)
|
2007-11-15 18:26:25 +08:00
|
|
|
{
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->histogram);
|
2016-12-27 00:32:17 +08:00
|
|
|
gimp_histogram_view_set_histogram (view, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (editor->bg_histogram)
|
|
|
|
{
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->bg_histogram);
|
2007-11-15 18:26:25 +08:00
|
|
|
gimp_histogram_view_set_background (view, NULL);
|
|
|
|
}
|
|
|
|
|
2005-05-27 19:48:50 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->drawable,
|
|
|
|
gimp_histogram_editor_name_update,
|
|
|
|
editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->drawable,
|
2003-11-03 07:31:26 +08:00
|
|
|
gimp_histogram_editor_menu_update,
|
2003-11-01 21:58:06 +08:00
|
|
|
editor);
|
|
|
|
g_signal_handlers_disconnect_by_func (editor->drawable,
|
2003-11-03 07:31:26 +08:00
|
|
|
gimp_histogram_editor_update,
|
2003-11-01 10:39:34 +08:00
|
|
|
editor);
|
2016-12-27 00:32:17 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->drawable,
|
|
|
|
gimp_histogram_editor_buffer_update,
|
|
|
|
editor);
|
2007-11-15 18:26:25 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (editor->drawable,
|
|
|
|
gimp_histogram_editor_frozen_update,
|
|
|
|
editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
editor->drawable = NULL;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image)
|
|
|
|
editor->drawable = (GimpDrawable *) gimp_image_get_active_layer (image);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2003-11-01 21:58:06 +08:00
|
|
|
gimp_histogram_editor_menu_update (editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2003-11-01 21:58:06 +08:00
|
|
|
if (editor->drawable)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2007-11-15 18:26:25 +08:00
|
|
|
g_signal_connect_object (editor->drawable, "notify::frozen",
|
|
|
|
G_CALLBACK (gimp_histogram_editor_frozen_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2016-12-27 00:32:17 +08:00
|
|
|
g_signal_connect_object (editor->drawable, "notify::buffer",
|
|
|
|
G_CALLBACK (gimp_histogram_editor_buffer_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2007-10-26 16:16:25 +08:00
|
|
|
g_signal_connect_object (editor->drawable, "update",
|
2003-11-03 07:31:26 +08:00
|
|
|
G_CALLBACK (gimp_histogram_editor_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2005-05-27 19:48:50 +08:00
|
|
|
g_signal_connect_object (editor->drawable, "alpha-changed",
|
2003-11-01 21:58:06 +08:00
|
|
|
G_CALLBACK (gimp_histogram_editor_menu_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2005-05-27 19:48:50 +08:00
|
|
|
g_signal_connect_object (editor->drawable, "name-changed",
|
|
|
|
G_CALLBACK (gimp_histogram_editor_name_update),
|
|
|
|
editor, G_CONNECT_SWAPPED);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
gimp_histogram_editor_buffer_update (editor, NULL);
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
2005-05-27 19:40:06 +08:00
|
|
|
else if (editor->histogram)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2018-02-22 00:02:07 +08:00
|
|
|
editor->recompute = TRUE;
|
2005-09-28 08:31:46 +08:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (editor->box));
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
2005-07-19 17:44:46 +08:00
|
|
|
gimp_histogram_editor_info_update (editor);
|
2005-05-27 19:48:50 +08:00
|
|
|
gimp_histogram_editor_name_update (editor);
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
2018-05-11 23:56:08 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_calculate_async_callback (GimpAsync *async,
|
|
|
|
GimpHistogramEditor *editor)
|
|
|
|
{
|
2019-01-04 21:10:55 +08:00
|
|
|
editor->calculate_async = NULL;
|
|
|
|
|
2019-01-05 04:13:43 +08:00
|
|
|
if (gimp_async_is_finished (async) && editor->histogram)
|
|
|
|
{
|
|
|
|
if (editor->bg_pending)
|
|
|
|
{
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
|
|
|
editor->bg_histogram = gimp_histogram_duplicate (editor->histogram);
|
|
|
|
|
|
|
|
gimp_histogram_view_set_background (view, editor->bg_histogram);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_histogram_editor_info_update (editor);
|
|
|
|
}
|
|
|
|
|
|
|
|
editor->bg_pending = FALSE;
|
|
|
|
|
2019-01-05 04:30:25 +08:00
|
|
|
if (editor->update_pending)
|
2019-01-05 04:13:43 +08:00
|
|
|
gimp_histogram_editor_update (editor);
|
2018-05-11 23:56:08 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 17:29:35 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_histogram_editor_validate (GimpHistogramEditor *editor)
|
|
|
|
{
|
2018-02-22 00:02:07 +08:00
|
|
|
if (editor->recompute || ! editor->histogram)
|
2008-07-22 17:29:35 +08:00
|
|
|
{
|
2018-05-12 21:23:40 +08:00
|
|
|
if (editor->drawable &&
|
|
|
|
/* avoid calculating the histogram of a detached layer. this can
|
|
|
|
* happen during gimp_image_remove_layer(), as a result of a pending
|
|
|
|
* "expose-event" signal (handled in
|
|
|
|
* gimp_histogram_editor_view_expose()) executed through
|
|
|
|
* gtk_tree_view_clamp_node_visible(), as a result of the
|
|
|
|
* GimpLayerTreeView in the Layers dialog receiving the image's
|
2020-03-26 07:33:11 +08:00
|
|
|
* "selected-layers-changed" signal before us. See bug #795716,
|
2018-05-12 21:23:40 +08:00
|
|
|
* comment 6.
|
|
|
|
*/
|
|
|
|
gimp_item_is_attached (GIMP_ITEM (editor->drawable)))
|
2016-12-27 00:32:17 +08:00
|
|
|
{
|
2018-05-11 23:56:08 +08:00
|
|
|
GimpAsync *async;
|
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
if (! editor->histogram)
|
|
|
|
{
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
editor->histogram = gimp_histogram_new (editor->trc);
|
2016-12-27 00:32:17 +08:00
|
|
|
|
2019-10-22 21:08:25 +08:00
|
|
|
gimp_histogram_clear_values (
|
|
|
|
editor->histogram,
|
|
|
|
babl_format_get_n_components (
|
|
|
|
gimp_drawable_get_format (editor->drawable)));
|
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
gimp_histogram_view_set_histogram (view, editor->histogram);
|
|
|
|
}
|
|
|
|
|
2018-05-11 23:56:08 +08:00
|
|
|
async = gimp_drawable_calculate_histogram_async (editor->drawable,
|
|
|
|
editor->histogram,
|
|
|
|
TRUE);
|
|
|
|
|
2019-01-04 21:10:55 +08:00
|
|
|
editor->calculate_async = async;
|
|
|
|
|
2018-05-11 23:56:08 +08:00
|
|
|
gimp_async_add_callback (
|
|
|
|
async,
|
|
|
|
(GimpAsyncCallback) gimp_histogram_editor_calculate_async_callback,
|
|
|
|
editor);
|
|
|
|
|
|
|
|
g_object_unref (async);
|
2016-12-27 00:32:17 +08:00
|
|
|
}
|
2018-02-22 00:02:07 +08:00
|
|
|
else if (editor->histogram)
|
2016-12-27 00:32:17 +08:00
|
|
|
{
|
2019-10-22 21:08:25 +08:00
|
|
|
gimp_histogram_clear_values (editor->histogram, 0);
|
2018-05-11 23:56:08 +08:00
|
|
|
|
|
|
|
gimp_histogram_editor_info_update (editor);
|
2016-12-27 00:32:17 +08:00
|
|
|
}
|
2008-07-22 17:29:35 +08:00
|
|
|
|
2018-02-22 00:02:07 +08:00
|
|
|
editor->recompute = FALSE;
|
2018-05-14 03:12:23 +08:00
|
|
|
|
|
|
|
if (editor->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (editor->idle_id);
|
|
|
|
editor->idle_id = 0;
|
|
|
|
}
|
2008-07-22 17:29:35 +08:00
|
|
|
}
|
|
|
|
|
2018-02-22 00:02:07 +08:00
|
|
|
return (editor->histogram != NULL);
|
2008-07-22 17:29:35 +08:00
|
|
|
}
|
|
|
|
|
2007-11-15 18:26:25 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
|
|
|
const GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
|
|
|
if (gimp_viewable_preview_is_frozen (GIMP_VIEWABLE (editor->drawable)))
|
|
|
|
{
|
2008-08-13 03:37:09 +08:00
|
|
|
/* Only do the background histogram if the histogram is visible.
|
|
|
|
* This is a workaround for the fact that recalculating the
|
|
|
|
* histogram is expensive and that it is only validated when it
|
|
|
|
* is shown. So don't slow down painting by doing something that
|
|
|
|
* is not even seen by the user.
|
|
|
|
*/
|
2009-10-18 02:20:39 +08:00
|
|
|
if (! editor->bg_histogram &&
|
|
|
|
gtk_widget_is_drawable (GTK_WIDGET (editor)))
|
2007-11-15 18:26:25 +08:00
|
|
|
{
|
2019-01-05 04:13:43 +08:00
|
|
|
if (editor->idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (editor->idle_id);
|
2007-11-15 18:26:25 +08:00
|
|
|
|
2019-01-05 04:13:43 +08:00
|
|
|
gimp_histogram_editor_idle_update (editor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_histogram_editor_validate (editor))
|
|
|
|
{
|
|
|
|
if (editor->calculate_async)
|
|
|
|
{
|
|
|
|
editor->bg_pending = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
editor->bg_histogram = gimp_histogram_duplicate (
|
|
|
|
editor->histogram);
|
|
|
|
|
|
|
|
gimp_histogram_view_set_background (view,
|
|
|
|
editor->bg_histogram);
|
|
|
|
}
|
|
|
|
}
|
2007-11-15 18:26:25 +08:00
|
|
|
}
|
|
|
|
}
|
2019-01-05 04:13:43 +08:00
|
|
|
else
|
2007-11-15 18:26:25 +08:00
|
|
|
{
|
2019-01-05 04:13:43 +08:00
|
|
|
if (editor->bg_histogram)
|
|
|
|
{
|
|
|
|
g_clear_object (&editor->bg_histogram);
|
|
|
|
gimp_histogram_view_set_background (view, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
editor->bg_pending = FALSE;
|
|
|
|
|
|
|
|
if (editor->update_pending)
|
|
|
|
gimp_async_cancel_and_wait (editor->calculate_async);
|
2007-11-15 18:26:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-27 00:32:17 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_buffer_update (GimpHistogramEditor *editor,
|
|
|
|
const GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
g_object_set (editor,
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
"trc", gimp_drawable_get_trc (editor->drawable),
|
2016-12-27 00:32:17 +08:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
static void
|
2003-11-01 21:58:06 +08:00
|
|
|
gimp_histogram_editor_update (GimpHistogramEditor *editor)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2019-01-05 04:13:43 +08:00
|
|
|
if (editor->bg_pending)
|
|
|
|
{
|
|
|
|
editor->update_pending = TRUE;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
editor->update_pending = FALSE;
|
|
|
|
|
2019-01-04 21:10:55 +08:00
|
|
|
if (editor->calculate_async)
|
|
|
|
gimp_async_cancel_and_wait (editor->calculate_async);
|
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
if (editor->idle_id)
|
|
|
|
g_source_remove (editor->idle_id);
|
|
|
|
|
2005-09-28 08:31:46 +08:00
|
|
|
editor->idle_id =
|
2007-11-13 18:59:32 +08:00
|
|
|
g_timeout_add_full (G_PRIORITY_LOW,
|
|
|
|
200,
|
|
|
|
(GSourceFunc) gimp_histogram_editor_idle_update,
|
|
|
|
editor,
|
|
|
|
NULL);
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_histogram_editor_idle_update (GimpHistogramEditor *editor)
|
|
|
|
{
|
|
|
|
editor->idle_id = 0;
|
|
|
|
|
2018-02-22 00:02:07 +08:00
|
|
|
/* Mark the histogram for recomputation and queue a redraw.
|
2005-09-28 08:31:46 +08:00
|
|
|
* We will then recalculate the histogram when the view is exposed.
|
|
|
|
*/
|
2018-02-22 00:02:07 +08:00
|
|
|
editor->recompute = TRUE;
|
2005-09-28 08:31:46 +08:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (editor->box));
|
2003-11-01 10:39:34 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-24 21:09:10 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_histogram_menu_sensitivity (gint value,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpHistogramEditor *editor = GIMP_HISTOGRAM_EDITOR (data);
|
|
|
|
GimpHistogramChannel channel = value;
|
|
|
|
|
app: streamline GimpHistogram; avoid spurious channel switch in histogram view
In GimpHistogram, get rid of the "n-channels" property and
corresponding gimp_histogram_n_channels() function. The former
returned the actual number of channels, but this wasn't too useful,
as channel values may not be sequential; the latter returned the
number of components. Instead, add an "n-components" property and
a corresponding gimp_histogram_n_components() function, both of
which return the number of components. Furthermore, add a
gimp_histogram_has_channel() function, which determines if the
histogram has a given channel; this allows for simple testing for
channel availability, which was done wrong in various places.
Adjust the GimpHistogram code for the changes, and clean it up,
fixing a few bugs.
Adjust users of GimpHisotgram for the changes. In particular,
in GimpHisotgramView, fix the channel-availability test when
setting the view's histogram (which happens whenever the active
drawable's preview is frozen), to avoid erroneously swithcing the
view's channel back to "Value" when a non-RGB channel is selected.
2019-10-22 20:37:50 +08:00
|
|
|
if (editor->histogram)
|
|
|
|
return gimp_histogram_has_channel (editor->histogram, channel);
|
2005-03-24 21:09:10 +08:00
|
|
|
|
2005-03-01 07:27:12 +08:00
|
|
|
return FALSE;
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-01 21:58:06 +08:00
|
|
|
gimp_histogram_editor_menu_update (GimpHistogramEditor *editor)
|
2003-11-01 10:39:34 +08:00
|
|
|
{
|
2005-03-24 21:09:10 +08:00
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
|
2005-03-01 07:27:12 +08:00
|
|
|
gtk_widget_queue_draw (editor->menu);
|
2005-03-24 21:09:10 +08:00
|
|
|
|
app: streamline GimpHistogram; avoid spurious channel switch in histogram view
In GimpHistogram, get rid of the "n-channels" property and
corresponding gimp_histogram_n_channels() function. The former
returned the actual number of channels, but this wasn't too useful,
as channel values may not be sequential; the latter returned the
number of components. Instead, add an "n-components" property and
a corresponding gimp_histogram_n_components() function, both of
which return the number of components. Furthermore, add a
gimp_histogram_has_channel() function, which determines if the
histogram has a given channel; this allows for simple testing for
channel availability, which was done wrong in various places.
Adjust the GimpHistogram code for the changes, and clean it up,
fixing a few bugs.
Adjust users of GimpHisotgram for the changes. In particular,
in GimpHisotgramView, fix the channel-availability test when
setting the view's histogram (which happens whenever the active
drawable's preview is frozen), to avoid erroneously swithcing the
view's channel back to "Value" when a non-RGB channel is selected.
2019-10-22 20:37:50 +08:00
|
|
|
if (editor->histogram &&
|
|
|
|
! gimp_histogram_has_channel (editor->histogram, view->channel))
|
2005-03-24 21:09:10 +08:00
|
|
|
{
|
|
|
|
gimp_histogram_view_set_channel (view, GIMP_HISTOGRAM_VALUE);
|
|
|
|
}
|
2003-11-01 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
2005-05-27 19:48:50 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_name_update (GimpHistogramEditor *editor)
|
|
|
|
{
|
|
|
|
const gchar *name = NULL;
|
|
|
|
|
|
|
|
if (editor->drawable)
|
2009-09-01 04:47:18 +08:00
|
|
|
name = gimp_object_get_name (editor->drawable);
|
2005-05-27 19:48:50 +08:00
|
|
|
|
|
|
|
gimp_editor_set_name (GIMP_EDITOR (editor), name);
|
|
|
|
}
|
|
|
|
|
2003-11-01 10:39:34 +08:00
|
|
|
static void
|
|
|
|
gimp_histogram_editor_info_update (GimpHistogramEditor *editor)
|
|
|
|
{
|
|
|
|
GimpHistogramView *view = GIMP_HISTOGRAM_BOX (editor->box)->view;
|
|
|
|
GimpHistogram *hist = editor->histogram;
|
|
|
|
|
|
|
|
if (hist)
|
|
|
|
{
|
2013-06-12 07:01:39 +08:00
|
|
|
gint n_bins;
|
2004-01-13 21:35:58 +08:00
|
|
|
gdouble pixels;
|
|
|
|
gdouble count;
|
|
|
|
gchar text[12];
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2013-06-12 07:01:39 +08:00
|
|
|
n_bins = gimp_histogram_n_bins (hist);
|
|
|
|
|
|
|
|
pixels = gimp_histogram_get_count (hist, view->channel, 0, n_bins - 1);
|
2004-01-13 21:35:58 +08:00
|
|
|
count = gimp_histogram_get_count (hist, view->channel,
|
|
|
|
view->start, view->end);
|
2003-11-01 10:39:34 +08:00
|
|
|
|
2013-06-12 08:01:24 +08:00
|
|
|
g_snprintf (text, sizeof (text), "%.3f",
|
2004-01-13 21:35:58 +08:00
|
|
|
gimp_histogram_get_mean (hist, view->channel,
|
2003-11-01 10:39:34 +08:00
|
|
|
view->start, view->end));
|
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[0]), text);
|
|
|
|
|
2013-06-12 08:01:24 +08:00
|
|
|
g_snprintf (text, sizeof (text), "%.3f",
|
2004-01-13 21:35:58 +08:00
|
|
|
gimp_histogram_get_std_dev (hist, view->channel,
|
2003-11-01 10:39:34 +08:00
|
|
|
view->start, view->end));
|
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[1]), text);
|
|
|
|
|
2013-06-12 08:01:24 +08:00
|
|
|
g_snprintf (text, sizeof (text), "%.3f",
|
|
|
|
gimp_histogram_get_median (hist, view->channel,
|
|
|
|
view->start,
|
|
|
|
view->end));
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[2]), text);
|
|
|
|
|
2005-07-19 17:44:46 +08:00
|
|
|
g_snprintf (text, sizeof (text), "%d", (gint) pixels);
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[3]), text);
|
|
|
|
|
2005-07-19 17:44:46 +08:00
|
|
|
g_snprintf (text, sizeof (text), "%d", (gint) count);
|
2003-11-01 10:39:34 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[4]), text);
|
|
|
|
|
2005-07-19 17:44:46 +08:00
|
|
|
g_snprintf (text, sizeof (text), "%.1f", (pixels > 0 ?
|
2003-11-01 10:39:34 +08:00
|
|
|
(100.0 * count / pixels) :
|
|
|
|
0.0));
|
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[5]), text);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
gtk_label_set_text (GTK_LABEL (editor->labels[i]), NULL);
|
|
|
|
}
|
|
|
|
}
|
2005-09-28 08:31:46 +08:00
|
|
|
|
|
|
|
static gboolean
|
2010-10-21 19:15:52 +08:00
|
|
|
gimp_histogram_editor_view_draw (GimpHistogramEditor *editor,
|
|
|
|
cairo_t *cr)
|
2005-09-28 08:31:46 +08:00
|
|
|
{
|
2008-07-22 17:29:35 +08:00
|
|
|
gimp_histogram_editor_validate (editor);
|
2005-09-28 08:31:46 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|