Commit 9d439fe0 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added gimp_buffer_new_from_pixbuf().

2005-04-09  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpbuffer.[ch]: added gimp_buffer_new_from_pixbuf().

	* app/widgets/gimpclipboard.c: removed
	tile_manager_new_from_pixbuf() and base/ dependency.
parent b31216d0
2005-04-09 Michael Natterer <mitch@gimp.org>
* app/core/gimpbuffer.[ch]: added gimp_buffer_new_from_pixbuf().
* app/widgets/gimpclipboard.c: removed
tile_manager_new_from_pixbuf() and base/ dependency.
2005-04-09 Manish Singh <yosh@gimp.org>
* app/widgets/gimppixbuf.c: #include <string.h> for strcmp, and
......
......@@ -286,9 +286,8 @@ gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels)
{
GimpBuffer *buffer;
PixelRegion srcPR, destPR;
gint width, height;
GimpBuffer *buffer;
gint width, height;
g_return_val_if_fail (tiles != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
......@@ -302,6 +301,8 @@ gimp_buffer_new (TileManager *tiles,
if (copy_pixels)
{
PixelRegion srcPR, destPR;
buffer->tiles = tile_manager_new (width, height,
tile_manager_bpp (tiles));
......@@ -317,6 +318,41 @@ gimp_buffer_new (TileManager *tiles,
return buffer;
}
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);
}
gint
gimp_buffer_get_width (const GimpBuffer *buffer)
{
......
......@@ -46,14 +46,16 @@ struct _GimpBufferClass
};
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GType gimp_buffer_get_type (void) G_GNUC_CONST;
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
GimpBuffer * gimp_buffer_new (TileManager *tiles,
const gchar *name,
gboolean copy_pixels);
GimpBuffer * gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
const gchar *name);
gint gimp_buffer_get_width (const GimpBuffer *buffer);
gint gimp_buffer_get_height (const GimpBuffer *buffer);
gint gimp_buffer_get_width (const GimpBuffer *buffer);
gint gimp_buffer_get_height (const GimpBuffer *buffer);
#endif /* __GIMP_BUFFER_H__ */
......@@ -24,9 +24,6 @@
#include "widgets-types.h"
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "core/gimp.h"
#include "core/gimpbuffer.h"
#include "core/gimpviewable.h"
......@@ -197,40 +194,6 @@ gimp_clipboard_has_buffer (Gimp *gimp)
return (gimp_clipboard_wait_for_buffer (gimp) != GDK_NONE);
}
static TileManager *
tile_manager_new_from_pixbuf (GdkPixbuf *pixbuf)
{
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);
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 tiles;
}
/**
* gimp_clipboard_get_buffer:
* @gimp: pointer to #Gimp
......@@ -274,11 +237,8 @@ gimp_clipboard_get_buffer (Gimp *gimp)
if (pixbuf)
{
TileManager *tiles = tile_manager_new_from_pixbuf (pixbuf);
buffer = gimp_buffer_new_from_pixbuf (pixbuf, _("Clipboard"));
g_object_unref (pixbuf);
buffer = gimp_buffer_new (tiles, _("Clipboard"), FALSE);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment