Commit Graph

54 Commits

Author SHA1 Message Date
Jehan 9e2a7e8759 libgimp, plug-ins: rename gimp_load_procedure_new2() as gimp_load_procedure_new().
All C load procedures are now moved to the new API.
2023-10-01 21:02:32 +02:00
Jehan 4a3fd7423a plug-ins: port various plug-ins to gimp_load_procedure_new2(). 2023-10-01 20:52:02 +02:00
Jehan fcc810d7d3 libgimp, plug-ins: rename to gimp_save_procedure_new().
Also the mimetype is already set by gimp_file_procedure_set_mime_types() so
transform the mimetype argument into an export_metadata argument.
2023-10-01 20:52:02 +02:00
Jehan 14bcaa717b plug-ins: a bunch of more plug-ins ported to gimp_save_procedure_new2(). 2023-10-01 20:52:01 +02:00
Niels De Graef 89c359ce47 Remove GimpUint8Array in favor of GBytes
GLib has a specific type for byte arrays: `GBytes` (and it's underlying
GType `G_TYPE_BYTES`).

By using this type, we can avoid having a `GimpUint8Array` which is a
bit cumbersome to use for both the C API, as well as bindings. By using
`GBytes`, we allow other languages to pass on byte arrays as they are
used to, while the bindings will make sure to do the right thing.

In the end, it makes the API a little bit simpler for everyone, and
reduces confusion for people who are used to working with byte arrays
in other C/GLib based code (and not having 2 different types to denote
the same thing).

Related: https://gitlab.gnome.org/GNOME/gimp/-/issues/5919
2023-05-23 23:37:50 +02:00
Alx Sa 24a1d34bba plug-ins: Porting to GimpSaveProcedureDialog
These five plug-ins already used GimpProcedureDialog when I originally
worked on them for !9250. However, their export GUI needs to
use GimpSaveProcedureDialog instead.
2023-05-20 14:30:41 +00:00
Alx Sa e7695c2b57 plug-ins: Port file-tga widgets to use...
...GimpDialogProcedure functions rather than gimp_prop_* directly.
2023-03-23 02:45:55 +00:00
Jacob Boerema 5f9415a641 plug-ins: fix #9067 TGA files saved by Krita can't be opened
Krita had a bug where it incorrectly saved 4 for the alpha bits instead of
8. We will allow 4 and convert that to 8 to be able to read the incorrect
TGA images.

The likelyhood of real TGA images with 4 alphabits seems pretty low, so it
should not interfere with real images that have this set. We were not
supporting that anyway.
2023-02-14 15:16:15 -05:00
Jehan 4f1d0fb53b plug-ins: get rid of various gimp_image_set_file() calls.
- This is unneeded in all import procedures. See previous commit. Note though
  that this is not because of a change in previous commit. This was already
  useless previously. The file set with this PDB function was overridden by the
  core anyway (i.e. even before the previous commits).
  In app/file/file-import.c:file_import_image(), the imported file is correctly
  set (so there is no need to set it from plug-in, which anyway libgimp's
  gimp_image_set_file() was not doing) and the XCF file is reset to NULL
  (rendering the call to gimp_image_set_file() in a GimpLoadProcedure useless).
- Similarly, this is a useless call in export procedures because
  app/file/file-save.c:file_save() overrides such call too. I could only see one
  such case for JPEG export, which was quite useless.
- Finally in other types of plug-ins, setting a non-XCF file extension was
  interfering with the save feature (similarly to commit e6e73e14c7). I only
  fixed the screenshot implementations doing such a thing.
- I left a few usages which will have to be looked at more in details later.
2023-02-13 22:54:16 +01:00
Jehan df074bfe09 plug-ins: label and documentation of plug-ins localized plug-in side.
This is the consequence of previous commit. Plug-ins' label and
documentation are now localized before sending these data to GIMP core.
In other words, we replace N_() macros with basic gettext calls.
2022-07-05 12:23:51 +02:00
Jehan 18c37f7084 plug-ins, libgimp: override set_i18n() for all our core plug-ins.
Hence avoiding the stderr messages. These are going to be localized with
centrally installed catalogs "gimp*-std-plugins", "gimp*-script-fu" and
"gimp*-python".

We now handle core plug-in localizations differently and in particular,
with kind of a reverse logic:

- We don't consider "gimp*-std-plugins" to be the default catalog
  anymore. It made sense in the old world where we would consider the
  core plug-ins to be the most important and numerous ones. But we want
  to push a world where people are even more encouraged to develop their
  own plug-ins. These won't use the standard catalog anymore (because
  there are nearly no reasons that the strings are the same, it's only a
  confusing logic). So let's explicitly set the standard catalogs with
  DEFINE_STD_SET_I18N macro (which maps to a different catalog for
  script-fu plug-ins).
- Doing something similar for Python plug-ins which have again their own
  catalog.
- Getting rid of the INIT_I18N macro since now all the locale domain
  binding is done automatically by libgimp when using the set_i18n()
  method infrastructure.
