Commit Graph

560 Commits

Author SHA1 Message Date
Michael Natterer 392f00baf5 app, libgimp: get rid of all ID GTypes and ID param specs
Turn all ID param specs into object param specs (e.g. GimpParamImageID
becomes GimpParamImage) and convert between IDs and objects in
gimpgpparams.c directly above the the wire protocol, so all of app/,
libgimp/ and plug-ins/ can deal directly with objects down to the
lowest level and not care about IDs.

Use the actual object param specs for procedure arguments and return
values again instead of a plain g_param_spec_object() and bring back
the none_ok parameter.

This implies changing the PDB type checking functions to work on pure
integers instead of IDs (one can't check whether object creation is
possible if performing that check requires the object to already
exist).

For example gimp_foo_is_valid() becomes gimp_foo_id_is_valid() and is
not involved in automatic object creation magic at the protocol
level. Added wrappers which still say gimp_foo_is_valid() and take the
respective objects.

Adapted all code, and it all becomes nicer and less convoluted, even
the generated PDB wrappers in app/ and libgimp/.
2019-08-29 11:39:34 +02:00
Michael Natterer de121374ef Change the "handles uri" flag of file procedures to "handle remote"
And always pass URIs to all file procedures, the ones what didn't
register as "handles remove" will only ever get local file:// URIs.

Change all file plug-ins (also legacy ones) to expect URIs instead
of filenames, and convert to local paths in the plug-in.

The wire protocol should now be almost 100% clean of non-UTF-8 strings.
2019-08-19 12:05:12 +02:00
Michael Natterer 11ce199cea app: stop canonicalizing procedure names
on behalf of plug-in authors who have no style or can't type.

Instead, simply reject non-canonical procedure names and remove all
code that keeps aroud the original non-canonical shit just to pass it
back to the plug-in.
2019-08-18 01:55:47 +02:00
Michael Natterer 32ea28b6b1 app, libgimp, libgimpbase: plug-in and PDB protocol refactoring part two
- Change the wire protocol's GPProcInstall to transmit the entire
  information needed for constructing all GParamSpecs we use, don't
  use GimpPDBArgType in GPProcInstall but an enum private to the wire
  protocol plus the GParamSpec's GType name. Bump the wire protocol
  version.

- Add gimpgpparamspecs.[ch] in both app/plug-in/ and libgimp/ which
  take care of converting between GPParamDef and GParamSpec. They
  share code as far as possible.

- Change pluginrc writing and parsing to re-use GPParamDef and the
  utility functions from gimpgpparamspecs.

- Remove gimp_pdb_compat_param_spec() from app/pdb/gimp-pdb-compat.[ch],
  the entire core uses proper GParamSpecs from the wire protocol now,
  the whole file will follow down the drain once we use a GValue
  representation on the wire too.

- In gimp_plug_in_handle_proc_install(), change the "run-mode"
  parameter to a GParamSpecEnum(GIMP_TYPE_RUN_MODE) (if it is not
  already an enum). and change all places in app/ to treat it as an
  enum value.

- plug-ins: fix cml-explorer to register correctly, a typo in
  "run-mode" was never noticed until now.

- Add gimpgpcompat.[ch] in libgimp to deal with all the transforms
  between old-style wire communication and using GParamSpec and
  GValue, it contains some functions that are subject to change or
  even removal in the next steps.

- Change the libgimp GimpProcedure and GimpPlugIn in many ways to be
  able to actually install procedures the new way.

- plug-ins: change goat-exercise to completely use the new GimpPlugIn
  and GimpProcedure API, look here to see how plug-ins will look in
  the future, of course subject to change until this is finished.

- Next: changing GPParam to transmit all information about a GValue.
2019-07-28 17:34:40 +02:00
Jehan 06be074650 app: salvage loaded group and text layer of dimension 0.
Whereas normal layers of dimension 0x0 are definitely broken, group and
text layers depend on their contents, which will be able to resize the
layer appropriately and fix whatever rendering. This commit allows to
salvage such layers, hence make XCF loading even more resistant to
certain form of file corruption.

