mirror of https://github.com/GNOME/gimp.git
Issue #4492: Add "Flip image", save visible layers feature to DDS
This commit is contained in:
parent
3644b9010a
commit
42cbaff322
|
@ -216,8 +216,9 @@ dds_create_procedure (GimpPlugIn *plug_in,
|
|||
GIMP_PROC_ARG_INT (procedure, "save-type",
|
||||
"Save type",
|
||||
"How to save the image (0 = selected layer, "
|
||||
"1 = cube map, 2 = volume map, 3 = texture array",
|
||||
0, 3, DDS_SAVE_SELECTED_LAYER,
|
||||
"1 = cube map, 2 = volume map, 3 = texture array, "
|
||||
"4 = all visible layers)",
|
||||
0, 4, DDS_SAVE_SELECTED_LAYER,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_INT (procedure, "format",
|
||||
|
@ -233,6 +234,12 @@ dds_create_procedure (GimpPlugIn *plug_in,
|
|||
0, 14, DDS_FORMAT_DEFAULT,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_BOOLEAN (procedure, "flip-image",
|
||||
"Flip image vertically",
|
||||
"Flip the image vertically on export",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_BOOLEAN (procedure, "transparent-color",
|
||||
"Transparent color",
|
||||
"Make an indexed color transparent",
|
||||
|
@ -263,7 +270,7 @@ dds_create_procedure (GimpPlugIn *plug_in,
|
|||
G_PARAM_READWRITE);
|
||||
|
||||
GIMP_PROC_ARG_BOOLEAN (procedure, "gamma-correct",
|
||||
"Gamme correct",
|
||||
"Gamma correct",
|
||||
"Use gamma correct mipmap filtering",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
@ -476,7 +483,8 @@ dds_save (GimpProcedure *procedure,
|
|||
*/
|
||||
status = write_dds (file, image, drawables[0],
|
||||
run_mode == GIMP_RUN_INTERACTIVE,
|
||||
procedure, G_OBJECT (config));
|
||||
procedure, G_OBJECT (config),
|
||||
export == GIMP_EXPORT_EXPORT);
|
||||
|
||||
if (export == GIMP_EXPORT_EXPORT)
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@ typedef enum
|
|||
DDS_SAVE_CUBEMAP,
|
||||
DDS_SAVE_VOLUMEMAP,
|
||||
DDS_SAVE_ARRAY,
|
||||
DDS_SAVE_VISIBLE_LAYERS,
|
||||
DDS_SAVE_MAX
|
||||
} DDS_SAVE_TYPE;
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ static GtkWidget *mipmap_filter_opt;
|
|||
static GtkWidget *mipmap_wrap_opt;
|
||||
static GtkWidget *transparent_spin;
|
||||
static GtkWidget *srgb_check;
|
||||
static GtkWidget *flip_check;
|
||||
static GtkWidget *gamma_check;
|
||||
static GtkWidget *gamma_spin;
|
||||
static GtkWidget *pm_check;
|
||||
|
@ -510,7 +511,8 @@ write_dds (GFile *file,
|
|||
GimpDrawable *drawable,
|
||||
gboolean interactive,
|
||||
GimpProcedure *procedure,
|
||||
GObject *config)
|
||||
GObject *config,
|
||||
gboolean is_duplicate_image)
|
||||
{
|
||||
FILE *fp;
|
||||
gint rc = 0;
|
||||
|
@ -578,7 +580,19 @@ write_dds (GFile *file,
|
|||
|
||||
gimp_progress_init_printf ("Saving %s:", gimp_file_get_utf8_name (file));
|
||||
|
||||
/* If destructive changes are going to happen to the image,
|
||||
* make sure we send a duplicate of it to write_image()
|
||||
*/
|
||||
if (! is_duplicate_image)
|
||||
{
|
||||
GimpImage *duplicate_image = gimp_image_duplicate (image);
|
||||
rc = write_image (fp, duplicate_image, drawable, config);
|
||||
gimp_image_delete (duplicate_image);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = write_image (fp, image, drawable, config);
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
|
||||
|
@ -1329,6 +1343,7 @@ write_image (FILE *fp,
|
|||
gint savetype;
|
||||
gint pixel_format;
|
||||
gint transindex;
|
||||
gboolean flip_export;
|
||||
|
||||
g_object_get (config,
|
||||
"compression-format", &compression,
|
||||
|
@ -1336,8 +1351,15 @@ write_image (FILE *fp,
|
|||
"save-type", &savetype,
|
||||
"format", &pixel_format,
|
||||
"transparent-index", &transindex,
|
||||
"flip-image", &flip_export,
|
||||
NULL);
|
||||
|
||||
if (flip_export)
|
||||
{
|
||||
gimp_image_flip (image, GIMP_ORIENTATION_VERTICAL);
|
||||
drawable = gimp_image_get_active_drawable (image);
|
||||
}
|
||||
|
||||
layers = gimp_image_list_layers (image);
|
||||
num_layers = g_list_length (layers);
|
||||
|
||||
|
@ -1642,7 +1664,8 @@ write_image (FILE *fp,
|
|||
|
||||
if (is_dx10)
|
||||
{
|
||||
array_size = ((savetype == DDS_SAVE_SELECTED_LAYER) ?
|
||||
array_size = ((savetype == DDS_SAVE_SELECTED_LAYER ||
|
||||
savetype == DDS_SAVE_VISIBLE_LAYERS) ?
|
||||
1 : get_array_size (image));
|
||||
|
||||
PUTL32 (hdr10 + 0, dxgi_format);
|
||||
|
@ -1724,6 +1747,9 @@ write_image (FILE *fp,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (savetype == DDS_SAVE_VISIBLE_LAYERS)
|
||||
drawable = GIMP_DRAWABLE (gimp_image_merge_visible_layers (image,
|
||||
GIMP_CLIP_TO_IMAGE));
|
||||
write_layer (fp, image, drawable, config,
|
||||
w, h, bpp, fmtbpp, num_mipmaps);
|
||||
}
|
||||
|
@ -1807,6 +1833,7 @@ config_notify (GObject *config,
|
|||
switch (savetype)
|
||||
{
|
||||
case DDS_SAVE_SELECTED_LAYER:
|
||||
case DDS_SAVE_VISIBLE_LAYERS:
|
||||
case DDS_SAVE_CUBEMAP:
|
||||
case DDS_SAVE_ARRAY:
|
||||
gtk_widget_set_sensitive (compress_opt, TRUE);
|
||||
|
@ -2014,10 +2041,11 @@ save_dialog (GimpImage *image,
|
|||
0.0, 0.5,
|
||||
format_opt, 1);
|
||||
|
||||
store = gimp_int_store_new ("Image / Selected layer", DDS_SAVE_SELECTED_LAYER,
|
||||
"As cube map", DDS_SAVE_CUBEMAP,
|
||||
"As volume map", DDS_SAVE_VOLUMEMAP,
|
||||
"As texture array", DDS_SAVE_ARRAY,
|
||||
store = gimp_int_store_new (_("Selected layer"), DDS_SAVE_SELECTED_LAYER,
|
||||
_("All visible layers"), DDS_SAVE_VISIBLE_LAYERS,
|
||||
_("As cube map"), DDS_SAVE_CUBEMAP,
|
||||
_("As volume map"), DDS_SAVE_VOLUMEMAP,
|
||||
_("As texture array"), DDS_SAVE_ARRAY,
|
||||
NULL);
|
||||
opt = gimp_prop_int_combo_box_new (config, "save-type",
|
||||
GIMP_INT_STORE (store));
|
||||
|
@ -2034,13 +2062,17 @@ save_dialog (GimpImage *image,
|
|||
combo_set_item_sensitive (opt, DDS_SAVE_VOLUMEMAP, is_volume);
|
||||
combo_set_item_sensitive (opt, DDS_SAVE_ARRAY, is_array);
|
||||
|
||||
store = gimp_int_store_new ("No mipmaps", DDS_MIPMAP_NONE,
|
||||
"Generate mipmaps", DDS_MIPMAP_GENERATE,
|
||||
"Use existing mipmaps", DDS_MIPMAP_EXISTING,
|
||||
flip_check = gimp_prop_check_button_new (config, "flip-image",
|
||||
_("Flip image _vertically on export"));
|
||||
gtk_grid_attach (GTK_GRID (grid), flip_check, 1, 4, 1, 1);
|
||||
|
||||
store = gimp_int_store_new (_("No mipmaps"), DDS_MIPMAP_NONE,
|
||||
_("Generate mipmaps"), DDS_MIPMAP_GENERATE,
|
||||
_("Use existing mipmaps"), DDS_MIPMAP_EXISTING,
|
||||
NULL);
|
||||
mipmap_opt = gimp_prop_int_combo_box_new (config, "mipmaps",
|
||||
GIMP_INT_STORE (store));
|
||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 4,
|
||||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 5,
|
||||
_("_Mipmaps:"),
|
||||
0.0, 0.5,
|
||||
mipmap_opt, 1);
|
||||
|
|
|
@ -27,7 +27,8 @@ extern GimpPDBStatusType write_dds (GFile *file,
|
|||
GimpDrawable *drawable,
|
||||
gboolean interactive,
|
||||
GimpProcedure *procedure,
|
||||
GObject *config);
|
||||
GObject *config,
|
||||
gboolean is_duplicate_image);
|
||||
|
||||
|
||||
#endif /* __DDSWRITE_H__ */
|
||||
|
|
Loading…
Reference in New Issue