1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

app, libgimpcolor: more move to GeglColor.

- New libgimpcolor functions: gimp_color_parse_hex() and gimp_color_parse_name().
- GimpColorHexEntry is now space-invaded. Though recognized color names
  and hexadecimal syntax are sRGB only (because CSS and SVG
  specifications explicitly say that this syntax is for sRGB values), it
  is possible to enter non-sRGB values with
  gimp_color_hex_entry_set_color().
- GimpColorSelection is now space-invaded.
This commit is contained in:
Jehan
2023-12-09 20:53:39 +09:00
parent ee19ad54d6
commit 093d00572a
13 changed files with 277 additions and 229 deletions

View File

@@ -240,6 +240,70 @@ gimp_color_parse_css (const gchar *css,
return color;
}
/**
* gimp_color_parse_hex:
* @hex: (array length=len): a string describing a color in hexadecimal notation
* @len: the length of @hex, in bytes. or -1 if @hex is nul-terminated
*
* Attempts to parse a string describing an RGB color in hexadecimal
* notation (optionally prefixed with a '#').
*
* This function does not touch the alpha component of @rgb.
*
* Returns: (transfer full): a newly allocated color representing @hex.
*
* Since: 2.2
**/
GeglColor *
gimp_color_parse_hex (const gchar *hex,
gint len)
{
GeglColor *result;
gchar *tmp;
g_return_val_if_fail (hex != NULL, FALSE);
tmp = gimp_color_parse_strip (hex, len);
result = gimp_color_parse_hex_internal (tmp);
g_free (tmp);
return result;
}
/**
* gimp_color_parse_name:
* @name: (array length=len): a color name (in UTF-8 encoding)
* @len: the length of @name, in bytes. or -1 if @name is nul-terminated
*
* Attempts to parse a color name. This function accepts [SVG 1.1 color
* keywords](https://www.w3.org/TR/SVG11/types.html#ColorKeywords).
*
* Returns: (transfer full): a sRGB color as defined in "4.4. Recognized color
* keyword names" list of SVG 1.1 specification, if @name was parsed
* successfully, %NULL otherwise
*
* Since: 2.2
**/
GeglColor *
gimp_color_parse_name (const gchar *name,
gint len)
{
gchar *tmp;
GeglColor *result;
g_return_val_if_fail (name != NULL, FALSE);
tmp = gimp_color_parse_strip (name, len);
result = gimp_color_parse_name_internal (tmp);
g_free (tmp);
return result;
}
/* Private functions. */

View File

@@ -33,6 +33,8 @@ EXPORTS
gimp_color_managed_simulation_intent_changed
gimp_color_managed_simulation_profile_changed
gimp_color_parse_css
gimp_color_parse_hex
gimp_color_parse_name
gimp_color_profile_get_copyright
gimp_color_profile_get_description
gimp_color_profile_get_format

View File

@@ -55,6 +55,10 @@ gboolean gimp_color_is_perceptually_identical (GeglColor *color1,
GeglColor * gimp_color_parse_css (const gchar *css,
gint len);
GeglColor * gimp_color_parse_hex (const gchar *hex,
gint len);
GeglColor * gimp_color_parse_name (const gchar *name,
gint len);
gboolean gimp_color_is_out_of_self_gamut (GeglColor *color);
gboolean gimp_color_is_out_of_gamut (GeglColor *color,