After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 109078 - gimp-curves-* pdb can't be applied to gray alpha but can be applied to alpha in alpha-less RGB drawables
gimp-curves-* pdb can't be applied to gray alpha but can be applied to alpha ...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
1.x
Other All
: Normal minor
: 2.0
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2003-03-24 12:45 UTC by Pedro Gimeno
Modified: 2004-01-13 11:52 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Pedro Gimeno 2003-03-24 12:45:07 UTC
When using gimp-curves-spline or gimp-curves-explicit with the alpha
channel of a grayscale image, the PDB fails.

How to reproduce:

 1. Create a grayscale image.
 2. Add alpha channel or create a new layer.
 3. Open the script-fu console and enter: (gimp-image-get-active-layer
<image-number>)
 4. With the returned layer number, execute: (gimp-curves-spline
<layer-number> ALPHA-LUT 4 (hexstr->bytes "007fff7f"))

(will signal an error)

On the other hand, if step (2) is omitted and (1) is replaced with
 1a. Create an RGB image.
then no error is returned.

The problem lies in the sanity check done by colors.pdb, and applies also
to the HEAD branch. Patch follows.
Comment 1 Pedro Gimeno 2003-03-24 12:53:36 UTC
Sorry, for some reason I can't upload it as an attachment. Here's the
patch:

diff -ur gimp-1.2.4pre-orig/tools/pdbgen/pdb/color.pdb
gimp-1.2.4pre/tools/pdbgen/pdb/color.pdb
--- gimp-1.2.4pre-orig/tools/pdbgen/pdb/color.pdb	Tue Apr 16 22:19:22 2002
+++ gimp-1.2.4pre/tools/pdbgen/pdb/color.pdb	Mon Mar 24 04:15:11 2003
@@ -342,7 +342,9 @@
 	code => <<'CODE'
 {
   if (gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
-      (gimp_drawable_is_gray (drawable) && channel != GRAY_LUT))
+      (!gimp_drawable_has_alpha (drawable) && channel == ALPHA_LUT) ||
+      (gimp_drawable_is_gray (drawable) && channel != GRAY_LUT
+
				&& channel != ALPHA_LUT))
     success = FALSE;
   else
     {
@@ -363,8 +365,8 @@
 	  cd.curve_type[i] = SMOOTH;
 
       cd.drawable = drawable;
-      cd.channel = channel;
       cd.color = gimp_drawable_is_rgb (drawable);
+      cd.channel = (cd.color || channel != ALPHA_LUT) ? channel : 2;
 
       for (j = 0; j < num_points / 2; j++)
 	{
@@ -424,7 +426,9 @@
 	code => <<'CODE'
 {
   if (gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
-      (gimp_drawable_is_gray (drawable) && channel != GRAY_LUT))
+      (!gimp_drawable_has_alpha (drawable) && channel == ALPHA_LUT) ||
+      (gimp_drawable_is_gray (drawable) && channel != GRAY_LUT
+
				&& channel != ALPHA_LUT))
     success = FALSE;
   else 
     {
@@ -433,8 +437,8 @@
 	  cd.curve[i][j] = j;
 
       cd.drawable = drawable;
-      cd.channel = channel;
       cd.color = gimp_drawable_is_rgb (drawable);
+      cd.channel = (cd.color || channel != ALPHA_LUT) ? channel : 2;
 
       for (j = 0; j < 256; j++)
 	cd.curve[cd.channel][j] = curve[j];
Comment 2 Sven Neumann 2003-03-25 09:58:19 UTC
I can confirm that the code in question is wrong in several places we
can not accept the patch as it is. There is no reason to set the
channel variable to 2 in case of gray images since 2 would be
GREEN_LUT. We need to investigate further and come up with a clean patch.
Comment 3 Sven Neumann 2003-06-20 22:58:17 UTC
We should at least fix this in 1.3.
Comment 4 Dave Neary 2003-07-26 20:11:07 UTC
Changing milestone on a bunch of bugs to 2.0 - none of these could be considered
a blocker for a pre-release, IMHO. Many of these have patches or someone working
on them, but they're not urgent.

Dave.
Comment 5 Michael Natterer 2004-01-13 11:52:15 UTC
Fixed in CVS:

2004-01-13  Michael Natterer  <mitch@gimp.org>

	* app/base/gimphistogram.[ch]: renamed gimp_histogram_nchannels()
	to gimp_histogram_n_channels().

	* app/core/gimpdrawable-histogram.c: removed silly double negation
	logic. Cleanup.

	* app/widgets/gimphistogrameditor.c
	* app/widgets/gimphistogramview.c: adjust the GimpHistogramChannel
	for GRAYA images to make sure we pick alpha from the right slot.

	* app/tools/gimpcurvestool.c
	* app/tools/gimplevelstool.c: removed the same hack here and call
	gimp_histogram_view_set_channel() with the correct enum value.

	* tools/pdbgen/pdb/color.pdb (levels, curves, histogram): fiddle
	with enum values here too so GRAY* drawables produce the correct
	results.

	Fixed precondition checks and set "success" in a uniform way all
	over the place.

	Use gimp_drawable_calculate_histogram() instead of duplicating its
	code here.

	(started with a patch from Pedro Gimeno. Fixes bug #109078)

	* app/pdb/color_cmds.c: regenerated.