diff --git a/app/base/tile-pyramid.c b/app/base/tile-pyramid.c index 34cb5a2776..e11cb7e87c 100644 --- a/app/base/tile-pyramid.c +++ b/app/base/tile-pyramid.c @@ -32,11 +32,12 @@ struct _TilePyramid { - guint width; - guint height; - gint bytes; - TileManager *tiles[PYRAMID_MAX_LEVELS]; - gint top_level; + GimpImageType type; + guint width; + guint height; + gint bytes; + TileManager *tiles[PYRAMID_MAX_LEVELS]; + gint top_level; }; @@ -60,9 +61,9 @@ static void tile_pyramid_write_upper_quarter (Tile *dest, /** * tile_pyramid_new: + * @type: type of pixel data stored in the pyramid * @width: bottom level width * @height: bottom level height - * @bytes: the bpp of the pixel data stored in the pyramid * * Creates a new #TilePyramid, managing a set of tile-managers where * each level is a sized-down version of the level below. @@ -78,9 +79,9 @@ static void tile_pyramid_write_upper_quarter (Tile *dest, * Return value: a newly allocate #TilePyramid **/ TilePyramid * -tile_pyramid_new (gint width, - gint height, - gint bytes) +tile_pyramid_new (GimpImageType type, + gint width, + gint height) { TilePyramid *pyramid; @@ -89,11 +90,35 @@ tile_pyramid_new (gint width, pyramid = g_slice_new0 (TilePyramid); + pyramid->type = type; pyramid->width = width; pyramid->height = height; - pyramid->bytes = bytes; - pyramid->tiles[0] = tile_manager_new (width, height, bytes); + switch (type) + { + case GIMP_GRAY_IMAGE: + pyramid->bytes = 1; + break; + + case GIMP_GRAYA_IMAGE: + pyramid->bytes = 2; + break; + + case GIMP_RGB_IMAGE: + pyramid->bytes = 3; + break; + + case GIMP_RGBA_IMAGE: + pyramid->bytes = 4; + break; + + case GIMP_INDEXED_IMAGE: + case GIMP_INDEXEDA_IMAGE: + g_assert_not_reached (); + break; + } + + pyramid->tiles[0] = tile_manager_new (width, height, pyramid->bytes); return pyramid; } diff --git a/app/base/tile-pyramid.h b/app/base/tile-pyramid.h index 07c9cf1ab9..e62f652958 100644 --- a/app/base/tile-pyramid.h +++ b/app/base/tile-pyramid.h @@ -29,9 +29,9 @@ * is "nlevels - 1". That level will be smaller than TILE_WIDTH x * TILE_HEIGHT */ -TilePyramid * tile_pyramid_new (gint width, - gint height, - gint bytes); +TilePyramid * tile_pyramid_new (GimpImageType type, + gint width, + gint height); void tile_pyramid_destroy (TilePyramid *pyramid); gint tile_pyramid_get_level (gint width, diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 4db240b38d..5eb05ecb34 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -372,9 +372,9 @@ gimp_projection_get_tiles_at_level (GimpProjection *proj, if (! proj->pyramid) { - proj->pyramid = tile_pyramid_new (gimp_image_get_width (proj->image), - gimp_image_get_height (proj->image), - gimp_projection_get_bytes (proj)); + proj->pyramid = tile_pyramid_new (gimp_projection_get_image_type (proj), + gimp_image_get_width (proj->image), + gimp_image_get_height (proj->image)); tile_pyramid_set_validate_proc (proj->pyramid, (TileValidateProc) gimp_projection_validate_tile,