Commit Graph

436 Commits

Author SHA1 Message Date
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
Jehan 128baab2b6 Bug 735026: Enable zlib compression in XCF for GIMP 2.10
XCF file format bumped to version 8 when compressing with zlib.
2014-09-16 23:54:07 +02:00
Jehan d4dba427ac app: do not crash when opening a file with unimplemented compression
Our code was planning zlib and fractal compressions for eons, but would
crash against a file which would be actually using these. It means that
if we implement one of these compressions for 2.10, anyone with GIMP 2.8
(and likely earlier too) would crash when opening a legit file using the
new compressions. That's very bad.
Never use g_error() in non-fatale, expected, situations!
2014-09-15 16:17:13 +02:00
Michael Natterer a4ff0b17c8 app: also check for errors on closing the file in xcf_save_invoker()
and improve the error message.
2014-07-13 15:09:54 +02:00
Michael Natterer 7e9f4cc732 app: don't convert XCF filenames to UTF-8 display names twice
g_file_get_parse_name() already returns UTF-8, don't call
g_filename_display_name() on its result.
2014-07-13 14:03:00 +02:00
Michael Natterer 9e0c55eb04 app: remove two unused forgotten members from struct XcfInfo 2014-07-13 01:44:10 +02:00
Michael Natterer a6601d563b app: some GimpProgress cleanup
- change start() and set_text() to use "format" and "..." instead of
  "message", allowing to format progress messages in place
- s/cancelable/cancellable/
- move "cancellable" to be the second argument of start()
2014-07-12 23:45:20 +02:00
Michael Natterer e9e33421e2 app: turned an XCF debug patch I had into proper GIMP_LOG=xcf output
only for loading and incomplete, but a start.
2014-07-09 22:36:55 +02:00
Michael Natterer c3573c3c45 app: keep the plug-in executable path around as GFile 2014-07-08 21:09:35 +02:00
Michael Natterer 5d3583af87 app: remove xcf-load check that layer_type == image_type
This is not always true for floating selections.
2014-06-07 17:53:29 +02:00
Massimo Valentini 87596258d0 Bug 730396: GIMP crashes loading a XCF it saved
stop reading reached eof
2014-06-07 16:40:39 +02:00
Massimo Valentini a64a319d78 Bug 730396: GIMP crashes loading a XCF it saved
add few validity checks loading a xcf file.
2014-06-07 16:33:17 +02:00
Massimo Valentini fe4502fe04 Bug 730980: GIMP enters an infinite loop loading a truncated xcf 2014-06-06 18:35:25 +02:00
Michael Natterer de08267f06 libgimpbase, *: add enum value GIMP_ICON_TYPE_ICON_NAME
and keep GIMP_ICON_TYPE_STOCK_ID as a deprecated alias. Change all
plug-ins accordingly and increase the pluginrc file version number so
it gets regenerated with "icon-name" instead of "stock-id".
2014-05-11 23:56:30 +02:00
Michael Natterer 60f23afde2 app: add a small infrastructure to validate known parasites
when they are added to items, images or globally, from the PDF or an
XCF file. None of the validation functions does anything currently,
they simply return TRUE.
2014-03-22 00:18:48 +01:00
Michael Natterer 9a8aa70b85 xcf: forgot to register a loader for XCF version 7 2014-03-12 15:25:08 +01:00
Michael Natterer 2e2c6c2cf2 app: fix wrong version number comment in xcf-save.c 2014-03-09 19:07:58 +01:00
Michael Natterer e7ff0589cb app: shuffle precision enum values around to make room for U64
and add code to handle the old values from XCF files < version 7.
2014-03-09 01:46:08 +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
Nils Philippsen 2e6af22686 initialize length to appease cppcheck
The code was technically correct previously: It wrote the uninitialized
length only as a placeholder to overwrite it later on. Yet it's better
to not confuse tools (or people) analysing the code. Besides that having
0 for the length in the file while the payload is being written may aid
debugging e.g. crashes in that code later on.
2013-11-28 17:43:14 +01:00
Michael Schumacher 8db3b4312d Global EXIF -> Exif string change (official spelling) 2013-10-29 22:48:46 +01:00
Michael Natterer 8488248ec6 app: should also register a loader for XCF version 6... 2013-10-28 19:44:01 +01:00
Michael Natterer 95829c01cf app: save XCF version 6 when the image has metadata 2013-10-28 19:40:41 +01:00
Hartmut Kuhse 21bed1e2fb Completely rewrite metadata handling using gexiv2
Based on original patches from Hartmut Kuhse and modified
by Michael Natterer. Changes include:

- remove libexif dependency and add a hard dependency on gexiv2
- typedef GExiv2Metadata to GimpMetadata to avoid having to
  include gexiv2 globally
- add basic GimpMetadata handling functions to libgimpbase
- add image and image file specific metadata functions to libgimp,
  including the exif orientation image rotate dialog
- port plug-ins to use the new APIs
- port file-tiff-save's UI to GtkBuilder
- add new plug-in "metadata" to view the image's metadata
- keep metadata around as GimpImage member in the core
- update the image's metadata on image size, resolution and precision
  changes
- obsolete the old metadata parasites
- migrate the old parasites to new GimpMetadata object on XCF load
2013-10-27 01:02:17 +02:00
Michael Natterer 697572ccc0 app,libgimp*: fix includes to follow our include policy
- don't include <gdk-pixbuf/gdk-pixbuf.h> in headers in app/
- instead, include it in many .c files instead of <glib-object.h>,
  finally acknowledging the fact that app/ depends on gdk-pixbuf almost
  globally
- fix up includes as if libgimpbase depended in GIO, which it soon will
2013-10-15 01:58:39 +02:00