Skip to content

Color pick in image's RGB color space

Alx Sa requested to merge alxsa-pick-with-anyrgb into master

This patch attempts to resolve a core issue with color picking in anyRGB color space, noted by @Jehan in their comment on !775 (closed).

When picking a color, GIMP currently converts it to and from sRGB automatically via the *_pixel_to_srgb () and *_srgb_to_pixel () functions in GimpPickableInterface (as implemented by GimpImage, GimpLayer, GimpImageProxy, and GimpProjection). Ultimately these are all handled by GimpColorTransforms in gimp_image_color_profile_srgb_to_pixel ().

This patch replaces those interface functions with *_pixel_to_rgb () and *_rgb_to_pixel (). The pixel values are converted using the image's assigned color profile via babl_process () in the new gimp_image_color_profile_rgb_to_pixel () method. One direct usage of gimp_pickable_srgb_to_pixel () was also updated in app\paint\gimpsmudge.c.

While further refinements in widgets like GimpColorFrame are likely needed once this core function is fixed, there are already noticeable changes/improvements as a result. As one example, currently if you color-pick an AdobeRGB "reddest-red", the color picker will display 115.8% in RGB (%) mode. With this patch, it now correctly displays 100% instead.

Feedback and suggestions appreciated!

Merge request reports