This commit (and the previous one) are not theoretical but the result of
discovering some old corrupted file, with an empty group of size 0x0
(saved by GIMP itself, because of some old bug). Rather than destroying
these layer groups, this just allows us to reopen them without any kind
of loss!
2019-07-11 16:41:09 +02:00
Jehan 2045fdd2a3 app: don't abandon immediately XCF loading at first layer load failure.
If the problem occurs at one of the first layer, we may end up loading
nearly nothing even though there may be a whole lot of other data in
good state. So instead keep track of the number of failed layer and
channel loading to still display an error popup at the end, because we
still need to alert the user something went wrong. Yet damages are
limited.

Also make sure that layer paths are fixed when some layers could not be
loaded, hence stored paths end up wrong.
2019-07-11 16:13:18 +02:00
Michael Natterer 710cfc1f47 app: fix undoing image parasite attach/detach to emit the right signals
Add "gboolean push_undo" parameters to gimp_image_parasite_attach()
and _detach() and use the API also from undo, instead of implementing
attaching/removing manually and forgetting about the signals.

Fixes updating of the image properties color profile page.
2019-05-30 16:51:29 +02:00
Michael Natterer b9265e7cde Issue #2685 - Crash when distributing layers horizontally
Fix xcf-load.c to correct out-of-range item offsets (simply set them
to 0), so XCF files that are broken this way can still be recovered.

This doesn't fix the original bug, just recovering the crash images.
2019-01-03 15:02:55 +01:00
Ell 2168d91cf7 Issue #2604 - XCF saving bug in xcf_save_buffer()
The NULL terminator of the tile-offset array of dummy buffer-levels
is erroneously written as an int32, instead of an offset, even in
version-11+ XCFs, in which offsets are 64-bit.

Since the dummy levels aren't actually used by GIMP, we're going to
keep these fields as int32 as an exception, in order to remain
consistent with existing XCFs, and just add a comment in the code,
and update the docs.  If we ever make use of the higher buffer
levels, we should change these fields to offsets, and bump the XCF
version.
2018-12-04 12:09:49 -05:00
Jehan 076b53511a app: do no overwite XCF when an error occurred at saving time.
We can cancel a file overwrite at the last second when closing the
stream by setting a cancelled cancellable. Current code was simply not
closing the stream, but this was not enough as overwriting was happening
anyway (probably when finalizing).
This will allow much safe saving process since we would not be
overwriting a previously sane XCF file when an error occurred (either in
our code or a memory error, or whatnot).
See also discussion in #2565.
2018-11-26 14:10:37 +01:00
Elle Stone 298cc57042 Issue #2345 - Add xyY to color sample readouts
Add xyY color space to the color spaces for sampling colors.

Also add code to xcf-load.c that makes sure the sample point loading
code handles unknown future GimpColorPickMode values (fall back to
PIXEL pick mode).
2018-10-23 17:37:28 +02:00
Michael Natterer bcf9c94358 app: s/sprintf/g_snprintf/ in xcf_save_image() 2018-08-21 12:19:55 +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 ac5f44eb74 app: opaque in gimp_layer_new() is 1.0 not 255
The value is later CLAMP()ed correctly, but fix the call in xcf-load.c
anyway.
2018-07-16 14:47:10 +02:00
Michael Natterer 47a008be97 Issue #1805 - Sample Points keep resetting themselves to "Pixel"
Rename XCF property PROP_SAMPLE_POINT to PROP_OLD_SAMPLE_POINT and add
new PROP_SAMPLE_POINT.

The new property saves the sample point's pick mode plus some padding
for whatever else we might want to add. Always save the old property
too so nothing changes for older GIMP versions, and avoid loading the
old property if the new one was loaded before.
2018-07-16 01:42:19 +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
Ell d4ff57c793 app: avoid CRITICAL when loading XCF with empty gimp-image-metadata parasite 2018-07-05 22:47:45 -04:00
Ell 8e798e9cf2 app: avoid CRITICAL when writing 0-length data to XCF
In xcf_write_int8(), avoid calling g_output_stream_write_all() with
data == NULL and count == 0, in which case it raises a CRITICAL and
doesn't set bytes_written, which we proceed to use uninitialized.
This can happen, e.g., when writing an empty parasite.
2018-07-05 22:47:45 -04:00
Ell 6ebadea7c1 Issue #1783 - Xcf file crashing gimp-console-2.10 ...
... (Invalid read reported by valgrind)