2022-06-05 01:57:02 +02:00
Jacob Boerema 059599fc78 plug-ins: fix #6871 indexed tga file cannot be saved
Exporting an image to TGA fails with a crash when it's an indexed image
with alpha channel. We were not taking into account that even though
the output is 1 byte per pixel, the input should allocate memory for
2 bytes per pixel (1 color index and 1 alpha channel).
2022-01-18 15:00:22 -05:00
Jacob Boerema a77131db3c plug-ins: fix #1111 TGA with indexed colors + alpha channel : not displayed correctly
Just like COLOR targa MAPPED (indexed) images with a size of 32 per
index should also have alphaBits set to 8 or else the images get
loaded incorrectly.
2021-10-15 11:57:23 -04:00
Jehan 4ae3687c88 plug-ins: more replacement of g_file_get_path() to g_file_peek_path().
While doing this cleanup, I found at least several other string leaks
in: file-compressor, file-gegl, file-pdf-save, file-raw-data, file-xwd,
jpeg-load, psd-save…
So it's quite worth it!

Note: in file-pdf-save, there is a global variable file_name which seems
to be happily leaked without caring (didn't look in details, but looks
so). I didn't fix this one which will require a bit more in-depth logics
care.
2021-10-01 19:37:59 +02:00
Jehan ca8bc2bc1d app, libgimp, pdb, plug-ins: more functions moved to get|set().
The gimp_drawable_type() is an issue though as gimp_drawable_get_type()
is already defined as a common GObject API.
Though I'm actually wondering if GimpImageType is well called. Rather
than Type, shouldn't we go with ColorModel?

sed -i 's/\<gimp_drawable_bpp\>/gimp_drawable_get_bpp/g' "$@"
sed -i 's/\<gimp_drawable_width\>/gimp_drawable_get_width/g' "$@"
sed -i 's/\<gimp_drawable_height\>/gimp_drawable_get_height/g' "$@"
sed -i 's/\<gimp_drawable_offsets\>/gimp_drawable_get_offsets/g' "$@"
2021-04-06 14:34:31 +02:00
Jehan d3139e0f7c app: support saving/exporting with multi-selection.
This commit just changes our saving API (i.e. the GimpSaveProcedure
class) to take an array of drawables as argument instead of a single
drawable.

