Commit Graph

35 Commits

Author SHA1 Message Date
Michael Natterer 7ada432690 app: big porting of weak pointers to g_set,clear_weak_pointer()
This started as review of weak pointers, but using
g_set_weak_pointer() and g_clear_weak_pointer() is almost always
better, and shorter.
2023-05-22 18:16:09 +02:00
Ell ffaaa81c8a app: add gimp_babl_format_change_{component_type,trc}()
... which change a format's component-type/TRC, without otherwise
affecting it.
2019-03-20 15:57:05 -04:00
Ell d7f12c9d26 app: add gimp_babl_is_bounded()
... which takes a GimpPrecision, and determines if its values are
bounded to the [0,1] range (which is currently only true for
integer precisions).
2019-03-20 15:50:35 -04:00
Jehan a03e52ea08 app: add "cairo-ARGB32" to "R'G'B'A u8" in gimp_babl_init_fishes().
This fish is used for text layers, so if we let it to be
lazy-initialized, the first time one writes text in a text layer, it
generates a few seconds delay, which is really not great.
2018-08-01 16:45:16 +02:00
Michael Natterer e09e563a70 Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.

libgimp:

- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
  as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
  NON_LINEAR and PERCPTUAL for each encoding, matching the babl
  encoding variants RGB, R'G'B' and R~G~B~.

- gimp_color_transform_can_gegl_copy() now returns TRUE if both
  profiles can return a babl space, increasing the amount of fast babl
  color conversions significantly.

- TODO: no solution yet for getting libgimp drawable proxy buffers in
  the right format with space.

plug-ins:

- follow the GimpPrecision change.

- TODO: everything else unchanged and partly broken or sub-optimal,
  like setting a new image's color profile too late.

app:

- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
  replacement for all "linear" booleans.

- change gimp-babl functions to take babl spaces and GimpTRCType
  parameters and support all sorts of new perceptual ~ formats.

- a lot of places changed in the early days of goat invasion didn't
  take advantage of gimp-babl utility functions and constructed
  formats manually. They all needed revisiting and many now use much
  simpler code calling gimp-babl API.

- change gimp_babl_format_get_color_profile() to really extract a
  newly allocated color profile from the format, and add
  gimp_babl_get_builtin_color_profile() which does the same as
  gimp_babl_format_get_color_profile() did before. Visited all callers
  to decide whether they are looking for the format's actual profile,
  or for one of the builtin profiles, simplifying code that only needs
  builtin profiles.

- drawables have a new get_space_api(), get_linear() is now get_trc().

- images now have a "layer space" and an API to get it,
  gimp_image_get_layer_format() returns formats in that space.

- an image's layer space is created from the image's color profile,
  change gimpimage-color-profile to deal with that correctly

- change many babl_format() calls to babl_format_with_space() and take
  the space from passed formats or drawables

- add function gimp_layer_fix_format_space() which replaces the
  layer's buffer with one that has the image's layer format, but
  doesn't change pixel values

- use gimp_layer_fix_format_space() to make sure layers loaded from
  XCF and created by plug-ins have the right space when added to the
  image, because it's impossible to always assign the right space upon
  layer creation

- "assign color profile" and "discard color profile" now require use
  of gimp_layer_fix_format_space() too because the profile is now
  embedded in all formats via the space.  Add
  gimp_image_assign_color_profile() which does all that and call it
  instead of a simple gimp_image_set_color_profile(), also from the
  PDB set-color-profile functions, which are essentially "assign" and
  "discard" calls.

- generally, make sure a new image's color profile is set before
  adding layers to it, gimp_image_set_color_profile() is more than
  before considered know-what-you-are-doing API.

- take special precaution in all places that call
  gimp_drawable_convert_type(), we now must pass a new_profile from
  all callers that convert layers within the same image (such as
  image_convert_type, image_convert_precision), because the layer's
  new space can't be determined from the image's layer format during
  the call.

- change all "linear" properties to "trc", in all config objects like
  for levels and curves, in the histogram, in the widgets. This results
  in some GUI that now has three choices instead of two.
  TODO: we might want to reduce that back to two later.

- keep "linear" boolean properties around as compat if needed for file
  pasring, but always convert the parsed parsed boolean to
  GimpTRCType.

- TODO: the image's "enable color management" switch is currently
  broken, will fix that in another commit.
2018-07-21 16:42:57 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Ell a0a62656d2 Issue #1792 - Xcf file crashing gimp-console-2.10 ...
... (valgrind reports Invalid read)

Add gimp_babl_is_valid(), which takes a GimpImageBaseType and a
GimpPrecision, and determines whether the image-type/precision
combination is valid.  Use this function to validate that loaded
XCFs use a valid type/precision combination, before trying to
create the image.  Otherwise, we get a CRITICAL, and eventually a
segfault, when the combination is invalid.