In xcf_read_int8(), avoid calling g_input_stream_read_all() with
data == NULL and count == 0, in which case it raises a CRITICAL and
doesn't set bytes_read, which we proceed to use uninitialized.
This can happen, e.g., when reading an empty parasite.
2018-07-05 20:38:11 -04:00
Michael Natterer a4061a6b0d Issue #1291 - Non-intrusive warning when saved XCF version...
...won't work with older GIMP?

Make gimp_image_get_xcf_version() return a "reason" string which lists
all reasons why the image can't be saved with compatibility for older
GIMP versions. Display the reason as tooltip on the compat hint label
in the save dialog.
2018-06-06 23:08:33 +02:00
Michael Natterer ecb99ab445 app: add the new distance, rotation and slider axes to GimpCoords
and add code to get them from events and devices.
2018-05-20 21:06:35 +02:00
Jehan 47a036f750 Bug 795814 - Error saving VERY large file.
g_alloca() is not very advisable, especially when it might be used to
allocate a big chunk of memory at once. It is better to allocate dynamic
memory with malloc(), or in particular with g_try_malloc() which won't
abort the program on failure.
This might be slightly slower (one of the advantages of memory on the
stack, though not even an absolute truth) but probably not by much, if
at all, and it's better to be safe anyway.
2018-05-05 20:13:27 +02:00
luz.paz 4a77ff2d3d Bug 795557 - Misc. typo fixes in source, comments and doxygen (pt3)
Found via `codespell` and grep.
2018-04-25 23:49:06 +02: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 43549b7a38 app: remove some references to TileManager from xcf-load.c comments
and minor whitepace cleanup.
2018-04-06 12:56:31 +02:00
Jehan 65717041ed app: save image symmetries in the XCF file.
Symmetries are saved in a parasite, which is backward compatible.
2018-04-01 15:08:48 +02:00
Ell fcde7bdf47 app: small cleanup in xcf_load_channel_props()
Remove the impromptu boundary invalidation when converting a
channel to a selection mask in xcf_load_channel_props(), as this
happens implicitly when stealing the channel's buffer, since
commit 38d4aa8121.
2018-02-13 13:47:37 -05:00
Ell 38d4aa8121 Bug 793428 - Errors when loading an XCF with a saved selection mask
Since commit d0ae244fe8, which
connects GimpChannel instances to their buffer's "changed" signal,
the XCF loading code that steals a channel's buffer when converting
it to a selection mask (which happens when loading an XCF with a
saved selection mask) is unsafe, since fails to perform the
necessary cleanup and setup of the buffer in the old and new
channel objects, respectively.

Perform the buffer transfer using the new
gimp_drawable_steal_buffer(), which does the same thing in a safe
manner.
2018-02-13 13:29:15 -05:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
Ell 17fb644787 app: add XCF version 13 for images with group-layer masks 2018-02-05 15:15:21 -05:00
Hanno Boeck 702c4227e8 790783 - buffer overread in XCF parser if version field...
...has no null terminator