It actually doesn't matter much for exporting as the whole API seems
more or less bogus there and all formats plug-ins mostly care only
whether they will merge/flatten all visible layers (the selected ones
don't really matter) or if the format supports layers of some sort. It
may be worth later strengthening a bit this whole logics, and maybe
allow partial exports for instance.

As for saving, it was not even looking at the passed GimpDrawable either
and was simply re-querying the active layer anyway.
Note that I don't implement the multi-selection saving in XCF yet in
this commit. I only updated the API. The reason is that the current
commit won't be backportable to gimp-2-10 because it is an API break. On
the other hand, the code to save multi-selection can still be backported
even though the save() API will only pass a single drawable (as I said
anyway, this argument was mostly bogus until now, hence it doesn't
matter much for 2.10 logics).
2020-05-17 18:32:16 +02:00
Sabri Ünal 0f8b9ed4aa CID 228155: Resource leak in file-tga.c
Variable fp going out of scope leaks the storage it points to.

(cherry picked from commit e6b0b992df)
2019-10-20 00:30:00 +02:00
Michael Natterer 6660dc540d plug-ins: port file-tga-save to GimpProcedureConfig 2019-10-05 12:41:53 +02:00
Michael Natterer df8d5b02ae libgimp, plug-ins: remove the "preview" parameter from gimp_ui_init()
It's dead since a looong time.
2019-09-20 19:56:00 +02:00
Michael Natterer 6bca8c4f89 pdb, app, libgimp, plug-ins: replace most PDB filenames/URIs by GFile
and in an attack of madness, changes almost all file plug-in
code to use GFile instead of filenames, which means passing
the GFile down to the bottom and get its filename at the very
end where it's actually needed.
2019-09-11 21:48:34 +02:00
Michael Natterer 8a78203aed Properly prefix the values of enum GimpPDBProcType
to be GIMP_PDB_PROC_TYPE_PLUGIN, _EXTENSION etc.
2019-08-30 12:52:28 +02:00
Michael Natterer 0ae833b0e0 plug-ins: port file-tga to GimpPlugIn and libgimp objects 2019-08-24 18:34:53 +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 169f98f915 libgimpwidgets: add GDestroyNotify to gimp_int_combo_box_connect() 2019-08-08 00:22:15 +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
Jehan 3d5732e23e plug-ins: some minor coding style fix.
Just some missing spaces between function name and parenthese which I
came across.
2017-12-20 15:12:10 +01:00
Jehan 8ea316667c plug-ins: TGA 16-bit RGB (without alpha bit) is also valid.
According to some spec on the web, 16-bit RGB is also valid. In this
case, the last bit is simply ignored (at least that's how it is
implemented right now).
2017-12-20 13:28:44 +01:00
Jehan 674b62ad45 Bug 739134 - (CVE-2017-17786) Out of bounds read / heap overflow in...
... TGA importer.

Be more thorough on valid TGA RGB and RGBA images.
In particular current TGA plug-in can import RGBA as 32 bits (8 bits per
channel) and 16 bits (5 bits per color channel and 1 bit for alpha), and
RGB as 15 and 24 bits.
Maybe there exist more variants, but if they do exist, we simply don't
support them yet.

Thanks to Hanno Böck for the report and a first patch attempt.
2017-12-20 13:02:38 +01:00
Thomas Manni b1ac9f33b2 Bug 790917 - Exporting 16bit per channel w/ alpha data as TGA destroys part of the image
Do not use the bytes-per-pixel size of the input drawable.
Use the bpp of the output format instead.
2017-12-03 01:22:28 +01:00
Michael Natterer e16c8a2352 Move the new "default_new_layer_mode" APIs to the image...
...in both the core and libgimp.

Images now know what the default mode for new layers is:

- NORMAL for empty images
- NORMAL for images with any non-legacy layer
- NORMAL_LEGAVY for images with only legacy layers

This changes behavior when layers are created from the UI, but *also*
when created by plug-ins (yes there is a compat issue here):

- Most (all?) single-layer file importers now create NORMAL layers
- Screenshot, Webpage etc also create NORMAL layers

Scripts that create images from scratch (logos etc) should not be
affected because they usually have NORMAL_LEGACY hardcoded.

3rd party plug-ins and scripts will also behave old-style unless they
get ported to gimp_image_get_default_new_layer_mode().
2017-08-21 20:18:00 +02:00
Michael Natterer 838449254a plug-ins: use gimp_get_default_new_layer_mode() for most new layers
instead of hardcoding NORMAL_LEGACY.
2017-08-20 17:12:46 +02: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 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
Jehan ec27b539ea plug-ins: various s/save/export/ replacement on visible strings. 2016-02-16 02:35:43 +01:00
Mukund Sivaraman ddda6a15c3 file-tga: Use the colormap origin / first entry index field 2014-12-20 23:24:20 +05:30
Michael Natterer f28878b6d3 plug-ins: start the progress before opening files for loading/saving
so the user gets feedback as early as possible.
2014-07-23 21:37:13 +02:00
Massimo Valentini 35466d6dd0 Bug 732163 - Flipped pixel columns in TGA
do not flip the central columns twice
2014-07-20 16:16:50 +02:00
Michael Natterer 03df8c6af4 plug-ins: pass the format's name again in calls to gimp_export_image()
and clean up the formatting of the call and the lines around it. Now
we can check the various (disabled) export options for regressions
again by changing a single line in gimp_export_image().
2013-11-10 00:18:48 +01:00
Mukund Sivaraman baf856e79d file-tga: Simplify has_alpha expression
Also fix variable name that changed from gimp-2-8 to master. This and
the last commit were cherry-picked from the gimp-2-8 branch.
2012-12-05 09:07:57 +05:30
Mukund Sivaraman 6d09237ca1 file-tga: Handle 16-bit palettes with transparency (#687802)
Primarily, this fixes a buffer overflow in the colormap buffer.

* We promote such images to GIMP_RGBA_IMAGE now.
* The alpha handling for the colormap to RGBA conversion has been
  fixed.
* Inverted transparency in upsampling has been fixed.
2012-12-05 08:51:12 +05:30
Michael Natterer 759142d82a plug-ins: port file-tga to GEGL 2012-11-22 00:04:28 +01:00
Michael Natterer a366fd76e5 Revert "Bug 683381 - Inverted alpha behavior of 16-bit Targa files"
This reverts commit dc00fb57a0.
2012-09-05 23:34:11 +02:00
Mike Gran dc00fb57a0 Bug 683381 - Inverted alpha behavior of 16-bit Targa files
file-tga.c (upsample): swap alpha behavior
2012-09-05 22:47:35 +02:00
Michael Natterer dcb4c6e34a plug-ins: use gtk_box_new() 2011-09-30 12:18:24 +02:00
Mikael Magnusson 8ff66342b8 plug-ins: set progress to 1.0 when done 2011-04-10 19:28:43 +02:00
Michael Natterer 8c4d99f883 Bug 645456 - Inconsistent window (role) naming scheme
Applied patch from Christoph Kappel which adds a "gimp-" prefix to all
plug-in dialog window roles.
2011-04-08 20:31:34 +02:00
Michael Natterer bbd7ec6b5c plug-ins: port from gimp_image_add_foo() to gimp_image_insert_foo()
I'm sure some plug-ins need to add their items *not* at the toplevel,
but since making plug-ins really tree-aware is a lot more work than
just fixing insert positions, I went for passing -1 as parent in
almost all cases. And because of laziness...
2010-09-06 11:40:46 +02:00
Andrew Wyatt 4a1078796b Bug 613328 - TGA files saved with incorrect header yOrigin data
Fix header for TGA files saved with save option 'Origin=Top Left'.
2010-07-07 20:41:46 +02:00
Martin Nordholts 19fe919dce plug-ins: Port file plug-ins to new export API 2009-07-21 16:03:58 +02:00
Michael Natterer e805cb0cf4 Use gtk_dialog_get_content_area() instead of dialog->vbox 2009-07-15 18:57:12 +02:00