static GimpValueArray * image_convert_precision_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GimpValueArray *args, GError **error) { gboolean success = TRUE; GimpImage *image; gint32 precision; image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp); precision = g_value_get_enum (gimp_value_array_index (args, 1)); if (success) { if (gimp->plug_in_manager->current_plug_in) gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in); if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) && gimp_pdb_image_is_not_precision (image, precision, error)) { gimp_image_convert_precision (image, precision, 0, 0, 0, NULL); } else { success = FALSE; } } return gimp_procedure_get_return_values (procedure, success, error ? *error : NULL); }
static void convert_precision_dialog_response (GtkWidget *widget, gint response_id, ConvertDialog *dialog) { if (response_id == GTK_RESPONSE_OK) { GimpProgress *progress; GimpPrecision precision; const gchar *enum_desc; precision = gimp_babl_precision (dialog->component_type, dialog->linear); gimp_enum_get_value (GIMP_TYPE_PRECISION, precision, NULL, NULL, &enum_desc, NULL); progress = gimp_progress_start (dialog->progress, FALSE, _("Converting image to %s"), enum_desc); gimp_image_convert_precision (dialog->image, precision, dialog->layer_dither_type, dialog->text_layer_dither_type, dialog->mask_dither_type, progress); if (progress) gimp_progress_end (progress); gimp_image_flush (dialog->image); /* gegl:color-reduction only does 16 bits */ if (dialog->bits <= 16) { /* Save defaults for next time */ saved_layer_dither_type = dialog->layer_dither_type; saved_text_layer_dither_type = dialog->text_layer_dither_type; saved_mask_dither_type = dialog->mask_dither_type; } } gtk_widget_destroy (dialog->dialog); }
static void convert_precision_dialog_response (GtkWidget *widget, gint response_id, ConvertDialog *dialog) { if (response_id == GTK_RESPONSE_OK) { GimpProgress *progress; progress = gimp_progress_start (dialog->progress, FALSE, _("Converting to lower bit depth")); gimp_image_convert_precision (dialog->image, dialog->precision, dialog->layer_dither_type, dialog->text_layer_dither_type, dialog->mask_dither_type, progress); if (progress) gimp_progress_end (progress); gimp_image_flush (dialog->image); /* gegl:color-reduction only does 16 bits */ if (dialog->bits <= 16) { /* Save defaults for next time */ saved_layer_dither_type = dialog->layer_dither_type; saved_text_layer_dither_type = dialog->text_layer_dither_type; saved_mask_dither_type = dialog->mask_dither_type; } } gtk_widget_destroy (dialog->dialog); }
void file_import_image (GimpImage *image, GimpContext *context, GFile *file, gboolean interactive, GimpProgress *progress) { GimpCoreConfig *config; g_return_if_fail (GIMP_IS_IMAGE (image)); g_return_if_fail (GIMP_IS_CONTEXT (context)); g_return_if_fail (G_IS_FILE (file)); g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress)); config = image->gimp->config; if (interactive && gimp_image_get_base_type (image) != GIMP_INDEXED) { if (config->import_promote_float) { GimpPrecision old_precision = gimp_image_get_precision (image); if (old_precision != GIMP_PRECISION_FLOAT_LINEAR) { gimp_image_convert_precision (image, GIMP_PRECISION_FLOAT_LINEAR, GEGL_DITHER_NONE, GEGL_DITHER_NONE, GEGL_DITHER_NONE, progress); if (config->import_promote_dither && old_precision == GIMP_PRECISION_U8_NON_LINEAR) { gimp_image_convert_dither_u8 (image, progress); } } } if (config->import_add_alpha) { GList *layers = gimp_image_get_layer_list (image); GList *list; for (list = layers; list; list = g_list_next (list)) { if (! gimp_viewable_get_children (list->data) && ! gimp_item_is_text_layer (list->data) && ! gimp_drawable_has_alpha (list->data)) { gimp_layer_add_alpha (list->data); } } g_list_free (layers); } } gimp_image_import_color_profile (image, context, progress, interactive); /* Remember the import source */ gimp_image_set_imported_file (image, file); /* We shall treat this file as an Untitled file */ gimp_image_set_file (image, NULL); }