Check for the presence of '\0' before using atoi() on the version
string. Patch slightly modified (mitch).
2017-11-27 00:49:05 +01:00
Michael Natterer d613842eba Bug 788768 - GIMP crashes loading a valid truncated xcf
If the XCF is truncated in the middle of selection mask data,
don't unref the currently loading channel because we can't
unref the image's selection.
2017-11-19 18:28:36 +01:00
Ell 0ae7acd594 app: in xcf-load, avoid writing buffer data for empty tiles
When loading tile data, avoid copying the data into the GEGL
buffer when the tile is empty (i.e., all its bytes are 0), so that
GEGL doesn't allocate memory for it unnecessarily.
2017-10-04 06:51:34 -04:00
Michael Natterer 8f3cee4241 app: also fix the calls to xcf_read,write-component() 2017-10-01 17:43:10 +02:00
Michael Natterer 4503dad78c app: also, it's not the number of pixels but the number of components, sigh 2017-10-01 17:39:54 +02:00
Michael Natterer 2e0035c9df app: XCF endian swapping was still not correct
The number of pixels is "tile_size / bpp", not "tile_size / n_components".
2017-10-01 17:27:04 +02:00
Michael Natterer 54ac0feb5a app: "bpc" is bytes not bits per pixel in the new XCF endian code 2017-09-16 22:34:44 +02:00
Michael Natterer a735ba0daa app: add code to read/write XCF tile data as big-endian
It was always supposed to be like that, but simply forgotten.
Fortunately, big-endian machines are almost extinct...

The new code is triggered with XCF version >= 12, but we will start
using that only after code review.
2017-09-16 19:03:20 +02:00
Michael Natterer 4ff911f84d app: add xcf_read_component() and xcf_write_component()
which dispatch to endian-aware xcf_read/write_int8/int16/int32/int64()
2017-09-16 17:58:30 +02:00
Michael Natterer 0cfe550639 app, pdb: change a lot of GIMP_LAYER_MODE_NORMAL_LEGACY to just NORMAL
this commit changes just those which make no difference to
functionality: property and object member defaults that get overridden
anyway, return values of g_return_val_if_fail(), some other stuff.
2017-08-19 20:33:47 +02:00
Ell 8121769dc9 app: don't propagate NULL error when saving XCFs
xcf_save_foo() can fail without setting the error object, in which
case trying to propagate it emits a CRITICAL.
2017-07-28 16:51:08 -04:00
Ell 6b84293078 app: limit allowable tile data size in XCFs
When loading tiles from an XCF, reject tiles whose on-disk size is
greater than 1.5 times the size of an uncompressed tile -- a limit
that is already present for the last tile in the buffer.  This
should allow for the possibility of negative compression, while
restricting placing a realistic limit.

Currently, no limit is placed on the on-disk tile data size.  When
loading RLE- and zlib-compressed tiles, a buffer large enough to
hold the entire on-disk tile data, up to 2GB, is allocated on the
stack, and the data is read into it.  If the file is smaller than
the reported tile data size, the area of the buffer past the end
of the file is not touched.  This allows a malicious XCF to write
up to 2GB of arbitrary data, at an arbitrary offset, up to 2GB,
below the stack.

Note that a similar issue had existed for earlier versions of GIMP
(see commit d7a9e6079d), however,
since prior to 2.9 the tile data buffer was allocated on the heap,
the potential risk is far smaller.
2017-07-28 16:51:08 -04:00
Ell e7d781ff0e app: future-proof XCF layer blend/composite props
The layer blend space, composite space, and composite mode
properties have a special AUTO value, which may map to different
concrete values based on the layer mode.  Make sure we can change
this mapping in the future, without affecting existing XCFs (saved
after this commit), by encoding these properties as follows:

