GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf, const gchar *name) { TileManager *tiles; guchar *pixels; PixelRegion destPR; gint width; gint height; gint rowstride; gint channels; gint y; g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); g_return_val_if_fail (name != NULL, NULL); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf); channels = gdk_pixbuf_get_n_channels (pixbuf); tiles = tile_manager_new (width, height, channels); pixel_region_init (&destPR, tiles, 0, 0, width, height, TRUE); for (y = 0, pixels = gdk_pixbuf_get_pixels (pixbuf); y < height; y++, pixels += rowstride) { pixel_region_set_row (&destPR, 0, y, width, pixels); } return gimp_buffer_new (tiles, name, FALSE); }
GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf, const gchar *name, gint offset_x, gint offset_y) { GimpBuffer *gimp_buffer; GeglBuffer *buffer; guint8 *icc_data; gsize icc_len; g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); g_return_val_if_fail (name != NULL, NULL); buffer = gimp_pixbuf_create_buffer (pixbuf); gimp_buffer = gimp_buffer_new (buffer, name, offset_x, offset_y, FALSE); icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len); if (icc_data) { gimp_buffer_set_icc_profile (gimp_buffer, icc_data, icc_len); g_free (icc_data); } g_object_unref (buffer); return gimp_buffer; }
static GimpBuffer * gimp_edit_extract (GimpImage *image, GimpPickable *pickable, GimpContext *context, gboolean cut_pixels, GError **error) { GeglBuffer *buffer; gint offset_x; gint offset_y; if (cut_pixels) gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_CUT, C_("undo-type", "Cut")); /* Cut/copy the mask portion from the image */ buffer = gimp_selection_extract (GIMP_SELECTION (gimp_image_get_mask (image)), pickable, context, cut_pixels, FALSE, &offset_x, &offset_y, error); if (cut_pixels) gimp_image_undo_group_end (image); if (buffer) { GimpBuffer *gimp_buffer; gdouble res_x; gdouble res_y; gimp_buffer = gimp_buffer_new (buffer, _("Global Buffer"), offset_x, offset_y, FALSE); g_object_unref (buffer); gimp_image_get_resolution (image, &res_x, &res_y); gimp_buffer_set_resolution (gimp_buffer, res_x, res_y); gimp_buffer_set_unit (gimp_buffer, gimp_image_get_unit (image)); if (GIMP_IS_COLOR_MANAGED (pickable)) { GimpColorProfile *profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (pickable)); if (profile) gimp_buffer_set_color_profile (gimp_buffer, profile); } return gimp_buffer; } return NULL; }
GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf, const gchar *name, gint offset_x, gint offset_y) { GimpBuffer *gimp_buffer; GeglBuffer *buffer; guint8 *icc_data; gsize icc_len; GimpColorProfile *profile = NULL; g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); g_return_val_if_fail (name != NULL, NULL); buffer = gimp_pixbuf_create_buffer (pixbuf); gimp_buffer = gimp_buffer_new (buffer, name, offset_x, offset_y, FALSE); icc_data = gimp_pixbuf_get_icc_profile (pixbuf, &icc_len); if (icc_data) { profile = gimp_color_profile_new_from_icc_profile (icc_data, icc_len, NULL); g_free (icc_data); } if (! profile && gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB) { profile = gimp_color_profile_new_rgb_srgb (); } if (profile) { gimp_buffer_set_color_profile (gimp_buffer, profile); g_object_unref (profile); } g_object_unref (buffer); return gimp_buffer; }
GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf, const gchar *name, gint offset_x, gint offset_y) { GimpBuffer *gimp_buffer; GeglBuffer *buffer; g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); g_return_val_if_fail (name != NULL, NULL); buffer = gimp_pixbuf_create_buffer (pixbuf); gimp_buffer = gimp_buffer_new (buffer, name, offset_x, offset_y, FALSE); g_object_unref (buffer); return gimp_buffer; }