GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 9d260c38 authored by Michael Natterer's avatar Michael Natterer 😴

app: completely port gimpdrawable-convert.c to GeglBuffer

parent be4dcb16
......@@ -25,8 +25,6 @@
#include "core-types.h"
#include "base/tile-manager.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimpdrawable.h"
......@@ -37,13 +35,14 @@
void
gimp_drawable_convert_rgb (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo)
{
GimpImageType type;
TileManager *tiles;
GeglBuffer *dest_buffer;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (! gimp_drawable_is_rgb (drawable));
type = GIMP_RGB_IMAGE;
......@@ -51,31 +50,30 @@ gimp_drawable_convert_rgb (GimpDrawable *drawable,
if (gimp_drawable_has_alpha (drawable))
type = GIMP_IMAGE_TYPE_WITH_ALPHA (type);
tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
GIMP_IMAGE_TYPE_BYTES (type));
dest_buffer = gimp_tile_manager_create_buffer (tiles, NULL);
dest_buffer =
gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
gimp_image_get_format (dest_image, type));
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL,
dest_buffer, type);
g_object_unref (dest_buffer);
gimp_drawable_set_tiles (drawable, push_undo, NULL,
tiles, type);
tile_manager_unref (tiles);
}
void
gimp_drawable_convert_grayscale (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo)
{
GimpImageType type;
TileManager *tiles;
GeglBuffer *dest_buffer;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_IMAGE (dest_image));
g_return_if_fail (! gimp_drawable_is_gray (drawable));
type = GIMP_GRAY_IMAGE;
......@@ -83,20 +81,18 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
if (gimp_drawable_has_alpha (drawable))
type = GIMP_IMAGE_TYPE_WITH_ALPHA (type);
tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
GIMP_IMAGE_TYPE_BYTES (type));
dest_buffer = gimp_tile_manager_create_buffer (tiles, NULL);
dest_buffer =
gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
gimp_image_get_format (dest_image, type));
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL,
dest_buffer, type);
g_object_unref (dest_buffer);
gimp_drawable_set_tiles (drawable, push_undo, NULL,
tiles, type);
tile_manager_unref (tiles);
}
void
......@@ -105,7 +101,6 @@ gimp_drawable_convert_indexed (GimpDrawable *drawable,
gboolean push_undo)
{
GimpImageType type;
TileManager *tiles;
GeglBuffer *dest_buffer;
const Babl *format;
......@@ -116,28 +111,20 @@ gimp_drawable_convert_indexed (GimpDrawable *drawable,
type = GIMP_INDEXED_IMAGE;
if (gimp_drawable_has_alpha (drawable))
{
type = GIMP_IMAGE_TYPE_WITH_ALPHA (type);
format = gimp_image_colormap_get_rgba_format (dest_image);
}
format = gimp_image_colormap_get_rgba_format (dest_image);
else
{
format = gimp_image_colormap_get_rgb_format (dest_image);
}
format = gimp_image_colormap_get_rgb_format (dest_image);
tiles = tile_manager_new (gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
GIMP_IMAGE_TYPE_BYTES (type));
dest_buffer = gimp_tile_manager_create_buffer (tiles, format);
dest_buffer =
gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable))),
format);
gegl_buffer_copy (gimp_drawable_get_buffer (drawable), NULL,
dest_buffer, NULL);
gimp_drawable_set_buffer (drawable, push_undo, NULL,
dest_buffer, type);
g_object_unref (dest_buffer);
gimp_drawable_set_tiles (drawable, push_undo, NULL,
tiles, type);
tile_manager_unref (tiles);
}
......@@ -20,8 +20,10 @@
void gimp_drawable_convert_rgb (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo);
void gimp_drawable_convert_grayscale (GimpDrawable *drawable,
GimpImage *dest_image,
gboolean push_undo);
void gimp_drawable_convert_indexed (GimpDrawable *drawable,
GimpImage *dest_image,
......
......@@ -759,11 +759,11 @@ gimp_drawable_real_convert_type (GimpDrawable *drawable,
switch (new_base_type)
{
case GIMP_RGB:
gimp_drawable_convert_rgb (drawable, push_undo);
gimp_drawable_convert_rgb (drawable, dest_image, push_undo);
break;
case GIMP_GRAY:
gimp_drawable_convert_grayscale (drawable, push_undo);
gimp_drawable_convert_grayscale (drawable, dest_image, push_undo);
break;
case GIMP_INDEXED:
......
......@@ -965,7 +965,7 @@ gimp_image_convert (GimpImage *image,
{
case GIMP_RGB:
case GIMP_GRAY:
gimp_drawable_convert_type (GIMP_DRAWABLE (layer), NULL, new_type,
gimp_drawable_convert_type (GIMP_DRAWABLE (layer), image, new_type,
TRUE);
break;
......
Markdown is supported
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