From: Jehan Date: Wed, 17 Aug 2022 13:53:25 +0000 (+0200) Subject: bin: profile-aware babl format defaults. X-Git-Tag: archive/raspbian/1%0.1.106-3+rpi1^2~15^2~2^2~16 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=035c7b7661c90e264bbf06ecc9f25fc1e0d3c03c;p=babl.git bin: profile-aware babl format defaults. Instead of always defaulting to "R'G'B' float", if a input/output profile was set, check if it's CMYK, grayscale or RGB. The defaults are: * For a CMYK profile: "CMYK float" * For a grayscale profile: "Y' float" * For anything else (or no profile): "R'G'B' float" --- diff --git a/bin/babl.c b/bin/babl.c index 75df2d6..964a357 100644 --- a/bin/babl.c +++ b/bin/babl.c @@ -39,8 +39,8 @@ main (int argc, const Babl *to_format; const Babl *to_space = NULL; const Babl *fish; - const char *from = "R'G'B' float"; - const char *to = "R'G'B' float"; + const char *from = NULL; + const char *to = NULL; const char *from_profile = NULL; const char *to_profile = NULL; BablIccIntent intent = BABL_ICC_INTENT_RELATIVE_COLORIMETRIC; @@ -185,6 +185,25 @@ main (int argc, return 6; } + if (from == NULL) + { + if (babl_space_is_cmyk (from_space)) + from = "CMYK float"; + else if (babl_space_is_gray (from_space)) + from = "Y' float"; + else + from = "R'G'B' float"; + } + if (to == NULL) + { + if (babl_space_is_cmyk (to_space)) + to = "CMYK float"; + else if (babl_space_is_gray (to_space)) + to = "Y' float"; + else + to = "R'G'B' float"; + } + from_format = babl_format_with_space (from, from_space); n_components = babl_format_get_n_components (from_format); source = malloc (babl_format_get_bytes_per_pixel (from_format));