2018-11-13 02:35:07 +03:00
|
|
|
/*
|
2019-01-02 21:32:17 +01:00
|
|
|
* DDS GIMP plugin
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
|
|
|
|
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2018-11-14 14:56:15 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2018-11-13 02:35:07 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2018-11-14 14:56:15 +01:00
|
|
|
#include <libgimp/stdplugins-intl.h>
|
|
|
|
|
2018-11-13 02:35:07 +03:00
|
|
|
#include "dds.h"
|
2019-10-02 20:54:16 +02:00
|
|
|
#include "ddsread.h"
|
|
|
|
#include "ddswrite.h"
|
2018-11-13 02:35:07 +03:00
|
|
|
#include "misc.h"
|
|
|
|
|
2019-05-23 14:34:00 +02:00
|
|
|
|
2019-10-02 20:54:16 +02:00
|
|
|
#define LOAD_PROC "file-dds-load"
|
2024-04-13 15:10:25 +00:00
|
|
|
#define EXPORT_PROC "file-dds-export"
|
2019-10-02 20:54:16 +02:00
|
|
|
|
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
typedef struct _Dds Dds;
|
|
|
|
typedef struct _DdsClass DdsClass;
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
struct _Dds
|
|
|
|
{
|
|
|
|
GimpPlugIn parent_instance;
|
|
|
|
};
|
2019-05-23 14:34:00 +02:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
struct _DdsClass
|
2018-11-13 02:35:07 +03:00
|
|
|
{
|
2019-08-27 14:43:38 +02:00
|
|
|
GimpPlugInClass parent_class;
|
2018-11-13 02:35:07 +03:00
|
|
|
};
|
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
#define DDS_TYPE (dds_get_type ())
|
2023-10-18 18:29:37 +02:00
|
|
|
#define DDS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDS_TYPE, Dds))
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
GType dds_get_type (void) G_GNUC_CONST;
|
|
|
|
|
2023-08-05 19:07:04 +02:00
|
|
|
static GList * dds_query_procedures (GimpPlugIn *plug_in);
|
|
|
|
static GimpProcedure * dds_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name);
|
|
|
|
|
|
|
|
static GimpValueArray * dds_load (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GFile *file,
|
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpMetadataLoadFlags *flags,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data);
|
2024-04-13 15:10:25 +00:00
|
|
|
static GimpValueArray * dds_export (GimpProcedure *procedure,
|
2023-08-05 19:07:04 +02:00
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
2024-05-06 18:38:12 +00:00
|
|
|
GimpExportOptions *options,
|
2023-08-05 19:07:04 +02:00
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (Dds, dds, GIMP_TYPE_PLUG_IN)
|
|
|
|
|
|
|
|
GIMP_MAIN (DDS_TYPE)
|
2022-05-26 00:59:36 +02:00
|
|
|
DEFINE_STD_SET_I18N
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dds_class_init (DdsClass *klass)
|
2018-11-13 02:35:07 +03:00
|
|
|
{
|
2019-08-27 14:43:38 +02:00
|
|
|
GimpPlugInClass *plug_in_class = GIMP_PLUG_IN_CLASS (klass);
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
plug_in_class->query_procedures = dds_query_procedures;
|
|
|
|
plug_in_class->create_procedure = dds_create_procedure;
|
2022-05-26 00:59:36 +02:00
|
|
|
plug_in_class->set_i18n = STD_SET_I18N;
|
2019-08-27 14:43:38 +02:00
|
|
|
}
|
2019-05-23 14:34:00 +02:00
|
|
|
|
2019-01-02 21:32:17 +01:00
|
|
|
static void
|
2019-08-27 14:43:38 +02:00
|
|
|
dds_init (Dds *dds)
|
2018-11-13 02:35:07 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
static GList *
|
|
|
|
dds_query_procedures (GimpPlugIn *plug_in)
|
2018-11-13 02:35:07 +03:00
|
|
|
{
|
2019-08-27 14:43:38 +02:00
|
|
|
GList *list = NULL;
|
2019-01-02 21:32:17 +01:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
list = g_list_append (list, g_strdup (LOAD_PROC));
|
2024-04-13 15:10:25 +00:00
|
|
|
list = g_list_append (list, g_strdup (EXPORT_PROC));
|
2019-01-02 21:32:17 +01:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
return list;
|
|
|
|
}
|
2019-01-02 21:32:17 +01:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
static GimpProcedure *
|
|
|
|
dds_create_procedure (GimpPlugIn *plug_in,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GimpProcedure *procedure = NULL;
|
2019-01-02 21:32:17 +01:00
|
|
|
|
2019-05-23 14:34:00 +02:00
|
|
|
if (! strcmp (name, LOAD_PROC))
|
2019-01-02 21:32:17 +01:00
|
|
|
{
|
2023-08-06 03:21:27 +02:00
|
|
|
procedure = gimp_load_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
|
|
|
dds_load, NULL, NULL);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
2022-07-04 22:50:53 +02:00
|
|
|
gimp_procedure_set_menu_label (procedure, _("DDS image"));
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
2023-04-01 02:03:55 +00:00
|
|
|
_("Loads files in DDS image format"),
|
|
|
|
_("Loads files in DDS image format"),
|
2019-08-27 14:43:38 +02:00
|
|
|
name);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Shawn Kirst",
|
|
|
|
"Shawn Kirst",
|
|
|
|
"2008");
|
|
|
|
|
|
|
|
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"image/dds");
|
|
|
|
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"dds");
|
|
|
|
gimp_file_procedure_set_magics (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"0,string,DDS");
|
|
|
|
|
2024-06-12 16:53:12 +00:00
|
|
|
gimp_procedure_add_boolean_argument (procedure, "load-mipmaps",
|
|
|
|
_("Load _mipmaps"),
|
|
|
|
_("Load mipmaps if present"),
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "flip-image",
|
|
|
|
_("Flip image _vertically"),
|
|
|
|
_("Flip the image vertically on import"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
2019-01-02 21:32:17 +01:00
|
|
|
}
|
2024-04-13 15:10:25 +00:00
|
|
|
else if (! strcmp (name, EXPORT_PROC))
|
2019-01-02 21:32:17 +01:00
|
|
|
{
|
2024-04-20 03:08:57 +00:00
|
|
|
procedure = gimp_export_procedure_new (plug_in, name,
|
|
|
|
GIMP_PDB_PROC_TYPE_PLUGIN,
|
|
|
|
FALSE, dds_export, NULL, NULL);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
gimp_procedure_set_image_types (procedure, "INDEXED, GRAY, RGB");
|
|
|
|
|
2022-07-04 22:50:53 +02:00
|
|
|
gimp_procedure_set_menu_label (procedure, _("DDS image"));
|
2023-10-26 17:16:49 +00:00
|
|
|
gimp_file_procedure_set_format_name (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
_("DDS"));
|
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
gimp_procedure_set_documentation (procedure,
|
2023-10-26 17:16:49 +00:00
|
|
|
_("Saves files in DDS image format"),
|
|
|
|
_("Saves files in DDS image format"),
|
2019-08-27 14:43:38 +02:00
|
|
|
name);
|
|
|
|
gimp_procedure_set_attribution (procedure,
|
|
|
|
"Shawn Kirst",
|
|
|
|
"Shawn Kirst",
|
|
|
|
"2008");
|
|
|
|
|
|
|
|
gimp_file_procedure_set_mime_types (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"image/dds");
|
|
|
|
gimp_file_procedure_set_extensions (GIMP_FILE_PROCEDURE (procedure),
|
|
|
|
"dds");
|
|
|
|
|
2024-05-06 18:38:12 +00:00
|
|
|
gimp_export_procedure_set_capabilities (GIMP_EXPORT_PROCEDURE (procedure),
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_RGB |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_GRAY |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_INDEXED |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_ALPHA |
|
|
|
|
GIMP_EXPORT_CAN_HANDLE_LAYERS,
|
app, libgimp*, pdb, plug-ins: review and enhance MR !1549.
- Fix annotations for gimp_export_options_get_image() to make it
actually introspectable with the GimpImage being both input and
output. Even though the logic doesn't change much (the input image may
be overriden or not), it doesn't matter for introspection because
images are handled centrally by libgimp and therefore must not be
freed. Actually deleting the image from the central list of images
though remains a manual action depending on code logic, not some
automatic action to be handled by binding engines.
- Add G_GNUC_WARN_UNUSED_RESULT to gimp_export_options_get_image()
because ignoring the returned value is rarely a good idea (as you
usually want to delete the image).
- Remove gimp_export_options_new(): we don't need this constructor
because at this point, the best is to tell plug-in developers to just
pass NULL everywhere. This leaves us free to create a more useful
default constructor if needed, in the future. Main description for
GimpExportOptions has also been updated to say this.
- Add a data_destroy callback for the user data passed in
gimp_export_procedure_set_capabilities().
- Fixing annotations of 'export_options' object from pdb/pdb.pl: input
args would actually be (nullable) and would not transfer ownership
(calling code must still free the object). Return value's ownership on
the other hand is fully transfered.
- Add C and Python unit testing for GimpExportOptions and
gimp_export_options_get_image() in particular.
- Fix or improve various details.
Note that I have also considered for a long time changing the signature
of gimp_export_options_get_image() to return a boolean indicating
whether `image` had been replaced (hence needed deletion) or not. This
also meant getting rid of the GimpExportReturn enum. Right now it would
work because there are no third case, but I was considering the future
possibility that for instance we got some impossible conversion for some
future capability. I'm not sure it would ever happen; and for sure, this
is not desirable because it implies an export failure a bit late in the
workflow. But just in case, let's keep the enum return value. It does
not even make the using code that much more complicated (well just a
value comparison instead of a simple boolean test).
2024-08-17 15:06:27 +02:00
|
|
|
NULL, NULL, NULL);
|
2024-05-06 18:38:12 +00:00
|
|
|
|
2024-06-12 16:53:12 +00:00
|
|
|
gimp_procedure_add_choice_argument (procedure, "compression-format",
|
|
|
|
_("Compressio_n"),
|
|
|
|
_("Compression format"),
|
|
|
|
gimp_choice_new_with_values ("none", DDS_COMPRESS_NONE, _("None"), NULL,
|
|
|
|
"bc1", DDS_COMPRESS_BC1, _("BC1 / DXT1"), NULL,
|
|
|
|
"bc2", DDS_COMPRESS_BC2, _("BC2 / DXT3"), NULL,
|
|
|
|
"bc3, ", DDS_COMPRESS_BC3, _("BC3 / DXT5"), NULL,
|
|
|
|
"bc3n", DDS_COMPRESS_BC3N, _("BC3nm / DXT5nm"), NULL,
|
|
|
|
"bc4", DDS_COMPRESS_BC4, _("BC4 / ATI1 (3Dc+)"), NULL,
|
|
|
|
"bc5", DDS_COMPRESS_BC5, _("BC5 / ATI2 (3Dc)"), NULL,
|
|
|
|
"rxgb", DDS_COMPRESS_RXGB, _("RXGB (DXT5)"), NULL,
|
|
|
|
"aexp", DDS_COMPRESS_AEXP, _("Alpha Exponent (DXT5)"), NULL,
|
|
|
|
"ycocg", DDS_COMPRESS_YCOCG, _("YCoCg (DXT5)"), NULL,
|
|
|
|
"ycocgs", DDS_COMPRESS_YCOCGS, _("YCoCg scaled (DXT5)"), NULL,
|
|
|
|
NULL),
|
|
|
|
"none",
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "perceptual-metric",
|
|
|
|
_("Use percept_ual error metric"),
|
|
|
|
_("Use a perceptual error metric during compression"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_choice_argument (procedure, "format",
|
|
|
|
_("_Format"),
|
|
|
|
_("Pixel format"),
|
|
|
|
gimp_choice_new_with_values ("default", DDS_FORMAT_DEFAULT, _("Default"), NULL,
|
|
|
|
"rgb8", DDS_FORMAT_RGB8, _("RGB8"), NULL,
|
|
|
|
"rgba8", DDS_FORMAT_RGBA8, _("RGBA8"), NULL,
|
|
|
|
"bgr8", DDS_FORMAT_BGR8, _("BGR8"), NULL,
|
|
|
|
"abgr8, ", DDS_FORMAT_ABGR8, _("ABGR8"), NULL,
|
|
|
|
"r5g6b5", DDS_FORMAT_R5G6B5, _("R5G6B5"), NULL,
|
|
|
|
"rgba4", DDS_FORMAT_RGBA4, _("RGBA4"), NULL,
|
|
|
|
"rgb5a1", DDS_FORMAT_RGB5A1, _("RGB5A1"), NULL,
|
|
|
|
"rgb10a2", DDS_FORMAT_RGB10A2, _("RGB10A2"), NULL,
|
|
|
|
"r3g3b2", DDS_FORMAT_R3G3B2, _("R3G3B2"), NULL,
|
|
|
|
"a8", DDS_FORMAT_A8, _("A8"), NULL,
|
|
|
|
"l8", DDS_FORMAT_L8, _("L8"), NULL,
|
|
|
|
"l8a8", DDS_FORMAT_L8A8, _("L8A8"), NULL,
|
|
|
|
"aexp", DDS_FORMAT_AEXP, _("AEXP"), NULL,
|
|
|
|
"ycocg", DDS_FORMAT_YCOCG, _("YCOCG"), NULL,
|
|
|
|
NULL),
|
|
|
|
"default",
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_choice_argument (procedure, "save-type",
|
|
|
|
_("Sav_e type"),
|
|
|
|
_("How to save the image"),
|
|
|
|
gimp_choice_new_with_values ("layer", DDS_SAVE_SELECTED_LAYER, _("Selected layer"), NULL,
|
|
|
|
"canvas", DDS_SAVE_VISIBLE_LAYERS, _("All visible layers"), NULL,
|
|
|
|
"cube", DDS_SAVE_CUBEMAP, _("As cube map"), NULL,
|
|
|
|
"volume", DDS_SAVE_VOLUMEMAP, _("As volume map"), NULL,
|
|
|
|
"array", DDS_SAVE_ARRAY, _("As texture array"), NULL,
|
|
|
|
NULL),
|
|
|
|
"layer",
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "flip-image",
|
|
|
|
_("Flip image _vertically on export"),
|
|
|
|
_("Flip the image vertically on export"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "transparent-color",
|
|
|
|
_("Set _transparent color"),
|
|
|
|
_("Make an indexed color transparent"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_int_argument (procedure, "transparent-index",
|
|
|
|
_("Transparent inde_x"),
|
|
|
|
_("Index of transparent color or -1 to disable "
|
|
|
|
"(for indexed images only)."),
|
|
|
|
0, 255, 0,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_choice_argument (procedure, "mipmaps",
|
|
|
|
_("_Mipmaps"),
|
|
|
|
_("How to handle mipmaps"),
|
|
|
|
gimp_choice_new_with_values ("none", DDS_MIPMAP_NONE, _("No mipmaps"), NULL,
|
|
|
|
"generate", DDS_MIPMAP_GENERATE, _("Generate mipmaps"), NULL,
|
|
|
|
"existing", DDS_MIPMAP_EXISTING, _("Use existing mipmaps"), NULL,
|
|
|
|
NULL),
|
|
|
|
"none",
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_choice_argument (procedure, "mipmap-filter",
|
|
|
|
_("F_ilter"),
|
|
|
|
_("Filtering to use when generating mipmaps"),
|
|
|
|
gimp_choice_new_with_values ("default", DDS_MIPMAP_FILTER_DEFAULT, _("Default"), NULL,
|
|
|
|
"nearest", DDS_MIPMAP_FILTER_NEAREST, _("Nearest"), NULL,
|
|
|
|
"box", DDS_MIPMAP_FILTER_BOX, _("Box"), NULL,
|
|
|
|
"triangle", DDS_MIPMAP_FILTER_TRIANGLE, _("Triangle"), NULL,
|
|
|
|
"quadratic", DDS_MIPMAP_FILTER_QUADRATIC, _("Quadratic"), NULL,
|
|
|
|
"bspline", DDS_MIPMAP_FILTER_BSPLINE, _("B-Spline"), NULL,
|
|
|
|
"mitchell", DDS_MIPMAP_FILTER_MITCHELL, _("Mitchell"), NULL,
|
|
|
|
"catrom", DDS_MIPMAP_FILTER_CATROM, _("Catmull-Rom"), NULL,
|
|
|
|
"lanczos", DDS_MIPMAP_FILTER_LANCZOS, _("Lanczos"), NULL,
|
|
|
|
"kaiser", DDS_MIPMAP_FILTER_KAISER, _("Kaiser"), NULL,
|
|
|
|
NULL),
|
|
|
|
"default",
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_choice_argument (procedure, "mipmap-wrap",
|
|
|
|
_("_Wrap mode"),
|
|
|
|
_("Wrap mode to use when generating mipmaps"),
|
|
|
|
gimp_choice_new_with_values ("default", DDS_MIPMAP_WRAP_DEFAULT, _("Default"), NULL,
|
|
|
|
"mirror", DDS_MIPMAP_WRAP_MIRROR, _("Mirror"), NULL,
|
|
|
|
"repeat", DDS_MIPMAP_WRAP_REPEAT, _("Repeat"), NULL,
|
|
|
|
"clamp", DDS_MIPMAP_WRAP_CLAMP, _("Clamp"), NULL,
|
|
|
|
NULL),
|
|
|
|
"default",
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "gamma-correct",
|
|
|
|
_("Appl_y gamma correction"),
|
|
|
|
_("Use gamma correct mipmap filtering"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "srgb",
|
|
|
|
_("Use sRG_B colorspace"),
|
|
|
|
_("Use sRGB colorspace for gamma correction"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_double_argument (procedure, "gamma",
|
|
|
|
_("_Gamma"),
|
|
|
|
_("Gamma value to use for gamma correction (e.g. 2.2)"),
|
|
|
|
0.0, 10.0, 0.0,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_boolean_argument (procedure, "preserve-alpha-coverage",
|
|
|
|
_("Preserve al_pha test coverage"),
|
|
|
|
_("Preserve alpha test coverage for alpha "
|
|
|
|
"channel maps"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
gimp_procedure_add_double_argument (procedure, "alpha-test-threshold",
|
|
|
|
_("Alp_ha test threshold"),
|
|
|
|
_("Alpha test threshold value for which alpha test "
|
|
|
|
"coverage should be preserved"),
|
|
|
|
0.0, 1.0, 0.5,
|
|
|
|
G_PARAM_READWRITE);
|
2019-01-02 21:32:17 +01:00
|
|
|
}
|
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
return procedure;
|
|
|
|
}
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
static GimpValueArray *
|
2023-08-05 19:07:04 +02:00
|
|
|
dds_load (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GFile *file,
|
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpMetadataLoadFlags *flags,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data)
|
2019-08-27 14:43:38 +02:00
|
|
|
{
|
2019-10-01 23:31:06 +02:00
|
|
|
GimpValueArray *return_vals;
|
|
|
|
GimpPDBStatusType status;
|
|
|
|
GimpImage *image;
|
|
|
|
GError *error = NULL;
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
gegl_init (NULL, NULL);
|
|
|
|
|
2019-10-01 23:31:06 +02:00
|
|
|
status = read_dds (file, &image, run_mode == GIMP_RUN_INTERACTIVE,
|
2023-11-25 19:47:48 -07:00
|
|
|
procedure, config, &error);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
2019-10-01 23:31:06 +02:00
|
|
|
if (status != GIMP_PDB_SUCCESS)
|
2019-08-27 14:43:38 +02:00
|
|
|
return gimp_procedure_new_return_values (procedure, status, error);
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
return_vals = gimp_procedure_new_return_values (procedure,
|
|
|
|
GIMP_PDB_SUCCESS,
|
|
|
|
NULL);
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2019-08-27 14:43:38 +02:00
|
|
|
GIMP_VALUES_SET_IMAGE (return_vals, 1, image);
|
|
|
|
|
|
|
|
return return_vals;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpValueArray *
|
2024-04-13 15:10:25 +00:00
|
|
|
dds_export (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
2024-05-06 18:38:12 +00:00
|
|
|
GimpExportOptions *options,
|
2024-04-13 15:10:25 +00:00
|
|
|
GimpMetadata *metadata,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data)
|
2019-08-27 14:43:38 +02:00
|
|
|
{
|
2023-07-20 23:58:41 +02:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
2024-04-30 04:25:51 +00:00
|
|
|
GimpExportReturn export = GIMP_EXPORT_IGNORE;
|
2025-03-30 01:38:18 +00:00
|
|
|
GimpLayer **drawables;
|
2024-04-30 13:50:24 +00:00
|
|
|
GError *error = NULL;
|
2023-07-20 23:58:41 +02:00
|
|
|
gdouble gamma;
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
gegl_init (NULL, NULL);
|
|
|
|
|
2024-07-14 20:12:57 +00:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
|
|
|
gimp_ui_init ("dds");
|
|
|
|
|
2024-05-06 18:38:12 +00:00
|
|
|
export = gimp_export_options_get_image (options, &image);
|
2025-03-30 01:38:18 +00:00
|
|
|
drawables = gimp_image_get_selected_layers (image);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
2019-10-02 20:46:58 +02:00
|
|
|
g_object_get (config,
|
|
|
|
"gamma", &gamma,
|
|
|
|
NULL);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
2019-10-02 20:46:58 +02:00
|
|
|
/* gimp_gamma () got removed and was always returning 2.2 anyway.
|
|
|
|
* XXX Review this piece of code if we expect gamma value could be
|
|
|
|
* parameterized.
|
|
|
|
*/
|
|
|
|
if (gamma < 1e-04f)
|
|
|
|
g_object_set (config,
|
|
|
|
"gamma", 2.2,
|
|
|
|
NULL);
|
2018-11-13 02:35:07 +03:00
|
|
|
|
2020-04-14 11:46:17 +02:00
|
|
|
/* TODO: support multiple-layers selection, especially as DDS has
|
|
|
|
* DDS_SAVE_SELECTED_LAYER option support.
|
|
|
|
*/
|
2025-03-30 01:38:18 +00:00
|
|
|
status = write_dds (file, image, GIMP_DRAWABLE (drawables[0]),
|
2019-10-02 20:46:58 +02:00
|
|
|
run_mode == GIMP_RUN_INTERACTIVE,
|
2023-10-26 17:16:49 +00:00
|
|
|
procedure, config,
|
2022-05-16 18:56:16 +00:00
|
|
|
export == GIMP_EXPORT_EXPORT);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
|
|
|
if (export == GIMP_EXPORT_EXPORT)
|
2024-04-30 13:50:24 +00:00
|
|
|
gimp_image_delete (image);
|
2019-08-27 14:43:38 +02:00
|
|
|
|
2025-03-30 01:38:18 +00:00
|
|
|
g_free (drawables);
|
2019-08-27 14:43:38 +02:00
|
|
|
return gimp_procedure_new_return_values (procedure, status, error);
|
|
|
|
}
|