app: remove image_type API from GimpBuffer

This commit is contained in:
Michael Natterer 2012-04-07 02:43:18 +02:00
parent ec2d5647c0
commit baa5ceb1e7
6 changed files with 19 additions and 33 deletions

View File

@ -582,11 +582,7 @@ gimp_edit_extract (GimpImage *image,
if (buffer) if (buffer)
{ {
GimpBuffer *gimp_buffer; GimpBuffer *gimp_buffer = gimp_buffer_new (buffer, _("Global Buffer"),
const Babl *format = gegl_buffer_get_format (buffer);
gimp_buffer = gimp_buffer_new (buffer, _("Global Buffer"),
GIMP_IMAGE_TYPE_FROM_BYTES (babl_format_get_bytes_per_pixel (format)),
offset_x, offset_y, FALSE); offset_x, offset_y, FALSE);
g_object_unref (buffer); g_object_unref (buffer);

View File

@ -228,7 +228,6 @@ gimp_buffer_get_description (GimpViewable *viewable,
GimpBuffer * GimpBuffer *
gimp_buffer_new (GeglBuffer *buffer, gimp_buffer_new (GeglBuffer *buffer,
const gchar *name, const gchar *name,
GimpImageType image_type,
gint offset_x, gint offset_x,
gint offset_y, gint offset_y,
gboolean copy_pixels) gboolean copy_pixels)
@ -247,7 +246,6 @@ gimp_buffer_new (GeglBuffer *buffer,
else else
gimp_buffer->buffer = g_object_ref (buffer); gimp_buffer->buffer = g_object_ref (buffer);
gimp_buffer->image_type = image_type;
gimp_buffer->offset_x = offset_x; gimp_buffer->offset_x = offset_x;
gimp_buffer->offset_y = offset_y; gimp_buffer->offset_y = offset_y;
@ -262,17 +260,13 @@ gimp_buffer_new_from_pixbuf (GdkPixbuf *pixbuf,
{ {
GimpBuffer *gimp_buffer; GimpBuffer *gimp_buffer;
GeglBuffer *buffer; GeglBuffer *buffer;
gint channels;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL); g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (name != NULL, NULL);
channels = gdk_pixbuf_get_n_channels (pixbuf);
buffer = gimp_pixbuf_create_buffer (pixbuf); buffer = gimp_pixbuf_create_buffer (pixbuf);
gimp_buffer = gimp_buffer_new (buffer, name, gimp_buffer = gimp_buffer_new (buffer, name,
GIMP_IMAGE_TYPE_FROM_BYTES (channels),
offset_x, offset_y, FALSE); offset_x, offset_y, FALSE);
g_object_unref (buffer); g_object_unref (buffer);
@ -304,14 +298,6 @@ gimp_buffer_get_format (const GimpBuffer *buffer)
return gegl_buffer_get_format (buffer->buffer); return gegl_buffer_get_format (buffer->buffer);
} }
GimpImageType
gimp_buffer_get_image_type (const GimpBuffer *buffer)
{
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
return buffer->image_type;
}
GeglBuffer * GeglBuffer *
gimp_buffer_get_buffer (const GimpBuffer *buffer) gimp_buffer_get_buffer (const GimpBuffer *buffer)
{ {

View File

@ -37,7 +37,6 @@ struct _GimpBuffer
GimpViewable parent_instance; GimpViewable parent_instance;
GeglBuffer *buffer; GeglBuffer *buffer;
GimpImageType image_type;
gint offset_x; gint offset_x;
gint offset_y; gint offset_y;
}; };
@ -52,7 +51,6 @@ GType gimp_buffer_get_type (void) G_GNUC_CONST;
GimpBuffer * gimp_buffer_new (GeglBuffer *buffer, GimpBuffer * gimp_buffer_new (GeglBuffer *buffer,
const gchar *name, const gchar *name,
GimpImageType image_type,
gint offset_x, gint offset_x,
gint offset_y, gint offset_y,
gboolean copy_pixels); gboolean copy_pixels);
@ -65,7 +63,6 @@ gint gimp_buffer_get_width (const GimpBuffer *buffer);
gint gimp_buffer_get_height (const GimpBuffer *buffer); gint gimp_buffer_get_height (const GimpBuffer *buffer);
const Babl * gimp_buffer_get_format (const GimpBuffer *buffer); const Babl * gimp_buffer_get_format (const GimpBuffer *buffer);
GimpImageType gimp_buffer_get_image_type (const GimpBuffer *buffer);
GeglBuffer * gimp_buffer_get_buffer (const GimpBuffer *buffer); GeglBuffer * gimp_buffer_get_buffer (const GimpBuffer *buffer);

View File

@ -26,6 +26,8 @@
#include "config/gimpcoreconfig.h" #include "config/gimpcoreconfig.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h" #include "gimp.h"
#include "gimpbuffer.h" #include "gimpbuffer.h"
#include "gimpchannel.h" #include "gimpchannel.h"
@ -269,19 +271,21 @@ gimp_image_new_from_buffer (Gimp *gimp,
{ {
GimpImage *image; GimpImage *image;
GimpLayer *layer; GimpLayer *layer;
GimpImageType type; const Babl *format;
gboolean has_alpha;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (invoke == NULL || GIMP_IS_IMAGE (invoke), NULL); g_return_val_if_fail (invoke == NULL || GIMP_IS_IMAGE (invoke), NULL);
g_return_val_if_fail (GIMP_IS_BUFFER (paste), NULL); g_return_val_if_fail (GIMP_IS_BUFFER (paste), NULL);
type = gimp_buffer_get_image_type (paste); format = gimp_buffer_get_format (paste);
has_alpha = babl_format_has_alpha (format);
/* create a new image (always of type GIMP_RGB) */ /* create a new image (always of type GIMP_RGB) */
image = gimp_create_image (gimp, image = gimp_create_image (gimp,
gimp_buffer_get_width (paste), gimp_buffer_get_width (paste),
gimp_buffer_get_height (paste), gimp_buffer_get_height (paste),
GIMP_IMAGE_TYPE_BASE_TYPE (type), gimp_babl_format_get_base_type (format),
TRUE); TRUE);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
@ -297,7 +301,8 @@ gimp_image_new_from_buffer (Gimp *gimp,
layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste), layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (paste),
image, image,
gimp_image_get_format (image, type), gimp_image_get_layer_format (image,
has_alpha),
_("Pasted Layer"), _("Pasted Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);

View File

@ -30,6 +30,7 @@
#include "core/gimpcontainer-filter.h" #include "core/gimpcontainer-filter.h"
#include "core/gimpcontainer.h" #include "core/gimpcontainer.h"
#include "core/gimpparamspecs.h" #include "core/gimpparamspecs.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimppdb.h" #include "gimppdb.h"
#include "gimppdb-utils.h" #include "gimppdb-utils.h"
@ -263,7 +264,7 @@ buffer_get_image_type_invoker (GimpProcedure *procedure,
GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error); GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
if (buffer) if (buffer)
image_type = gimp_buffer_get_image_type (buffer); image_type = gimp_babl_format_get_image_type (gimp_buffer_get_format (buffer));
else else
success = FALSE; success = FALSE;
} }

View File

@ -225,7 +225,7 @@ sub buffer_get_image_type {
GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error); GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
if (buffer) if (buffer)
image_type = gimp_buffer_get_image_type (buffer); image_type = gimp_babl_format_get_image_type (gimp_buffer_get_format (buffer));
else else
success = FALSE; success = FALSE;
} }
@ -235,6 +235,7 @@ CODE
@headers = qw(<string.h> @headers = qw(<string.h>
"gegl/gimp-gegl-utils.h"
"core/gimp.h" "core/gimp.h"
"core/gimpbuffer.h" "core/gimpbuffer.h"
"core/gimpcontainer.h" "core/gimpcontainer.h"