app: use gimp_create_image_from_buffer() to create the debug image graph

This commit is contained in:
Michael Natterer
2015-06-19 23:49:41 +02:00
parent 6138b58f14
commit 7d4948b190
3 changed files with 35 additions and 42 deletions

View File

@ -753,16 +753,20 @@ gimp_file_is_executable (GFile *file)
#include "gimplayer.h"
#include "gimplayer-new.h"
void
gimp_create_image_from_buffer (Gimp *gimp,
GeglBuffer *buffer)
GimpImage *
gimp_create_image_from_buffer (Gimp *gimp,
GeglBuffer *buffer,
const gchar *image_name)
{
GimpImage *image;
GimpLayer *layer;
const Babl *format;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GEGL_IS_BUFFER (buffer));
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
if (! image_name)
image_name = "Debug Image";
format = gegl_buffer_get_format (buffer);
@ -774,7 +778,7 @@ gimp_create_image_from_buffer (Gimp *gimp,
FALSE);
layer = gimp_layer_new_from_buffer (buffer, image, format,
"Debug Image",
image_name,
GIMP_OPACITY_OPAQUE,
GIMP_NORMAL_MODE);
gimp_image_add_layer (image, layer, NULL, -1, FALSE);
@ -782,5 +786,8 @@ gimp_create_image_from_buffer (Gimp *gimp,
gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0, NULL, 0);
/* unref the image unconditionally, even when no display was created */
g_object_add_weak_pointer (G_OBJECT (image), (gpointer) &image);
g_object_unref (image);
return image;
}