Commit Graph

51 Commits

Author SHA1 Message Date
Jehan 136aca3c34 plug-ins: port all remaining C load procedures to gimp_load_procedure_new2(). 2023-10-01 21:02:29 +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 9ed8f00e5b plug-ins: port most plug-ins to gimp_save_procedure_new2(). 2023-10-01 20:52:02 +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
Jacob Boerema d73bae0c66 plug-ins: add support for 8bpp with 4 planes in PCX/DC import
While testing the DCX import MR I saw that one image (abaddon.dcx) was not
recognized. This image uses 4 planes with 8 bpp while we only support
3 planes. The 4 planes type includes an alpha channel.

A few small changes allow us to also load 4 planes by allowing 3 or 4
planes instead of only 3.
2023-04-26 17:27:14 -04:00
Alx Sa da217088d0 plug-ins: Fix rounding error in PCX load
Some valid PCX/DCX files wouldn't load because the bytes per line
header check can be off by one due to integer division rounding.
This adds 1 to the equation to account for this.
2023-04-23 17:37:45 +00:00
Alx Sa 7bc7273d04 plug-ins: Add support for importing DCX files
DCX files are containers that store up to 1023 PCX files.
The PCX plug-in is rearranged to allow reading multiple PCX images per
file, rather than assuming there's only one image.
2023-04-23 17:37:45 +00:00
Alx Sa e599a9be59 plug-ins: Add option to override PCX 1 bit palette
If a 1 bit PCX image is opened interactively, a dialogue will let
users choose to either use the built-in palette, or force the colors to
be black/white only. Otherwise, the user can choose this via a script
parameter.
2023-03-27 15:53:05 +00: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
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
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 cd4fbb6213 plug-ins: port file-pcx to GimpPlunIn and libgimp objects 2019-08-24 19:27:46 +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
Ell 11defa4271 Issue #2997 - Error importing PCX
Commit dc069e424a removed the
assumption that 1-bpp PCX files are B&W, in favor of using the
provided palette, which is (supposedly?) the correct behavior.
However, there are evidently B&W files that do not specify a
palette, resulting in an all-black image (i.e., a 2-color indexed
image, whose both palette entries are black).  Since other
software, including older versions of GIMP, load such files
"correctly", let's fix this by falling back to a B&W palette when
the provded palette is uniform.
2019-02-22 12:02:09 -05:00
Jehan 5d319b77bf Issue #2160: Exporting to PCX results in a warped file.
Add line data padding when necessary.
Additionally I realize we should convert to little-endian after checking
the bytesperline oddness (this bug was most likely unnoticed until now
as most desktop proc are little endian now anyway).
2018-11-01 22:22:40 +01:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02: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 34485cff86 plug-ins: don't say for(int x...) in file-pcx.c 2017-06-29 18:39:41 +02:00
Jehan dc069e424a plug-ins: coding-style fix, adding comments and removing unused var.
Commits 8d4642f and daa5611 reviewed. I was only unsured on usage of
header vs EOF palette as well as the non-B&W monochrome palette since we
don't find a single authoritative spec. Nevertheless the implementer has
good argumentation so let's go with this. Simply I add some comments
about these 2 points in the code, just in case for future references.
2017-06-09 13:17:07 +02:00
Nikc M daa5611e6f Fix for Bug 159947 - saving 1bpp PCX files
+Allows user to save indexed 1bpp and 4bpp PCX files automatically,
depending on the number of colors used.

+Creates a general function with parameters for both bpp and # of
planes, to handle more PCX file types (1bpp, 2planes; 1bpp, 2planes;
4bpp, 1plane).

+Removes assumption when loading colormap that 1bpp files are black &
white only; loads both colors from PCX palette header instead.

https://bugzilla.gnome.org/show_bug.cgi?id=159947
2017-06-09 13:13:09 +02:00
Nikc M 8d4642f4ba Bug 159947 - saving 1bpp PCX Files
Allows saving 1bpp and 4bpp indexed PCX files based on number of colors
used in image. Also provides ability to load additional PCX formats:
2bpp, 2 planes 1bpp, 3 planes 1bpp, 4bpp.
2017-06-09 13:13:09 +02:00
Tobias Stoeckmann 10f12bdcbd PCX: Avoid segmentation fault with invalid file.
If a PCX file contains a bytesperline entry which is too small, it is
possible to trigger an out of boundary read, which can lead to a
segmentation fault.

The bytesperline validation is incomplete. While checking if enough
bytes per line exist, the integer truncation during the division must be
taken into account.

An example would be a 1x1 PCX file with a bpp of 1 (monochrome). The
current check allows a bytesperline field of 0, which in turn would lead
to a 0 byte allocation in load_1. Yet, the code would access index 0.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-04-08 17:25:07 +02:00
Tobias Stoeckmann 20c9b60487 PCX: Stop parsing an invalid file early on.
If either width or height is 0, gimp won't process the PCX file.
Instead, a bunch of error messages are printed.