When saving an XCF, if the property has a concrete (non-AUTO)
value, which is always positive, encode it as is.  If the property
is AUTO, which is always 0, encode it as the negative of the value
it actually maps to at the time of saving (note that in some cases
AUTO may map to AUTO, in which case it's encoded as 0).

When loading an XCF, if the encoded property (stored in the file)
is nonnegative, use it as is.  Otherwise, compare the negative of
the encoded property to the value AUTO maps to at the time of
loading.  If the values are equal, set the property to AUTO;
otherwise, use the concrete value (i.e., the negative of the value
stored in the XCF).

Note that XCFs saved prior to this commit still load fine, it's
simply that if we change the AUTO mapping in the future, all their
AUTO properties will keep being loaded as AUTO, even if the
resulting concrete values will have changed.
2017-05-21 08:44:19 -04:00
Michael Natterer 7f33edea1b app, libgimp: allow to register more than one MIME type per procedure
GIMP will always use the first one from the list, but at least now
there is a way to register variants.
2017-05-04 23:22:37 +02:00
HJ Imbens c3dc3ea59f Fix rle encoding, first byte of run was added to previous non-run. 2017-03-25 03:52:44 +01:00
Michael Natterer 10360c9e13 app: add new XCF property PROP_FLOAT_COLOR
We were still saving channel colors in 8 bit, this additionally
saves/loads the color as float values. Still save the old PROP_COLOR
for compatibility.
2017-03-24 22:35:57 +01:00
Michael Natterer a0521a520f app: change the "XCF compat" stuff to "XCF compression"
Both in the GimpImage API and in the GUI. The toggle in the save
dialog now controls ZLIB compression directly. Changed the various
info labels accordingly. Ditch the XCF parasite that saved the XCF
compat mode.
2017-03-23 18:03:27 +01:00
Michael Natterer dd47e7bc3d Bug 731390 - XCF files have a max size of 4G
Enable 64 bit file offsets in XCF files, starting with newly added XCF
version 11.

We use at least version 11 if:

- we would use the previous version 10 (essentially skipping 10)
- the in-memory size of the image is larger than 4 Gig
2017-03-23 14:17:56 +01:00
Michael Natterer 829bad4063 Bug 731390 - XCF files have a max size of 4G
Add support for 64 bit offsets to xcf_read_offset() and
xcf_write_offset(), but don't use the feature yet.
2017-03-23 13:16:13 +01:00
Michael Natterer 061c2e7388 app: clean up xcf_save_prop() to do things more consistently 2017-03-23 13:02:36 +01:00
Michael Natterer 0c58dcd5cd Bug 731390 - XCF files have a max size of 4G
Change the xcf_write_foo() functions to take the XcfInfo* instead of
a GOutputStream*, and make them advance the info->cp offset by
themselves.
2017-03-23 12:42:38 +01:00
Michael Natterer 01be120349 Bug 731390 - XCF files have a max size of 4G
Change the xcf_read_foo() functions to take the XcfInfo* instead of
a GInputStream*, and make them advance the info->cp offset by
themselves. Makes xcf-load.c a lot more readable.
2017-03-23 12:26:09 +01:00
Michael Natterer a0a5f714bb Bug 731390 - XCF files have a max size of 4G
Step one, without changing anything in the saved XCFs yet:

Abstract reading and writing of file offsets away into their own
xcf_read_offset() and xcf_write_offset() functions, which take
"goffset" instead of "guint32". Also change xcf_seek_pos() to take a
goffset argument.

Change all file offset variables in xcf-load.c, xcf-write.c and struct
XcfInfo to goffset, and add new member "bytes_per_offset" to XcfInfo,
which is currently always 4.
2017-03-23 11:44:41 +01:00
Michael Natterer 3cf423f0cd *: rename NORMAL to NORMAL_LEGACY and NORMAL_LINEAR to NORMAL
and make NORMAL_LEGACY immutable.
2017-02-26 16:26:34 +01:00
Michael Natterer 0874703e3b Bug 778988 - XCF error: unsupported XCF file version 10 encountered
Oops, should support version 10 when loading XCF...
2017-02-21 02:11:18 +01:00
Michael Natterer 8634b5cbc3 app: make layer blend color space and compositing color space configurable
...they say it's going to get worse before it gets better...
2017-02-12 23:49:26 +01:00
Michael Natterer 2a96d598c3 app: add internal and PDB API and UI to control a layer's composite mode
Largely based on a patch by Ell, with the enum type renamed and
various small changes. Adds another axis of configurability to the
existing layer mode madness, and is WIP too.
2017-02-02 00:38:25 +01:00
Michael Natterer 152adbb1bd Rename GIMP_LAYER_MODE_FOO_BROKEN to GIMP_LAYER_MODE_FOO_LEGACY
"Broken" sounds like it needs fixing, but it's legacy compat stuff
that will have to stay for all eternity.
2017-01-09 01:27:20 +01:00
Michael Natterer 66060e3307 app, libgimp*, plug-ins: replace enum GimpLayerModeEffects by GimpLayerMode
with proper value names. Mark most values as _BROKEN because they use
weird alpha compositing that has to die. Move GimpLayerModeEffects to
libgimpbase, deprecate it, and set it as compat enum for GimpLayerMode.
Add the GimpLayerModeEffects values as compat constants to script-fu
and pygimp.
2017-01-08 23:00:19 +01:00
Hartmut Kuhse 66bc98d299 Revert "New GimpMetadata as subclass of GExiv2Metadata"
This reverts commit 3ab08c8bfd.
2017-01-03 19:36:22 +01:00
Hartmut Kuhse 3ab08c8bfd New GimpMetadata as subclass of GExiv2Metadata 2017-01-03 19:26:35 +01:00
Jehan 3fa016fb4b app: clean out tab indentations. 2016-12-21 04:05:32 +01:00
Michael Natterer a694fdd152 app: fix warning in xcf_save_prop(): xcf_write_int32() takes guint32* 2016-11-15 18:43:51 +01:00
Michael Natterer 4f9095798d Bug 769738 - Add color tags/labels for layers/channels/paths
Forgot to add XCF saving and loading of color tags.
2016-11-14 23:02:43 +01:00
Michael Natterer 63bcc69827 app: factor out xcf_load_stream() and xcf_save_stream()
which can be used to load/save XCF from/to arbitrars streams. Use the
new functions from the load/save procedure invokers.

This commit also fixes a leaked open file ans input stream for each
loaded XCF.
2016-09-18 20:19:42 +02:00
Massimo Valentini fede5ccba9 Bug 768519: File->Open Recent does not show...
... recently opened xcf files

be consistent regarding xcf files mime type
image/x-xcf is used in the installed gimp.desktop
use it everywhere.
2016-07-08 18:38:19 +02:00
Shmuel H 6d804bf9ae Bug 767873 - (CVE-2016-4994) Multiple Use-After-Free when parsing...
...XCF channel and layer properties

The properties PROP_ACTIVE_LAYER, PROP_FLOATING_SELECTION,
PROP_ACTIVE_CHANNEL saves the current object pointer the @info
structure. Others like PROP_SELECTION (for channel) and
PROP_GROUP_ITEM (for layer) will delete the current object and create
a new object, leaving the pointers in @info invalid (dangling).

Therefore, if a property from the first type will come before the
second, the result will be an UaF in the last lines of xcf_load_image
(when it actually using the pointers from @info).

I wasn't able to exploit this bug because that
g_object_instance->c_class gets cleared by the last g_object_unref and
GIMP_IS_{LAYER,CHANNEL} detects that and return FALSE.
2016-06-22 12:47:13 +02:00
Michael Natterer 2ef8719cbe app: rename more stuff from "floating sel" to "floating selection" 2016-05-20 16:46:26 +02:00
Michael Natterer e5a669bdfc libgimpbase: fix gimp_metadata_set_from_xmp() to really expect XMP
Don't skip the first 10 bytes. That code was there to skip the magic
"GIMP_XMP_1" of the old "gimp-metadata" parasite. Instead, properly
check for that magic in xcf_load_image() and pass only the actual XMP
to gimp_metadata_set_from_xmp(). Also remove the +10 hack in file-exr.
2016-04-22 22:49:06 +02:00
Michael Natterer 47ef3be145 Initialize GValues with G_VALUE_INIT instead of { 0, } 2016-03-26 15:59:26 +01:00
Jehan b8fadf3ad7 app: add a "custom" guide concept.
With gimp_guide_custom_new(), you can create a custom guide with a different
style on canvas (other pattern/color/width). A custom guide won't be saved
and could be used, for instance, for specific GEGL op guiding.
2016-02-02 21:15:13 +01:00
Mukund Sivaraman e14c1a0156 Use GQueue for strokes list 2016-01-25 10:56:15 +05:30
Michael Natterer 2a43ab240b app: don't access GimpSamplePoint members directly
Use the new accessors instead. Clean up guide and sample point code in
image crop and resize a bit.
2016-01-04 22:06:27 +01:00
Michael Natterer 1b2076cf69 app: save the "gimp-xcf-compatibility-mode" parasite in network byte order 2015-10-31 19:28:36 +01:00
Michael Natterer a2ad257711 Bug 756678 - Layer opacities change upon saving and reopening an xcf file
Add new XCF property FLOAT_OPACITY and always save both the old 8-bit
and the new float opacity of layers and channels. Float opacity is
saved after the 8-bit one so when loading, it overwrites the limited
8-bit value with the proper precision. Do not increase the XCF version
number because old GIMP versions will simply skip the unknown
FLOAT_OPACITY and keep using the 8-bit value.
2015-10-16 21:59:11 +02:00
Michael Natterer 5d7710a8a5 app: fix comment in xcf_load_image() 2015-09-15 23:02:54 +02:00
Jehan c7a2574136 app: parasite renamed to gimp-xcf-compatibility-mode.
Commit 0ea7d85 was misunderstanding due to foo-lang (language spoken by
Mitch and others, but not me, it would seem!). :-P
2015-09-02 11:47:51 +02:00
Jehan 0ea7d85570 app: rename compat parasite s/gimp-compatibility-mode/gimp-xcf-foo/
Not sure why, ask Mitch! :-)
2015-09-01 19:47:48 +02:00
Jehan cb84d4bd7e app: save compatibility mode data in a parasite.
If one explicitely enabled the compat mode on an image, we should assume
this mode should be reused upon following saves, even after shutdown.
2015-09-01 19:27:56 +02:00
Michael Natterer 597a438f07 app: remove gimp_image_set_filename()
- gimp-image-set-filename PDB wrapper: implement the same there in
  a few lines
