Issue #3041: Color Picker no longer selects Colormap entry.

Do not take "Sample merge" into account when picking colors in a
single-layer image. The reason is to be able to get the index
information on indexed image. This information is lost otherwise when
using the whole image as a pickable.

Of course, other exceptions are possible, when you'd pick exactly a
colormap color, but I don't think it's worth making the code
extra-complicated for these. My previous commit will anyway already
select the right color in the colormap on common cases. Though it will
still fail to select the right index when several indexes store the same
color, on a multi-layer image, if you check "Sample merged" while the
right index was not the first one amongst the duplicates.
This commit is contained in:
Jehan
2019-03-07 18:43:05 +01:00
parent e47185bf11
commit 31b2b55b28

View File

@ -22,9 +22,11 @@
#include "core-types.h"
#include "gimpchannel.h"
#include "gimpdrawable.h"
#include "gimpimage.h"
#include "gimpimage-pick-color.h"
#include "gimplayer.h"
#include "gimppickable.h"
@ -48,6 +50,25 @@ gimp_image_pick_color (GimpImage *image,
gimp_item_get_image (GIMP_ITEM (drawable)) == image,
FALSE);
if (sample_merged && drawable)
{
if ((GIMP_IS_LAYER (drawable) &&
gimp_image_get_n_layers (image) == 1) ||
(GIMP_IS_CHANNEL (drawable) &&
gimp_image_get_n_channels (image) == 1))
{
/* Let's add a special exception when an image has only one
* layer. This was useful in particular for indexed image as
* it allows to pick the right index value even when "Sample
* merged" is checked. There are more possible exceptions, but
* we can't just take them all in considerations unless we
* want to make code extra-complicated).
* See #3041.
*/
sample_merged = FALSE;
}
}
if (! sample_merged)
{
if (! drawable)