It's nicer to quit parsing the file early on with a good error message
which is straight to the point instead.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-04-08 11:59:32 +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
Michael Natterer dae366bb6e configure.ac, *: require GLib 2.40.0
Remove gimp_output_stream_[v]printf() and use the new functions from
GLib instead. Use memmove() instead of the deprecated g_memmove().
2014-08-12 15:30:19 +02:00
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
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
Michael Natterer 3508079dcf plug-ins: add loading and saving of the image's resolution in file-pcx 2013-11-01 13:51:31 +01:00
Michael Natterer d48f0046fc plug-ins: port file-pcx to GEGL 2012-11-19 22:26:04 +01: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
Nelson A. de Oliveira f72d8a4a39 Move file opening block to after some tests
Instead fclosing fp for every return, it's better to move the block
to a lower position, since it's not used before.
2010-11-12 21:56:17 +01:00
Nelson A. de Oliveira 7666e5cf36 Fix memory and descriptor leaks 2010-11-12 21:56:17 +01: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
Nils Philippsen a9671395f6 PCX: Avoid allocation overflows.
Multiplying gint values may overflow unless cast into a larger type.
2009-12-09 16:32:29 +01:00
Nils Philippsen ed7f48be05 PCX: sanitize input data
Harden PCX plugin against bad width, height.
2009-12-09 15:40:13 +01:00
Martin Nordholts 19fe919dce plug-ins: Port file plug-ins to new export API 2009-07-21 16:03:58 +02:00
Sven Neumann c367ce336d sprinkled with const qualifiers.
2009-02-25  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/file-pcx.c: sprinkled with const qualifiers.


svn path=/trunk/; revision=28071
2009-02-25 10:56:41 +00:00
Michael Natterer 4ea1437646 plug-ins/common/*.c plug-ins/color-rotate/color-rotate.c
2009-01-19  Michael Natterer  <mitch@gimp.org>

	* plug-ins/common/*.c
	* plug-ins/color-rotate/color-rotate.c
	* plug-ins/file-bmp/bmp.c
	* plug-ins/file-faxg3/faxg3.c
	* plug-ins/file-fits/fits.c
	* plug-ins/file-fli/fli-gimp.c
	* plug-ins/file-ico/ico.c
	* plug-ins/file-jpeg/jpeg.c
	* plug-ins/file-psd/psd-save.c
	* plug-ins/file-psd/psd.c
	* plug-ins/file-sgi/sgi.c
	* plug-ins/file-uri/uri.c
	* plug-ins/file-xjt/xjt.c
	* plug-ins/flame/flame.c
	* plug-ins/fractal-explorer/fractal-explorer.c
	* plug-ins/gfig/gfig.c
	* plug-ins/gimpressionist/gimp.c
	* plug-ins/gradient-flare/gradient-flare.c
	* plug-ins/help-browser/help-browser.c
	* plug-ins/ifs-compose/ifs-compose.c
	* plug-ins/imagemap/imap_main.c
	* plug-ins/lighting/lighting-main.c
	* plug-ins/map-object/map-object-main.c
	* plug-ins/maze/maze.c
	* plug-ins/metadata/metadata.c
	* plug-ins/pagecurl/pagecurl.c
	* plug-ins/print/print.c
	* plug-ins/pygimp/gimpfu.py
	* plug-ins/script-fu/script-fu-script.c
	* plug-ins/script-fu/script-fu.c
	* plug-ins/selection-to-path/selection-to-path.c
	* plug-ins/twain/twain.c
	* plug-ins/win-snap/winsnap.c: document the "run-mode" parameter
	as we document enums for core procedures.


svn path=/trunk/; revision=27922
2009-01-19 20:11:36 +00:00
Michael Natterer d9b5207aa2 Change licence to GPLv3 (and to LGPLv3 for libgimp).
2009-01-17  Michael Natterer  <mitch@gimp.org>

	* all files with a GPL header and all COPYING files:

	Change licence to GPLv3 (and to LGPLv3 for libgimp).

	Cleaned up some copyright headers and regenerated the parsers in
	the ImageMap plugin.


svn path=/trunk/; revision=27913
2009-01-17 22:28:01 +00:00
Sven Neumann 592d59765e plug-ins/common/file-mng.c for the most common errors, pass the error
2008-08-18  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/file-mng.c
	* plug-ins/common/file-pcx.c: for the most common errors,
	pass the error message with the return values instead of calling
	gimp_message().

	* plug-ins/common/file-gif-save.c
	* plug-ins/common/file-pdf.c
	* plug-ins/common/file-png.c: minor cleanup.


svn path=/trunk/; revision=26638
2008-08-18 06:31:03 +00:00