Bug 765176 - ICC profile conversions between grayscale and RGB images
Add a dest_profile parameter to gimp_image_convert_type() so a profile can be chosen when converting between RGB and GRAY. Has no GUI yet.
This commit is contained in:
@ -195,7 +195,7 @@ image_convert_base_type_cmd_callback (GtkAction *action,
|
|||||||
if (dialog)
|
if (dialog)
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
|
|
||||||
if (! gimp_image_convert_type (image, value, NULL, &error))
|
if (! gimp_image_convert_type (image, value, NULL, NULL, &error))
|
||||||
{
|
{
|
||||||
gimp_message_literal (image->gimp,
|
gimp_message_literal (image->gimp,
|
||||||
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
||||||
|
@ -42,32 +42,38 @@
|
|||||||
gboolean
|
gboolean
|
||||||
gimp_image_convert_type (GimpImage *image,
|
gimp_image_convert_type (GimpImage *image,
|
||||||
GimpImageBaseType new_type,
|
GimpImageBaseType new_type,
|
||||||
|
GimpColorProfile *dest_profile,
|
||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GimpImageBaseType old_type;
|
GimpImageBaseType old_type;
|
||||||
|
const Babl *new_layer_format;
|
||||||
GList *all_layers;
|
GList *all_layers;
|
||||||
GList *list;
|
GList *list;
|
||||||
const gchar *undo_desc = NULL;
|
const gchar *undo_desc = NULL;
|
||||||
GimpProgress *sub_progress = NULL;
|
GimpProgress *sub_progress = NULL;
|
||||||
GimpColorProfile *dest_profile = NULL;
|
|
||||||
gint nth_layer;
|
gint nth_layer;
|
||||||
gint n_layers;
|
gint n_layers;
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (new_type != gimp_image_get_base_type (image), FALSE);
|
g_return_val_if_fail (new_type != gimp_image_get_base_type (image), FALSE);
|
||||||
g_return_val_if_fail (new_type != GIMP_INDEXED, FALSE);
|
g_return_val_if_fail (new_type != GIMP_INDEXED, FALSE);
|
||||||
|
g_return_val_if_fail (dest_profile == NULL || GIMP_IS_COLOR_PROFILE (dest_profile),
|
||||||
|
FALSE);
|
||||||
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
gimp_set_busy (image->gimp);
|
new_layer_format = gimp_babl_format (new_type,
|
||||||
|
gimp_image_get_precision (image),
|
||||||
|
TRUE);
|
||||||
|
|
||||||
all_layers = gimp_image_get_layer_list (image);
|
if (dest_profile &&
|
||||||
|
! gimp_image_validate_color_profile_by_format (new_layer_format,
|
||||||
n_layers = g_list_length (all_layers);
|
dest_profile,
|
||||||
|
NULL, error))
|
||||||
if (progress)
|
{
|
||||||
sub_progress = gimp_sub_progress_new (progress);
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
switch (new_type)
|
switch (new_type)
|
||||||
{
|
{
|
||||||
@ -83,6 +89,15 @@ gimp_image_convert_type (GimpImage *image,
|
|||||||
g_return_val_if_reached (FALSE);
|
g_return_val_if_reached (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gimp_set_busy (image->gimp);
|
||||||
|
|
||||||
|
all_layers = gimp_image_get_layer_list (image);
|
||||||
|
|
||||||
|
n_layers = g_list_length (all_layers);
|
||||||
|
|
||||||
|
if (progress)
|
||||||
|
sub_progress = gimp_sub_progress_new (progress);
|
||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (image));
|
g_object_freeze_notify (G_OBJECT (image));
|
||||||
|
|
||||||
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_CONVERT,
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_CONVERT,
|
||||||
@ -96,13 +111,13 @@ gimp_image_convert_type (GimpImage *image,
|
|||||||
|
|
||||||
g_object_set (image, "base-type", new_type, NULL);
|
g_object_set (image, "base-type", new_type, NULL);
|
||||||
|
|
||||||
/* when converting to/from GRAY, convert to the new type's builtin
|
/* When converting to/from GRAY, convert to the new type's builtin
|
||||||
* profile.
|
* profile if none was passed.
|
||||||
*/
|
*/
|
||||||
if (old_type == GIMP_GRAY ||
|
if (old_type == GIMP_GRAY ||
|
||||||
new_type == GIMP_GRAY)
|
new_type == GIMP_GRAY)
|
||||||
{
|
{
|
||||||
if (gimp_image_get_color_profile (image))
|
if (! dest_profile && gimp_image_get_color_profile (image))
|
||||||
dest_profile = gimp_image_get_builtin_color_profile (image);
|
dest_profile = gimp_image_get_builtin_color_profile (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
gboolean gimp_image_convert_type (GimpImage *image,
|
gboolean gimp_image_convert_type (GimpImage *image,
|
||||||
GimpImageBaseType new_type,
|
GimpImageBaseType new_type,
|
||||||
|
GimpColorProfile *dest_profile,
|
||||||
GimpProgress *progress,
|
GimpProgress *progress,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ image_convert_rgb_invoker (GimpProcedure *procedure,
|
|||||||
{
|
{
|
||||||
if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
|
if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
|
||||||
{
|
{
|
||||||
success = gimp_image_convert_type (image, GIMP_RGB, NULL, error);
|
success = gimp_image_convert_type (image, GIMP_RGB, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ image_convert_grayscale_invoker (GimpProcedure *procedure,
|
|||||||
{
|
{
|
||||||
if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
|
if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
|
||||||
{
|
{
|
||||||
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, error);
|
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -292,8 +292,8 @@ register_image_convert_procs (GimpPDB *pdb)
|
|||||||
"gimp-image-convert-grayscale");
|
"gimp-image-convert-grayscale");
|
||||||
gimp_procedure_set_static_strings (procedure,
|
gimp_procedure_set_static_strings (procedure,
|
||||||
"gimp-image-convert-grayscale",
|
"gimp-image-convert-grayscale",
|
||||||
"Convert specified image to grayscale (256 intensity levels)",
|
"Convert specified image to grayscale",
|
||||||
"This procedure converts the specified image to grayscale with 8 bits per pixel (256 intensity levels). This process requires an image in RGB or Indexed color mode.",
|
"This procedure converts the specified image to grayscale. This process requires an image in RGB or Indexed color mode.",
|
||||||
"Spencer Kimball & Peter Mattis",
|
"Spencer Kimball & Peter Mattis",
|
||||||
"Spencer Kimball & Peter Mattis",
|
"Spencer Kimball & Peter Mattis",
|
||||||
"1995-1996",
|
"1995-1996",
|
||||||
|
@ -70,11 +70,10 @@ gimp_image_convert_rgb (gint32 image_ID)
|
|||||||
* gimp_image_convert_grayscale:
|
* gimp_image_convert_grayscale:
|
||||||
* @image_ID: The image.
|
* @image_ID: The image.
|
||||||
*
|
*
|
||||||
* Convert specified image to grayscale (256 intensity levels)
|
* Convert specified image to grayscale
|
||||||
*
|
*
|
||||||
* This procedure converts the specified image to grayscale with 8 bits
|
* This procedure converts the specified image to grayscale. This
|
||||||
* per pixel (256 intensity levels). This process requires an image in
|
* process requires an image in RGB or Indexed color mode.
|
||||||
* RGB or Indexed color mode.
|
|
||||||
*
|
*
|
||||||
* Returns: TRUE on success.
|
* Returns: TRUE on success.
|
||||||
**/
|
**/
|
||||||
|
@ -37,7 +37,7 @@ HELP
|
|||||||
{
|
{
|
||||||
if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
|
if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
|
||||||
{
|
{
|
||||||
success = gimp_image_convert_type (image, GIMP_RGB, NULL, error);
|
success = gimp_image_convert_type (image, GIMP_RGB, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -49,12 +49,11 @@ CODE
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub image_convert_grayscale {
|
sub image_convert_grayscale {
|
||||||
$blurb = 'Convert specified image to grayscale (256 intensity levels)';
|
$blurb = 'Convert specified image to grayscale';
|
||||||
|
|
||||||
$help = <<'HELP';
|
$help = <<'HELP';
|
||||||
This procedure converts the specified image to grayscale with 8 bits
|
This procedure converts the specified image to grayscale. This process
|
||||||
per pixel (256 intensity levels). This process requires an image in RGB
|
requires an image in RGB or Indexed color mode.
|
||||||
or Indexed color mode.
|
|
||||||
HELP
|
HELP
|
||||||
|
|
||||||
&std_pdb_misc;
|
&std_pdb_misc;
|
||||||
@ -69,7 +68,7 @@ HELP
|
|||||||
{
|
{
|
||||||
if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
|
if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
|
||||||
{
|
{
|
||||||
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, error);
|
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user