Commit Graph

30 Commits

Author SHA1 Message Date
6ce835b9d7 plug-ins: Port DDS load dialog widgets to use...
GimpProcedureDialog APIs. Also add mnemonics.
2023-04-01 02:03:55 +00:00
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
eb2d99be3d plug-ins: support loading DDS with two 16-bit channels.
We have some examples of DDS images that have two 16-bit channels that
we could not load.

This commit adds checks to see if we need 16-bit channels, and conversion
of the input to a correct 16-bit red, green, blue or alpha channel.
2022-05-02 17:24:56 -04:00
045c3d3208 plug-ins: fix crash in DDS loader when one of the masks is zero. 2022-05-02 17:24:56 -04:00
d914580336 plug-ins: support loading more 16-bit, single channel DDS images
Single channel 16-bit DDS images can use other channels than red, so
let's support all masks with a value of 0xffff.
2022-05-02 17:24:56 -04:00
868a6f1d4a plug-ins: compute DDS variables earlier and support 16-bit masks
To be able to use certain variables we use in our DDS loader earlier,
we move the computation of these variables up.
We also add checks to see if the mask needs to be for 8 or 16-bit, since
there are DDS images with 16 bits per sample.
2022-05-02 17:24:56 -04:00
dec5ca2219 plug-ins: fix #7566 Import Issues with Indexed .dds Images
This proved to be both an import and export issue.
Our import set expected format as RGB, causing garbled image output.
Our export for indexed images converted to grayscale first, although the
palette was correctly saved. This caused wrong palette indexes on import.

For indexed images, on import, we request the actual indexed format after
creating the layer with gimp_drawable_get_format, which gives us a correct
indexed Babl format.
Also added logic for indexed with alpha, although I have no sample images
to test this.
For indexed images on export we do the same: use gimp_drawable_get_format
to get an actual indexed Babl format.
2021-12-01 15:01:48 -05:00
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
fe228a6f6f plug-ins: fix #5960 Gimp loads 16 bit DDS images with luminosity as 8 bit.
So far all dds images were loaded as 8 bit per channel which makes
sense for most but not all dds formats.

This commit implements loading in 16 bit for "L16" - a 16 bit
luminance channel.

In addition to that we improve security a bit  by not assuming
that L16 is the only left over case but instead explicitly
checking the correct value of rmask for L16.

For other cases we now set an error with enough details
to identify the type of DDS image that needs extra
handling.
2021-04-26 17:35:04 -04:00
cad6273fed plug-ins: fix #6755 DDS RGB10A2 has Red and Blue swapped.
Looking at the documentation it is indeed red that should go
in the lowest bits and blue in the highest bits so just
reverse our code for red and blue.

We also update the version of our GIMP DDS plug-in,
this way we can catch and correct RGB10A2 images
written by older versions of our plug-in and correct
them.
2021-04-23 14:31:50 -04:00
48ff5313c3 plug-ins: fix #6723 Unable to open DDS files.
This is the same as what we did for #5357
but in the reverse situation. The reason
for not doing the same at that time was
because I wasn't sure if that was valid
in all cases.

Looking at the documentation it does seem
to be the right solution and is working for
the supplied example image.
2021-04-14 13:37:22 -04:00
72d1f9cb6d plug-ins: get rid of gimp_image_(s|g)et_active_layer().
No more usage of the single active layer concept in existing plug-in
code.
2021-02-24 12:09:15 +01:00
a4cc8b7070 plug-ins: fix incorrect dds BC5 images saved by GIMP.
Since older versions of our GIMP dds file exporter incorrectly
saved BC5 dds images with the red and green channels
swapped we should fix that. Since the exporter already
wrote the plug-ins version number and that it is written by
GIMP we can check for these incorrect images.

To enable that we increase the plug-ins revision in this
commit and swap red and green channels for images
that have an older version number and are of the
correct type.
2021-01-05 17:58:20 -05:00
aea69dc165 plug-ins: file-dds (read) cleaned up a bit for better error handling.
Fatal errors should not be done with g_message(), but by setting the
returned GError appropriately. The main GError must therefore be passed
through functions.
Some non-fatal warnings may still be outputted with g_message() if we
want people to be aware of them (for instance if we managed to load some
data yet there might have been data loss or errors).
Finally when we are confident that we recovered from the format error,
it is still nice to output some error on standard error (not be totally
silent about it), but probably not need to bother people with popups.
See #5357.

Also clean up C++-style comments into C-style, to follow our coding
style.

Note: I only cleaned ddsread as a continuation of commit 81a3370e1d. I
expect ddswrite to have similar issues, but I did not look at it.
2020-07-26 13:32:18 +02:00
81a3370e1d plug-ins: fix #5357 Image marked as compressed, but DDSD_LINEARSIZE is not set. 2020-07-26 11:12:14 +00:00
871a31f70c plug-ins: remove ddsplugin.h and add ddsread.h and ddswrite.h 2019-10-02 20:54:16 +02:00
75396106d1 plug-ins: port file-dds-load to GimpProcedureConfig 2019-10-01 23:31:06 +02:00
e2ec4e0bd2 plug-ins: more file-dds cleanup 2019-10-01 18:29:42 +02:00
d3cfae2795 plug-ins: same cleanup in the DDS load dialog
and some more general cleanups.
2019-09-30 15:28:42 +02:00
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
a60ac57207 Missing mnemonics on several file dialogs
This path corrects missing mnemonics on several save/open/export dialogs.

save: file
open: file, dds, fits, tiff
export: bmp, dds, fli, gbr, gih, mng, pat, pnm, pdf, raw, sunras, sgi, webp
2019-09-09 18:06:29 +00:00
10b798c198 plug-ins: port file-dds to GimpPlugIn and libgimp objects
This is such a monster, I'm sure I broke something here...
2019-08-27 14:43:38 +02:00
2a48a5f868 plug-ins: big formatting and indentation cleanup in file-dds
Also change the license to GPL 3 or later, like all other files.
2019-05-23 14:34:00 +02:00
Ell
b5a34c3190 plug-ins: in file-dds, rename endian.h to endian_rw.h ...
... to avoid clashing with the system <endian.h>

Thanks Andrea!
2019-02-17 13:35:16 -05:00
ff2d22d915 plug-ins: a lot of coding style cleanup in file-dds.
Still a lot more to do but pushing WIP to not have it wasted if more
commits come in from others.
Also got rid of some global variables.
2019-01-02 21:41:19 +01:00
948608e658 plug-ins: get rid of "Show this dialog" checkbox in file-dds.
None of our load plug-ins have such a checkbox, so this is not
consistent. Moreover one you uncheck it, you just can't get back the
dialog until next GIMP restart. That's very bad usability.
2019-01-02 19:34:40 +01:00
df8a20956b plug-ins: make file-dds compile.
This is still very broken and it doesn't load well. But at least it
compiles!
All build errors (and a few warnings though not all) fixed.
2019-01-02 18:33:46 +01:00
2f3504e06a file-dds: mark some user-vsible messages for translation, expose them to PO files
Unfortunately, no items of comboboxes are currently translatble
due to the way the code is written.
2019-01-02 18:33:46 +01:00
d25348ca24 file-dds: support for DXT2/DXT4, initial build and GEGL-related fixes 2019-01-02 18:33:46 +01:00
79bc2dc1ef file-dds: add original source code of the DDS plug-in
This is the code from the 'gimp-2.9' branch of the plug-in,
integrated into GIMP's build system.
2019-01-02 18:33:46 +01:00