mirror of https://github.com/GNOME/gimp.git
plug-ins: port file-jpeg to GimpPlugIn and to libgimp objects
This commit is contained in:
parent
18c95e6fac
commit
3bef94d56f
|
@ -22,7 +22,6 @@ AM_LDFLAGS = $(mwindows)
|
|||
libexecdir = $(gimpplugindir)/plug-ins/file-jpeg
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-DGIMP_DEPRECATED_REPLACE_NEW_API \
|
||||
-I$(top_srcdir) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(EXIF_CFLAGS) \
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "jpeg-settings.h"
|
||||
#include "jpeg-load.h"
|
||||
|
||||
static gboolean jpeg_load_resolution (gint32 image_ID,
|
||||
static gboolean jpeg_load_resolution (GimpImage *image,
|
||||
struct jpeg_decompress_struct
|
||||
*cinfo);
|
||||
|
||||
|
@ -52,18 +52,18 @@ static void jpeg_load_cmyk_to_rgb (guchar *buf,
|
|||
glong pixels,
|
||||
gpointer transform);
|
||||
|
||||
gint32 volatile preview_image_ID;
|
||||
gint32 preview_layer_ID;
|
||||
GimpImage * volatile preview_image;
|
||||
GimpLayer * preview_layer;
|
||||
|
||||
gint32
|
||||
GimpImage *
|
||||
load_image (const gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview,
|
||||
gboolean *resolution_loaded,
|
||||
GError **error)
|
||||
{
|
||||
gint32 volatile image_ID;
|
||||
gint32 layer_ID;
|
||||
GimpImage * volatile image;
|
||||
GimpLayer *layer;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
jpeg_saved_marker_ptr marker;
|
||||
|
@ -96,10 +96,10 @@ load_image (const gchar *filename,
|
|||
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
||||
_("Could not open '%s' for reading: %s"),
|
||||
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
image_ID = -1;
|
||||
image = NULL;
|
||||
|
||||
/* Establish the setjmp return context for my_error_exit to use. */
|
||||
if (setjmp (jerr.setjmp_buffer))
|
||||
|
@ -111,8 +111,8 @@ load_image (const gchar *filename,
|
|||
if (infile)
|
||||
fclose (infile);
|
||||
|
||||
if (image_ID != -1 && !preview)
|
||||
gimp_image_delete (image_ID);
|
||||
if (image && !preview)
|
||||
gimp_image_delete (image);
|
||||
|
||||
if (preview)
|
||||
destroy_preview ();
|
||||
|
@ -120,7 +120,7 @@ load_image (const gchar *filename,
|
|||
if (buffer)
|
||||
g_object_unref (buffer);
|
||||
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Now we can initialize the JPEG decompression object. */
|
||||
|
@ -207,7 +207,7 @@ load_image (const gchar *filename,
|
|||
"with %d color channels, using colorspace %d (%d).",
|
||||
cinfo.output_components, cinfo.out_color_space,
|
||||
cinfo.jpeg_color_space);
|
||||
return -1;
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ load_image (const gchar *filename,
|
|||
{
|
||||
layer_name = _("JPEG preview");
|
||||
|
||||
image_ID = preview_image_ID;
|
||||
image = preview_image;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -225,16 +225,16 @@ load_image (const gchar *filename,
|
|||
|
||||
layer_name = _("Background");
|
||||
|
||||
image_ID = gimp_image_new_with_precision (cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
image_type,
|
||||
GIMP_PRECISION_U8_NON_LINEAR);
|
||||
image = gimp_image_new_with_precision (cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
image_type,
|
||||
GIMP_PRECISION_U8_NON_LINEAR);
|
||||
|
||||
gimp_image_undo_disable (image_ID);
|
||||
gimp_image_set_filename (image_ID, filename);
|
||||
gimp_image_undo_disable (image);
|
||||
gimp_image_set_filename (image, filename);
|
||||
|
||||
/* Step 5.0: save the original JPEG settings in a parasite */
|
||||
jpeg_detect_original_settings (&cinfo, image_ID);
|
||||
jpeg_detect_original_settings (&cinfo, image);
|
||||
|
||||
/* Step 5.1: check for comments, or Exif metadata in APP1 markers */
|
||||
for (marker = cinfo.marker_list; marker; marker = marker->next)
|
||||
|
@ -271,7 +271,7 @@ load_image (const gchar *filename,
|
|||
}
|
||||
}
|
||||
|
||||
if (jpeg_load_resolution (image_ID, &cinfo))
|
||||
if (jpeg_load_resolution (image, &cinfo))
|
||||
{
|
||||
if (resolution_loaded)
|
||||
*resolution_loaded = TRUE;
|
||||
|
@ -287,7 +287,7 @@ load_image (const gchar *filename,
|
|||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (comment_buffer->str) + 1,
|
||||
comment_buffer->str);
|
||||
gimp_image_attach_parasite (image_ID, parasite);
|
||||
gimp_image_attach_parasite (image, parasite);
|
||||
gimp_parasite_free (parasite);
|
||||
|
||||
g_string_free (comment_buffer, TRUE);
|
||||
|
@ -309,7 +309,7 @@ load_image (const gchar *filename,
|
|||
NULL);
|
||||
if (profile)
|
||||
{
|
||||
gimp_image_set_color_profile (image_ID, profile);
|
||||
gimp_image_set_color_profile (image, profile);
|
||||
g_object_unref (profile);
|
||||
}
|
||||
}
|
||||
|
@ -321,15 +321,15 @@ load_image (const gchar *filename,
|
|||
*/
|
||||
}
|
||||
|
||||
layer_ID = gimp_layer_new (image_ID, layer_name,
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type,
|
||||
100,
|
||||
gimp_image_get_default_new_layer_mode (image_ID));
|
||||
layer = gimp_layer_new (image, layer_name,
|
||||
cinfo.output_width,
|
||||
cinfo.output_height,
|
||||
layer_type,
|
||||
100,
|
||||
gimp_image_get_default_new_layer_mode (image));
|
||||
|
||||
if (preview)
|
||||
preview_layer_ID = layer_ID;
|
||||
preview_layer = layer;
|
||||
|
||||
/* Step 6: while (scan lines remain to be read) */
|
||||
/* jpeg_read_scanlines(...); */
|
||||
|
@ -338,11 +338,11 @@ load_image (const gchar *filename,
|
|||
* loop counter, so that we don't have to keep track ourselves.
|
||||
*/
|
||||
|
||||
buffer = gimp_drawable_get_buffer (layer_ID);
|
||||
buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (layer));
|
||||
|
||||
format = babl_format_with_space (image_type == GIMP_RGB ?
|
||||
"R'G'B' u8" : "Y' u8",
|
||||
gimp_drawable_get_format (layer_ID));
|
||||
gimp_drawable_get_format (GIMP_DRAWABLE (layer)));
|
||||
|
||||
while (cinfo.output_scanline < cinfo.output_height)
|
||||
{
|
||||
|
@ -433,13 +433,13 @@ load_image (const gchar *filename,
|
|||
gimp_progress_update (1.0);
|
||||
}
|
||||
|
||||
gimp_image_insert_layer (image_ID, layer_ID, -1, 0);
|
||||
gimp_image_insert_layer (image, layer, NULL, 0);
|
||||
|
||||
return image_ID;
|
||||
return image;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
jpeg_load_resolution (gint32 image_ID,
|
||||
jpeg_load_resolution (GimpImage *image,
|
||||
struct jpeg_decompress_struct *cinfo)
|
||||
{
|
||||
if (cinfo->saw_JFIF_marker && cinfo->X_density != 0 && cinfo->Y_density != 0)
|
||||
|
@ -455,7 +455,7 @@ jpeg_load_resolution (gint32 image_ID,
|
|||
*/
|
||||
asymmetry = xresolution / yresolution;
|
||||
|
||||
gimp_image_get_resolution (image_ID, &xresolution, &yresolution);
|
||||
gimp_image_get_resolution (image, &xresolution, &yresolution);
|
||||
|
||||
xresolution *= asymmetry;
|
||||
break;
|
||||
|
@ -466,7 +466,7 @@ jpeg_load_resolution (gint32 image_ID,
|
|||
case 2: /* dots per cm */
|
||||
xresolution *= 2.54;
|
||||
yresolution *= 2.54;
|
||||
gimp_image_set_unit (image_ID, GIMP_UNIT_MM);
|
||||
gimp_image_set_unit (image, GIMP_UNIT_MM);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -475,7 +475,7 @@ jpeg_load_resolution (gint32 image_ID,
|
|||
break;
|
||||
}
|
||||
|
||||
gimp_image_set_resolution (image_ID, xresolution, yresolution);
|
||||
gimp_image_set_resolution (image, xresolution, yresolution);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -509,14 +509,14 @@ jpeg_load_sanitize_comment (gchar *comment)
|
|||
}
|
||||
}
|
||||
|
||||
gint32
|
||||
GimpImage *
|
||||
load_thumbnail_image (GFile *file,
|
||||
gint *width,
|
||||
gint *height,
|
||||
GimpImageType *type,
|
||||
GError **error)
|
||||
{
|
||||
gint32 volatile image_ID = -1;
|
||||
GimpImage * volatile image = NULL;
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
struct my_error_mgr jerr;
|
||||
FILE *infile = NULL;
|
||||
|
@ -524,9 +524,9 @@ load_thumbnail_image (GFile *file,
|
|||
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
|
||||
g_file_get_parse_name (file));
|
||||
|
||||
image_ID = gimp_image_metadata_load_thumbnail (file, error);
|
||||
if (image_ID < 1)
|
||||
return -1;
|
||||
image = gimp_image_metadata_load_thumbnail (file, error);
|
||||
if (! image)
|
||||
return NULL;
|
||||
|
||||
cinfo.err = jpeg_std_error (&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
|
@ -538,10 +538,10 @@ load_thumbnail_image (GFile *file,
|
|||
_("Could not open '%s' for reading: %s"),
|
||||
g_file_get_parse_name (file), g_strerror (errno));
|
||||
|
||||
if (image_ID != -1)
|
||||
gimp_image_delete (image_ID);
|
||||
if (image)
|
||||
gimp_image_delete (image);
|
||||
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Establish the setjmp return context for my_error_exit to use. */
|
||||
|
@ -553,10 +553,10 @@ load_thumbnail_image (GFile *file,
|
|||
*/
|
||||
jpeg_destroy_decompress (&cinfo);
|
||||
|
||||
if (image_ID != -1)
|
||||
gimp_image_delete (image_ID);
|
||||
if (image)
|
||||
gimp_image_delete (image);
|
||||
|
||||
return -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Now we can initialize the JPEG decompression object. */
|
||||
|
@ -599,8 +599,8 @@ load_thumbnail_image (GFile *file,
|
|||
cinfo.output_components, cinfo.out_color_space,
|
||||
cinfo.jpeg_color_space);
|
||||
|
||||
gimp_image_delete (image_ID);
|
||||
image_ID = -1;
|
||||
gimp_image_delete (image);
|
||||
image = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -613,7 +613,7 @@ load_thumbnail_image (GFile *file,
|
|||
|
||||
fclose (infile);
|
||||
|
||||
return image_ID;
|
||||
return image;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
#ifndef __JPEG_LOAD_H__
|
||||
#define __JPEG_LOAD_H__
|
||||
|
||||
gint32 load_image (const gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview,
|
||||
gboolean *resolution_loaded,
|
||||
GError **error);
|
||||
GimpImage * load_image (const gchar *filename,
|
||||
GimpRunMode runmode,
|
||||
gboolean preview,
|
||||
gboolean *resolution_loaded,
|
||||
GError **error);
|
||||
|
||||
gint32 load_thumbnail_image (GFile *file,
|
||||
gint *width,
|
||||
gint *height,
|
||||
GimpImageType *type,
|
||||
GError **error);
|
||||
GimpImage * load_thumbnail_image (GFile *file,
|
||||
gint *width,
|
||||
gint *height,
|
||||
GimpImageType *type,
|
||||
GError **error);
|
||||
|
||||
#endif /* __JPEG_LOAD_H__ */
|
||||
|
|
|
@ -261,9 +261,9 @@ background_jpeg_save (PreviewPersistent *pp)
|
|||
|
||||
gboolean
|
||||
save_image (const gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
GimpImage *orig_image,
|
||||
gboolean preview,
|
||||
GError **error)
|
||||
{
|
||||
|
@ -285,9 +285,9 @@ save_image (const gchar *filename,
|
|||
gboolean out_linear = FALSE;
|
||||
gint rowstride, yend;
|
||||
|
||||
drawable_type = gimp_drawable_type (drawable_ID);
|
||||
buffer = gimp_drawable_get_buffer (drawable_ID);
|
||||
space = gimp_drawable_get_format (drawable_ID);
|
||||
drawable_type = gimp_drawable_type (drawable);
|
||||
buffer = gimp_drawable_get_buffer (drawable);
|
||||
space = gimp_drawable_get_format (drawable);
|
||||
|
||||
if (! preview)
|
||||
gimp_progress_init_printf (_("Exporting '%s'"),
|
||||
|
@ -346,7 +346,7 @@ save_image (const gchar *filename,
|
|||
*/
|
||||
if (jsvals.save_profile)
|
||||
{
|
||||
profile = gimp_image_get_color_profile (orig_image_ID);
|
||||
profile = gimp_image_get_color_profile (orig_image);
|
||||
|
||||
/* If a profile is explicitly set, follow its TRC, whatever the
|
||||
* storage format.
|
||||
|
@ -357,11 +357,11 @@ save_image (const gchar *filename,
|
|||
if (! profile)
|
||||
{
|
||||
/* There is always an effective profile. */
|
||||
profile = gimp_image_get_effective_color_profile (orig_image_ID);
|
||||
profile = gimp_image_get_effective_color_profile (orig_image);
|
||||
|
||||
if (gimp_color_profile_is_linear (profile))
|
||||
{
|
||||
if (gimp_image_get_precision (image_ID) != GIMP_PRECISION_U8_LINEAR)
|
||||
if (gimp_image_get_precision (image) != GIMP_PRECISION_U8_LINEAR)
|
||||
{
|
||||
GimpColorProfile *saved_profile;
|
||||
|
||||
|
@ -390,7 +390,7 @@ save_image (const gchar *filename,
|
|||
g_printerr ("%s: error getting the profile space: %s",
|
||||
G_STRFUNC, (*error)->message);
|
||||
g_clear_error (error);
|
||||
space = gimp_drawable_get_format (drawable_ID);
|
||||
space = gimp_drawable_get_format (drawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,7 +476,7 @@ save_image (const gchar *filename,
|
|||
gint t;
|
||||
|
||||
/* override tables generated by jpeg_set_quality() with custom tables */
|
||||
quant_tables = jpeg_restore_original_tables (image_ID, num_quant_tables);
|
||||
quant_tables = jpeg_restore_original_tables (image, num_quant_tables);
|
||||
if (quant_tables)
|
||||
{
|
||||
for (t = 0; t < num_quant_tables; t++)
|
||||
|
@ -498,7 +498,7 @@ save_image (const gchar *filename,
|
|||
else
|
||||
cinfo.optimize_coding = jsvals.optimize;
|
||||
|
||||
subsampling = (gimp_drawable_is_rgb (drawable_ID) ?
|
||||
subsampling = (gimp_drawable_is_rgb (drawable) ?
|
||||
jsvals.subsmp : JPEG_SUBSAMPLING_1x1_1x1_1x1);
|
||||
|
||||
/* smoothing is not supported with nonstandard sampling ratios */
|
||||
|
@ -576,13 +576,13 @@ save_image (const gchar *filename,
|
|||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
|
||||
gimp_image_get_resolution (orig_image_ID, &xresolution, &yresolution);
|
||||
gimp_image_get_resolution (orig_image, &xresolution, &yresolution);
|
||||
|
||||
if (xresolution > 1e-5 && yresolution > 1e-5)
|
||||
{
|
||||
gdouble factor;
|
||||
|
||||
factor = gimp_unit_get_factor (gimp_image_get_unit (orig_image_ID));
|
||||
factor = gimp_unit_get_factor (gimp_image_get_unit (orig_image));
|
||||
|
||||
if (factor == 2.54 /* cm */ ||
|
||||
factor == 25.4 /* mm */)
|
||||
|
@ -746,19 +746,19 @@ make_preview (void)
|
|||
{
|
||||
/* we freeze undo saving so that we can avoid sucking up
|
||||
* tile cache with our unneeded preview steps. */
|
||||
gimp_image_undo_freeze (preview_image_ID);
|
||||
gimp_image_undo_freeze (preview_image);
|
||||
|
||||
undo_touched = TRUE;
|
||||
}
|
||||
|
||||
save_image (tn,
|
||||
preview_image_ID,
|
||||
drawable_ID_global,
|
||||
orig_image_ID_global,
|
||||
preview_image,
|
||||
drawable_global,
|
||||
orig_image_global,
|
||||
TRUE, NULL);
|
||||
|
||||
if (display_ID == -1)
|
||||
display_ID = gimp_display_new (preview_image_ID);
|
||||
if (! display)
|
||||
display = gimp_display_new (preview_image);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -779,15 +779,15 @@ destroy_preview (void)
|
|||
g_source_remove (id);
|
||||
}
|
||||
|
||||
if (gimp_image_is_valid (preview_image_ID) &&
|
||||
gimp_item_is_valid (preview_layer_ID))
|
||||
if (gimp_image_is_valid (preview_image) &&
|
||||
gimp_item_is_valid (preview_layer))
|
||||
{
|
||||
/* assuming that reference counting is working correctly,
|
||||
we do not need to delete the layer, removing it from
|
||||
the image should be sufficient */
|
||||
gimp_image_remove_layer (preview_image_ID, preview_layer_ID);
|
||||
gimp_image_remove_layer (preview_image, preview_layer);
|
||||
|
||||
preview_layer_ID = -1;
|
||||
preview_layer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ save_dialog (void)
|
|||
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||
|
||||
if (gimp_drawable_is_rgb (drawable_ID_global))
|
||||
if (gimp_drawable_is_rgb (drawable_global))
|
||||
{
|
||||
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
|
||||
jsvals.subsmp,
|
||||
|
@ -1439,7 +1439,7 @@ load_gui_defaults (JpegSaveGui *pg)
|
|||
{
|
||||
gtk_adjustment_set_value (pg->quality, jsvals.quality);
|
||||
|
||||
if (gimp_drawable_is_rgb (drawable_ID_global))
|
||||
if (gimp_drawable_is_rgb (drawable_global))
|
||||
{
|
||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (pg->subsmp),
|
||||
jsvals.subsmp);
|
||||
|
|
|
@ -40,14 +40,14 @@ typedef struct
|
|||
|
||||
extern JpegSaveVals jsvals;
|
||||
|
||||
extern gint32 orig_image_ID_global;
|
||||
extern gint32 drawable_ID_global;
|
||||
extern GimpImage *orig_image_global;
|
||||
extern GimpDrawable *drawable_global;
|
||||
|
||||
|
||||
gboolean save_image (const gchar *filename,
|
||||
gint32 image_ID,
|
||||
gint32 drawable_ID,
|
||||
gint32 orig_image_ID,
|
||||
GimpImage *image,
|
||||
GimpDrawable *drawable,
|
||||
GimpImage *orig_image,
|
||||
gboolean preview,
|
||||
GError **error);
|
||||
gboolean save_dialog (void);
|
||||
|
|
|
@ -61,21 +61,21 @@
|
|||
/**
|
||||
* jpeg_detect_original_settings:
|
||||
* @cinfo: a pointer to a JPEG decompressor info.
|
||||
* @image_ID: the image to which the parasite should be attached.
|
||||
* @image: the image to which the parasite should be attached.
|
||||
*
|
||||
* Analyze the image being decompressed (@cinfo) and extract the
|
||||
* sampling factors, quantization tables and overall image quality.
|
||||
* Store this information in a parasite and attach it to @image_ID.
|
||||
* Store this information in a parasite and attach it to @image.
|
||||
*
|
||||
* This function must be called after jpeg_read_header() so that
|
||||
* @cinfo contains the quantization tables and the sampling factors
|
||||
* for each component.
|
||||
*
|
||||
* Returns: TRUE if a parasite has been attached to @image_ID.
|
||||
* Returns: TRUE if a parasite has been attached to @image.
|
||||
*/
|
||||
gboolean
|
||||
jpeg_detect_original_settings (struct jpeg_decompress_struct *cinfo,
|
||||
gint32 image_ID)
|
||||
GimpImage *image)
|
||||
{
|
||||
guint parasite_size;
|
||||
guchar *parasite_data;
|
||||
|
@ -132,8 +132,9 @@ jpeg_detect_original_settings (struct jpeg_decompress_struct *cinfo,
|
|||
parasite_size,
|
||||
parasite_data);
|
||||
g_free (parasite_data);
|
||||
gimp_image_attach_parasite (image_ID, parasite);
|
||||
gimp_image_attach_parasite (image, parasite);
|
||||
gimp_parasite_free (parasite);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -143,28 +144,28 @@ jpeg_detect_original_settings (struct jpeg_decompress_struct *cinfo,
|
|||
* GIMP color space of the drawable to be saved. If one of them is
|
||||
* grayscale and the other isn't, then the quality setting may be used
|
||||
* but the subsampling parameters and quantization tables should be
|
||||
* ignored. The drawable_ID needs to be passed around because the
|
||||
* ignored. The drawable needs to be passed around because the
|
||||
* color space of the drawable may be different from that of the image
|
||||
* (e.g., when saving a mask or channel).
|
||||
*/
|
||||
|
||||
/**
|
||||
* jpeg_restore_original_settings:
|
||||
* @image_ID: the image that may contain original jpeg settings in a parasite.
|
||||
* @image: the image that may contain original jpeg settings in a parasite.
|
||||
* @quality: where to store the original jpeg quality.
|
||||
* @subsmp: where to store the original subsampling type.
|
||||
* @num_quant_tables: where to store the number of quantization tables found.
|
||||
*
|
||||
* Retrieve the original JPEG settings (quality, type of subsampling
|
||||
* and number of quantization tables) from the parasite attached to
|
||||
* @image_ID. If the number of quantization tables is greater than
|
||||
* @image. If the number of quantization tables is greater than
|
||||
* zero, then these tables can be retrieved from the parasite by
|
||||
* calling jpeg_restore_original_tables().
|
||||
*
|
||||
* Returns: TRUE if a valid parasite was attached to the image
|
||||
*/
|
||||
gboolean
|
||||
jpeg_restore_original_settings (gint32 image_ID,
|
||||
jpeg_restore_original_settings (GimpImage *image,
|
||||
gint *quality,
|
||||
JpegSubsampling *subsmp,
|
||||
gint *num_quant_tables)
|
||||
|
@ -183,7 +184,7 @@ jpeg_restore_original_settings (gint32 image_ID,
|
|||
g_return_val_if_fail (subsmp != NULL, FALSE);
|
||||
g_return_val_if_fail (num_quant_tables != NULL, FALSE);
|
||||
|
||||
parasite = gimp_image_get_parasite (image_ID, "jpeg-settings");
|
||||
parasite = gimp_image_get_parasite (image, "jpeg-settings");
|
||||
if (parasite)
|
||||
{
|
||||
src = gimp_parasite_data (parasite);
|
||||
|
@ -248,11 +249,11 @@ jpeg_restore_original_settings (gint32 image_ID,
|
|||
|
||||
/**
|
||||
* jpeg_restore_original_tables:
|
||||
* @image_ID: the image that may contain original jpeg settings in a parasite.
|
||||
* @image: the image that may contain original jpeg settings in a parasite.
|
||||
* @num_quant_tables: the number of quantization tables to restore.
|
||||
*
|
||||
* Retrieve the original quantization tables from the parasite
|
||||
* attached to @image_ID. Each table is an array of coefficients that
|
||||
* attached to @image. Each table is an array of coefficients that
|
||||
* can be associated with a component of a JPEG image when saving it.
|
||||
*
|
||||
* An array of newly allocated tables is returned if @num_quant_tables
|
||||
|
@ -267,8 +268,8 @@ jpeg_restore_original_settings (gint32 image_ID,
|
|||
* Returns: (nullable): an array of quantization tables, or NULL.
|
||||
*/
|
||||
guint **
|
||||
jpeg_restore_original_tables (gint32 image_ID,
|
||||
gint num_quant_tables)
|
||||
jpeg_restore_original_tables (GimpImage *image,
|
||||
gint num_quant_tables)
|
||||
{
|
||||
GimpParasite *parasite;
|
||||
const guchar *src;
|
||||
|
@ -279,7 +280,7 @@ jpeg_restore_original_tables (gint32 image_ID,
|
|||
gint t;
|
||||
gint i;
|
||||
|
||||
parasite = gimp_image_get_parasite (image_ID, "jpeg-settings");
|
||||
parasite = gimp_image_get_parasite (image, "jpeg-settings");
|
||||
if (parasite)
|
||||
{
|
||||
src_size = gimp_parasite_data_size (parasite);
|
||||
|
@ -319,7 +320,7 @@ jpeg_restore_original_tables (gint32 image_ID,
|
|||
|
||||
/**
|
||||
* jpeg_swap_original_settings:
|
||||
* @image_ID: the image that may contain original jpeg settings in a parasite.
|
||||
* @image: the image that may contain original jpeg settings in a parasite.
|
||||
*
|
||||
* Swap the horizontal and vertical axis for the saved subsampling
|
||||
* parameters and quantization tables. This should be done if the
|
||||
|
@ -327,7 +328,7 @@ jpeg_restore_original_tables (gint32 image_ID,
|
|||
* mirrored along its diagonal.
|
||||
*/
|
||||
void
|
||||
jpeg_swap_original_settings (gint32 image_ID)
|
||||
jpeg_swap_original_settings (GimpImage *image)
|
||||
{
|
||||
GimpParasite *parasite;
|
||||
const guchar *src;
|
||||
|
@ -340,7 +341,7 @@ jpeg_swap_original_settings (gint32 image_ID)
|
|||
gint i;
|
||||
gint j;
|
||||
|
||||
parasite = gimp_image_get_parasite (image_ID, "jpeg-settings");
|
||||
parasite = gimp_image_get_parasite (image, "jpeg-settings");
|
||||
if (parasite)
|
||||
{
|
||||
src_size = gimp_parasite_data_size (parasite);
|
||||
|
@ -389,7 +390,7 @@ jpeg_swap_original_settings (gint32 image_ID)
|
|||
src_size,
|
||||
new_data);
|
||||
g_free (new_data);
|
||||
gimp_image_attach_parasite (image_ID, parasite);
|
||||
gimp_image_attach_parasite (image, parasite);
|
||||
}
|
||||
}
|
||||
gimp_parasite_free (parasite);
|
||||
|
|
|
@ -22,16 +22,16 @@
|
|||
#define __JPEG_SETTINGS_H__
|
||||
|
||||
gboolean jpeg_detect_original_settings (struct jpeg_decompress_struct *cinfo,
|
||||
gint32 image_ID);
|
||||
GimpImage *image);
|
||||
|
||||
gboolean jpeg_restore_original_settings (gint32 image_ID,
|
||||
gboolean jpeg_restore_original_settings (GimpImage *image,
|
||||
gint *quality,
|
||||
JpegSubsampling *subsmp,
|
||||
gint *num_quant_tables);
|
||||
|
||||
guint **jpeg_restore_original_tables (gint32 image_ID,
|
||||
guint **jpeg_restore_original_tables (GimpImage *image,
|
||||
gint num_quant_tables);
|
||||
|
||||
void jpeg_swap_original_settings (gint32 image_ID);
|
||||
void jpeg_swap_original_settings (GimpImage *image);
|
||||
|
||||
#endif /* __JPEG_SETTINGS_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -51,11 +51,11 @@ typedef enum
|
|||
JPEG_SUBSAMPLING_1x2_1x1_1x1 = 3
|
||||
} JpegSubsampling;
|
||||
|
||||
extern gint32 volatile preview_image_ID;
|
||||
extern gint32 preview_layer_ID;
|
||||
extern GimpImage * volatile preview_image;
|
||||
extern GimpLayer * preview_layer;
|
||||
extern gboolean undo_touched;
|
||||
extern gboolean load_interactive;
|
||||
extern gint32 display_ID;
|
||||
extern GimpDisplay *display;
|
||||
extern gchar *image_comment;
|
||||
extern gint orig_quality;
|
||||
extern JpegSubsampling orig_subsmp;
|
||||
|
|
Loading…
Reference in New Issue