- xcf-load.c: use gimp_image_set_file() instead, and get rid of the
  last use of filename in xcf/ in favor of GFile
2015-07-13 22:43:22 +02:00
Michael Natterer ee70fe6e78 Revert "app: saving as XCF should clean the dirty flags…"
This reverts commit 0c3e6675b0.

xcf_save_invoker() is not the right place to set the image's file
or dirty flag. It breaks "save a copy", for example.
2015-07-11 19:35:42 +02:00
Jehan 0c3e6675b0 app: saving as XCF should clean the dirty flags…
and associate the image to the saved file, even when saved with
`gimp-xcf-save` or `gimp-file-save` with ".xcf" extension.
2015-07-11 17:04:20 +02:00
Jehan f6fb13378d app: propagate the error when the XCF to save cannot even be created.
The possible failure of `g_file_replace()` was overlooked, as well as
the error which may have been created and could be useful information
for the developers.
2015-07-11 16:28:19 +02:00
Jehan 2edfde4f40 app: update `gimp-xcf-save` procedure documentation.
The "filename" parameter must be in UTF-8 and in URI format (for
instance file://path for local files, and not just a path).
Cf. `g_file_new_for_uri()` documentation:
@uri: a UTF-8 string containing a URI
2015-07-11 16:19:47 +02:00
Michael Natterer e64e9d0599 app: use gimp_channel_is_empty() not gimp_channel_bounds() in xcf_save_image()
We are not interested in the selection bounds, only if there is a
selection at all.
2015-07-03 19:38:07 +02:00
Michael Natterer db09d0f3d3 app: move functions to create layers to new files gimplayer-new.[ch] 2015-06-17 13:21:01 +02:00
Michael Natterer bc4cf9918f Bug 673501 - Issue with Overlay
GIMP's OVERLAY mode was identical to SOFTLIGHT. This commit fixes the
issue and introduces a NEW_OVERLAY mode and enum value.

- change gimp:overlay-mode to be a real (svg-ish) overlay mode
- when compositing, map OVERLAY to gimp:softlight-mode
- when compisiting, map NEW_OVERLAY to gimp:overlay-mode
- bump the XCF version when NEW_OVERLAY is used
- map OVERLAY to SOFTLIGHT when loading and saving XCF
- map OVERLAY to softlight in all PDB setters
- map OVERLAY to softlight when deserializing a GimpContext
- change all paint mode menus to show an entry for NEW_OVERLAY
  instead of OVERLAY
- change PSP, PSD and OpenRaster to use NEW_OVERLAY

These changes should (redundantly) make sure that no OVERLAY enum
value is used in the core any longer because it gets mapped to
SOFTLIGHT at all entry points, with the downside of introducing a
setter/getter asymmetry when OVERLAY was set in a PDB api.
2015-04-29 13:32:58 -04:00
Michael Natterer 744eeb8e1a Bug 686862 - Seek less when saving XCF files
Get rid of most seeking by writing the tile offsets to a table in
memory, instead of directly to the file after each tile. Only seek
back after writing all tiles, in order to save the entire table at
once.
2015-04-06 20:01:39 +02:00
Michael Natterer dd169a6a36 app: extend array in xcf_load_vector() for the new members of GimpCoords 2014-11-18 23:05:47 +01:00
Michael Natterer 950f753ede Bug 736907 - Compat mode for XCF
- add gimp_image_get,get_xcf_compat_mode()
- add a compat toggle to GimpFileDialog which is shown and sensitive
  only for a save (not export), and if the image structure allows
  to save an old version at all. The button also has a tooltip
  which explains why it is sensitive and what it does
- add "gboolean xcf_compat" to file_save_dialog_save_image()
- in file_save_dialog_save_image(), call image_set_xcf_compat_mode(TRUE)
  only around the call to file_save() and set it to FALSE after saving
- in xcf_save_invoker(), honor the image's XCF compat flag and save an
  RLE-compressed XCF if possible

The above is very convoluted and doesn't pass the "xcf_compat" boolean
directly because we can't change the parameters of gimp-xcf-save, and
because the gimp-xcf-save might be called indirectly.
2014-10-20 22:54:11 +02:00
Michael Natterer f5df5bee93 app: register file-xcf-load and file-xcf-save as GIO-ported
because the reason we didn't (seek errors) is gone now.
2014-10-18 01:17:01 +02:00
Michael Natterer 5a4d865358 Bug 738329 - xcf_seek_pos() can cause unexpected OS behavior
Change XCF saving to never seek past the end of the partially written
file. The only places where we still did this was when skipping the
offset tables for layers, channels, levels and tiles.

Now we write an all-zero offset table first, and then only seek around
in areas of the file that already exist. This also simplifies the code
a bit. Changed comments to make it clear what happens.
2014-10-17 19:12:05 +02:00
Michael Natterer 0d435f11b7 app: allocate the RLE buffer only if we save an RLE-compressed XCF 2014-10-15 23:53:59 +02:00
Michael Natterer 7b6c66159a app: use xcf_write_int32_check_error() for all XCF property writing
Some (copy/paste I guess) places used xcf_write_int32() plus manual
error checking for no reason.
2014-10-15 23:36:06 +02:00
Michael Natterer b9ff01306e app: remove xcf_seek_end(), it's unused, and should not be used any longer 2014-10-15 23:21:34 +02:00
Massimo Valentini 1368f73354 Bug 730211 - Extra zeroes appear in XCF files
Don't use xcf_seek_end() because that seems to be broken on certain
file systems / operating systems / FUSE mounts / whatever. Instead,
seek to explicitly calculated file offsets.

Ported Massimo's patch to master and added comments --Mitch

The same commit in gimp-2-8 is a57e49b1bb
2014-10-15 23:18:37 +02:00
Michael Natterer 849481a861 Clean up code around calls to g_file_replace()
- use G_FILE_CREATE_NONE instead of 0
- don't put "Could not open <file> for writing: <error>" around the
  returned error, the returned message is already verbose
2014-10-04 02:44:54 +02:00
Michael Natterer 4fdfe10b29 app: move the XCF version logic to gimpimage.[ch]
Add gimp_image_get_xcf_version() and use it when saving XCFs. The
function also returns GIMP versions in integer (comparable) and string
form to be used by GUI logic that allows to save compatible files.
2014-09-27 20:38:43 +02:00
Jehan ce2bb29605 app: do not use g_error() for non-fatale errors...
and g_warning() for programming errors only.
Use g_printerr() for "normal" errors which may happen in a program
lifetime (in particular corrupted XCF file errors are not necessarily
programming errors).
2014-09-17 00:18:15 +02:00