void gimp_create_image_from_buffer (Gimp *gimp, GeglBuffer *buffer) { GimpImage *image; GimpLayer *layer; const Babl *format; g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GEGL_IS_BUFFER (buffer)); format = gegl_buffer_get_format (buffer); image = gimp_create_image (gimp, gegl_buffer_get_width (buffer), gegl_buffer_get_height (buffer), gimp_babl_format_get_base_type (format), gimp_babl_format_get_precision (format), FALSE); layer = gimp_layer_new_from_buffer (buffer, image, format, "Debug Image", GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); gimp_image_add_layer (image, layer, NULL, -1, FALSE); gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0); }
static void gimp_text_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpTextUndo *text_undo = GIMP_TEXT_UNDO (undo); GimpTextLayer *layer = GIMP_TEXT_LAYER (GIMP_ITEM_UNDO (undo)->item); GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); switch (undo->undo_type) { case GIMP_UNDO_TEXT_LAYER: if (text_undo->pspec) { GValue *value; g_return_if_fail (layer->text != NULL); value = g_slice_new0 (GValue); g_value_init (value, text_undo->pspec->value_type); g_object_get_property (G_OBJECT (layer->text), text_undo->pspec->name, value); g_object_set_property (G_OBJECT (layer->text), text_undo->pspec->name, text_undo->value); g_value_unset (text_undo->value); g_slice_free (GValue, text_undo->value); text_undo->value = value; } else { GimpText *text; text = (layer->text ? gimp_config_duplicate (GIMP_CONFIG (layer->text)) : NULL); if (layer->text && text_undo->text) gimp_config_sync (G_OBJECT (text_undo->text), G_OBJECT (layer->text), 0); else gimp_text_layer_set_text (layer, text_undo->text); if (text_undo->text) g_object_unref (text_undo->text); text_undo->text = text; } break; case GIMP_UNDO_TEXT_LAYER_MODIFIED: { gboolean modified; #if 0 g_print ("setting layer->modified from %s to %s\n", layer->modified ? "TRUE" : "FALSE", text_undo->modified ? "TRUE" : "FALSE"); #endif modified = layer->modified; g_object_set (layer, "modified", text_undo->modified, NULL); text_undo->modified = modified; gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer)); } break; case GIMP_UNDO_TEXT_LAYER_CONVERT: { const Babl *format; format = gimp_drawable_get_format (GIMP_DRAWABLE (layer)); gimp_drawable_convert_type (GIMP_DRAWABLE (layer), gimp_item_get_image (GIMP_ITEM (layer)), gimp_babl_format_get_base_type (text_undo->format), gimp_babl_format_get_precision (text_undo->format), 0, 0, FALSE); text_undo->format = format; } break; default: g_assert_not_reached (); } }
static void gimp_color_frame_update (GimpColorFrame *frame) { const gchar *names[GIMP_COLOR_FRAME_ROWS] = { NULL, }; gchar **values = NULL; gboolean has_alpha; gint i; has_alpha = babl_format_has_alpha (frame->sample_format); if (frame->sample_valid) { gimp_color_area_set_color (GIMP_COLOR_AREA (frame->color_area), &frame->color); } switch (frame->frame_mode) { case GIMP_COLOR_FRAME_MODE_PIXEL: { GimpImageBaseType base_type; base_type = gimp_babl_format_get_base_type (frame->sample_format); if (frame->sample_valid) { const Babl *print_format = NULL; guchar print_pixel[32]; switch (gimp_babl_format_get_precision (frame->sample_format)) { case GIMP_PRECISION_U8_GAMMA: if (babl_format_is_palette (frame->sample_format)) { print_format = gimp_babl_format (GIMP_RGB, GIMP_PRECISION_U8_GAMMA, has_alpha); break; } /* else fall thru */ case GIMP_PRECISION_U8_LINEAR: case GIMP_PRECISION_U16_LINEAR: case GIMP_PRECISION_U16_GAMMA: case GIMP_PRECISION_U32_LINEAR: case GIMP_PRECISION_U32_GAMMA: case GIMP_PRECISION_FLOAT_LINEAR: case GIMP_PRECISION_FLOAT_GAMMA: case GIMP_PRECISION_DOUBLE_LINEAR: case GIMP_PRECISION_DOUBLE_GAMMA: print_format = frame->sample_format; break; case GIMP_PRECISION_HALF_GAMMA: print_format = gimp_babl_format (base_type, GIMP_PRECISION_FLOAT_GAMMA, has_alpha); break; case GIMP_PRECISION_HALF_LINEAR: print_format = gimp_babl_format (base_type, GIMP_PRECISION_FLOAT_LINEAR, has_alpha); break; } if (frame->sample_average) { /* FIXME: this is broken: can't use the averaged sRGB GimpRGB * value for displaying pixel values when color management * is enabled */ gimp_rgba_get_pixel (&frame->color, print_format, print_pixel); } else { babl_process (babl_fish (frame->sample_format, print_format), frame->pixel, print_pixel, 1); } values = gimp_babl_print_pixel (print_format, print_pixel); } if (base_type == GIMP_GRAY) { names[0] = _("Value:"); if (has_alpha) names[1] = _("Alpha:"); } else { names[0] = _("Red:"); names[1] = _("Green:"); names[2] = _("Blue:"); if (has_alpha) names[3] = _("Alpha:"); if (babl_format_is_palette (frame->sample_format)) { names[4] = _("Index:"); if (frame->sample_valid) { gchar **v = g_new0 (gchar *, 6); gchar **tmp = values; memcpy (v, values, 4 * sizeof (gchar *)); values = v; g_free (tmp); if (! frame->sample_average) values[4] = g_strdup_printf ("%d", frame->pixel[0]); } } } }