mirror of https://github.com/GNOME/gimp.git
pdb, libgimp, app: add gimp_drawable_get_thumbnail_format()
so plug-ins can allocate buffers and stuff before getting the actual thumbnail data.
This commit is contained in:
parent
0326a3e79a
commit
fc89dfb09b
|
@ -90,6 +90,36 @@ drawable_get_format_invoker (GimpProcedure *procedure,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
drawable_get_thumbnail_format_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpDrawable *drawable;
|
||||
gchar *format = NULL;
|
||||
|
||||
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
|
||||
|
||||
if (success)
|
||||
{
|
||||
format = g_strdup (babl_format_get_encoding (gimp_drawable_get_preview_format (drawable)));
|
||||
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), format);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
drawable_type_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -994,6 +1024,37 @@ register_drawable_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-drawable-get-thumbnail-format
|
||||
*/
|
||||
procedure = gimp_procedure_new (drawable_get_thumbnail_format_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-drawable-get-thumbnail-format");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-drawable-get-thumbnail-format",
|
||||
"Returns the drawable's thumbnail Babl format",
|
||||
"This procedure returns the drawable's thumbnail Babl format.\n"
|
||||
"Thumbnails are always 8-bit images, see 'gimp-drawable-thumbnail' and 'gimp-drawable-sub-thmbnail'.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2019",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_drawable_id ("drawable",
|
||||
"drawable",
|
||||
"The drawable",
|
||||
pdb->gimp, FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("format",
|
||||
"format",
|
||||
"The drawable's thumbnail Babl format",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-drawable-type
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 734 procedures registered total */
|
||||
/* 735 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -212,6 +212,7 @@ EXPORTS
|
|||
gimp_drawable_get_sub_thumbnail_data
|
||||
gimp_drawable_get_thumbnail
|
||||
gimp_drawable_get_thumbnail_data
|
||||
gimp_drawable_get_thumbnail_format
|
||||
gimp_drawable_get_tile
|
||||
gimp_drawable_has_alpha
|
||||
gimp_drawable_height
|
||||
|
|
|
@ -437,3 +437,24 @@ gimp_drawable_get_format (gint32 drawable_ID)
|
|||
|
||||
return format;
|
||||
}
|
||||
/**
|
||||
* gimp_drawable_get_thumbnail_format:
|
||||
* @drawable_ID: the ID of the #GimpDrawable to get the thumbnail format for.
|
||||
*
|
||||
* Returns the #Babl thumbnail format of the drawable.
|
||||
*
|
||||
* Return value: The #Babl thumbnail format.
|
||||
*
|
||||
* Since: 2.10.14
|
||||
*/
|
||||
const Babl *
|
||||
gimp_drawable_get_thumbnail_format (gint32 drawable_ID)
|
||||
{
|
||||
const Babl *format = NULL;
|
||||
gchar *format_str = _gimp_drawable_get_thumbnail_format (drawable_ID);
|
||||
|
||||
if (format_str)
|
||||
format = babl_format (format_str);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ GeglBuffer * gimp_drawable_get_buffer (gint32 drawable_ID)
|
|||
GeglBuffer * gimp_drawable_get_shadow_buffer (gint32 drawable_ID);
|
||||
|
||||
const Babl * gimp_drawable_get_format (gint32 drawable_ID);
|
||||
const Babl * gimp_drawable_get_thumbnail_format (gint32 drawable_ID);
|
||||
|
||||
GIMP_DEPRECATED_FOR(gimp_drawable_get_buffer)
|
||||
GimpDrawable * gimp_drawable_get (gint32 drawable_ID);
|
||||
|
|
|
@ -71,6 +71,40 @@ _gimp_drawable_get_format (gint32 drawable_ID)
|
|||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* _gimp_drawable_get_thumbnail_format:
|
||||
* @drawable_ID: The drawable.
|
||||
*
|
||||
* Returns the drawable's thumbnail Babl format
|
||||
*
|
||||
* This procedure returns the drawable's thumbnail Babl format.
|
||||
* Thumbnails are always 8-bit images, see gimp_drawable_thumbnail()
|
||||
* and gimp_drawable_sub_thmbnail().
|
||||
*
|
||||
* Returns: The drawable's thumbnail Babl format.
|
||||
*
|
||||
* Since: 2.10.14
|
||||
**/
|
||||
gchar *
|
||||
_gimp_drawable_get_thumbnail_format (gint32 drawable_ID)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *format = NULL;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-drawable-get-thumbnail-format",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
format = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_drawable_type:
|
||||
* @drawable_ID: The drawable.
|
||||
|
|
|
@ -33,6 +33,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
G_GNUC_INTERNAL gchar* _gimp_drawable_get_format (gint32 drawable_ID);
|
||||
G_GNUC_INTERNAL gchar* _gimp_drawable_get_thumbnail_format (gint32 drawable_ID);
|
||||
GimpImageType gimp_drawable_type (gint32 drawable_ID);
|
||||
GimpImageType gimp_drawable_type_with_alpha (gint32 drawable_ID);
|
||||
gboolean gimp_drawable_has_alpha (gint32 drawable_ID);
|
||||
|
|
|
@ -307,6 +307,38 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub drawable_get_thumbnail_format {
|
||||
$blurb = "Returns the drawable's thumbnail Babl format";
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns the drawable's thumbnail Babl format.
|
||||
|
||||
Thumbnails are always 8-bit images, see gimp_drawable_thumbnail() and
|
||||
gimp_drawable_sub_thmbnail().
|
||||
HELP
|
||||
|
||||
&mitch_pdb_misc('2019', '2.10.14');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'drawable', type => 'drawable',
|
||||
desc => 'The drawable' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'format', type => 'string', wrap => 1,
|
||||
desc => "The drawable's thumbnail Babl format" }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
format = g_strdup (babl_format_get_encoding (gimp_drawable_get_preview_format (drawable)));
|
||||
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub drawable_type {
|
||||
$blurb = "Returns the drawable's type.";
|
||||
$help = "This procedure returns the drawable's type.";
|
||||
|
@ -994,6 +1026,7 @@ CODE
|
|||
"gimp-intl.h");
|
||||
|
||||
@procs = qw(drawable_get_format
|
||||
drawable_get_thumbnail_format
|
||||
drawable_type
|
||||
drawable_type_with_alpha
|
||||
drawable_has_alpha
|
||||
|
|
Loading…
Reference in New Issue