Use the same function to validate the arguments of
gimp_image_new().
2018-07-06 13:06:46 -04:00
luz.paz 7fdb963e01 Bug 794996 - Misc. typo fixes in comments in app/
Found via `codespell -q 3 --skip="./po*"`
2018-04-08 21:25:56 +02:00
Michael Natterer 54dc424b31 app: better progress indication in gimp_babl_init_fishes() 2016-11-14 19:58:20 +01:00
Øyvind Kolås 3bc2d25ccd app: preinit more fishes commonly used for filters on u8 images 2016-11-11 13:55:05 +01:00
Michael Natterer 17ac37ef8e app: pass a status_callback to gimp_babl_init_fishes()
and make it report progress. Also call it at the end of initialization.
2016-11-11 13:09:12 +01:00
Michael Natterer 0788db4702 app: split babl fish creating to a separate function gimp_babl_init_fishes()
and call that function later in gimp_real_initialize() so the splash
is always fully drawn when it's called.
2016-11-11 01:06:14 +01:00
Øyvind Kolås 99b9a60e8b app: pre-initialize some babl fishes 2016-11-11 00:54:04 +01:00
Michael Natterer c1ae0864de app: add gimp_babl_linear()
which completes gimp_babl_component_type() and gimp_babl_precision().
2016-11-09 12:02:12 +01:00
Michael Natterer 56596da23a app: support premultiplied formats in some gimp_babl functions 2016-06-08 00:03:48 +02:00
Michael Natterer 3fd6435198 app: add gimp_babl_format_get_color_profile()
and remove the code duplication added a few commits before.
2016-04-15 23:02:19 +01:00
Michael Natterer 5f8b6ce8da app: s/gimp_babl_get_description/gimp_babl_format_get_description/ 2016-04-15 19:19:09 +01:00
Michael Natterer 3c918353fb app: add double precision support, for completeness
and because it makes us look utterly cool.
2014-03-09 00:43:55 +01:00
Michael Natterer caf73f5f35 Add support for both gamma-corrected and linear for all bit depths
- Add new enum GimpComponentType which contains u8, u16, u32 etc.
- Change GimpPrecision to be u8-linear, u8-gamma, u16-linear etc.
- Add all the needed formats to gimp-babl.c
- Bump the XCF version to 5 and make sure version 4 with the old
  GimpPrecision enum values is loaded correctly

This change blows up the precision enums in "New Image" and
Image->Precision so we can test all this stuff. It is undecided what
format will be user-visible options in 2.10.
2013-06-23 16:51:24 +02:00
Michael Natterer d6b3a81821 app: add gimp_babl_print_pixel (format, pixel)
which returns a NULL-terminated string array with the pixels's
components, converted to text in the current locale.
2013-06-10 00:30:18 +02:00
Daniel Sabo 8d88b71fad Implement gimp_drawable_get_linear 2013-04-30 15:36:22 -07:00
Michael Natterer 2e54d88ef2 app: fix the babl model of the "A u16" format
makes babl stats crash one line later...
2012-12-03 23:04:52 +01:00
Michael Natterer c9e788c39d app: add gimp_babl_mask_format(precision) 2012-09-27 23:50:20 +02:00
Øyvind Kolås 20094807c8 app: gimp-babl.c fix formatting 2012-09-22 17:54:38 +01:00
Øyvind Kolås 594b4bcdef app: use sRGB gamma in u16 precision
This permits editing sRGB profile PNGs and other formats using sRGB storage,
without this editing a 16bit bpc PNG in u16 mode would cause banding in the
shadow areas on import. File that do not have an sRGB like gamma should be
promoted to a higher bit-depth on import.
2012-09-22 17:47:43 +01:00
Michael Natterer 1badcb7ce9 app: add GIMP_PRECISION_U32 and all its formats 2012-05-02 17:51:19 +02:00
Michael Natterer 2e7944cad0 app: add GIMP_PRECISION_HALF for 16 bit floating point
and use babl_format_get_palette() to simplify some code.
2012-05-02 17:51:18 +02:00
Michael Natterer 5167550271 app: add GIMP_PRECISION_U16 and all needed 16 bit integer formats 2012-05-02 17:51:15 +02:00
Michael Natterer a34afd63d8 app: add GIMP_PRECISION_FLOAT and all its formats
Images in that format can't be created currently, the legacy code
crashes royally on it.
2012-05-02 17:51:11 +02:00
Michael Natterer 8a55b13577 app: add gimp_babl_component_format() and use it in GimpImage 2012-05-02 17:51:10 +02:00
Michael Natterer 4f83ca48dc app: add missing formats to gimp_babl_get_description() 2012-05-02 17:51:09 +02:00
Michael Natterer 678255604d app: add a GimpPrecision enum that for now contains GIMP_PRECISION_U8
Add gimp_image_get_precision(), and a "precision" argument to
gimp_babl_format(). Change code accordingly and do some more format
related cleanups.
2012-05-02 17:51:09 +02:00
Michael Natterer 15d1827ead app: add gimp_babl_format() and use it in gimp_image_get_format() 2012-05-02 17:51:08 +02:00
Michael Natterer ff931e1ded app: move gimp_babl_format_get_base_type() to gimp-babl.[ch]
The GimpImageBaseType enum is going to go away, but a format -> enum
API is going to stay around.
2012-05-02 17:51:08 +02:00
Michael Natterer e737bf77fa app: add gimp-babl.[ch] and move Babl specific code there 2012-05-02 17:51:08 +02:00