added function that estimates the memory requirements for an image

2007-06-06  Sven Neumann  <sven@gimp.org>

	* app/core/gimpprojection.[ch]: added function that estimates the
	memory requirements for an image projection.

	* app/core/gimptemplate.c (gimp_template_notify): use it.

svn path=/trunk/; revision=22721
This commit is contained in:
Sven Neumann
2007-06-06 10:03:17 +00:00
committed by Sven Neumann
parent 0b92d2436c
commit feaf142fc7
4 changed files with 46 additions and 12 deletions

View File

@ -1,3 +1,10 @@
2007-06-06 Sven Neumann <sven@gimp.org>
* app/core/gimpprojection.[ch]: added function that estimates the
memory requirements for an image projection.
* app/core/gimptemplate.c (gimp_template_notify): use it.
2007-06-06 Sven Neumann <sven@gimp.org>
* docs/papers: removed this directory and its contents. The papers

View File

@ -203,6 +203,26 @@ gimp_projection_get_memsize (GimpObject *object,
gui_size);
}
/**
* gimp_projection_estimate_memsize:
* @type: the image base type
* @width: image width
* @height: image height
*
* Calculates a rough estimate of the memory that is required for the
* projection of an image with the given @width and @height.
*
* Return value: a rough estimate of the memory requirements.
**/
gint64
gimp_projection_estimate_memsize (GimpImageBaseType type,
gint width,
gint height)
{
return 4 * (gint64) width * (gint64) height;
}
static void
gimp_projection_pickable_flush (GimpPickable *pickable)
{

View File

@ -77,19 +77,23 @@ struct _GimpProjectionClass
};
GType gimp_projection_get_type (void) G_GNUC_CONST;
GType gimp_projection_get_type (void) G_GNUC_CONST;
GimpProjection * gimp_projection_new (GimpImage *image);
GimpProjection * gimp_projection_new (GimpImage *image);
TileManager * gimp_projection_get_tiles (GimpProjection *proj);
GimpImage * gimp_projection_get_image (const GimpProjection *proj);
GimpImageType gimp_projection_get_image_type (const GimpProjection *proj);
gint gimp_projection_get_bytes (const GimpProjection *proj);
gdouble gimp_projection_get_opacity (const GimpProjection *proj);
TileManager * gimp_projection_get_tiles (GimpProjection *proj);
GimpImage * gimp_projection_get_image (const GimpProjection *proj);
GimpImageType gimp_projection_get_image_type (const GimpProjection *proj);
gint gimp_projection_get_bytes (const GimpProjection *proj);
gdouble gimp_projection_get_opacity (const GimpProjection *proj);
void gimp_projection_flush (GimpProjection *proj);
void gimp_projection_flush_now (GimpProjection *proj);
void gimp_projection_finish_draw (GimpProjection *proj);
void gimp_projection_flush (GimpProjection *proj);
void gimp_projection_flush_now (GimpProjection *proj);
void gimp_projection_finish_draw (GimpProjection *proj);
gint64 gimp_projection_estimate_memsize (GimpImageBaseType type,
gint width,
gint height);
#endif /* __GIMP_PROJECTION_H__ */

View File

@ -293,13 +293,16 @@ gimp_template_notify (GObject *object,
channels = ((template->image_type == GIMP_RGB ? 3 : 1) /* color */ +
(template->fill_type == GIMP_TRANSPARENT_FILL) /* alpha */ +
1 /* selection */ +
(template->image_type == GIMP_RGB ? 4 : 2) /* projection */);
1 /* selection */);
template->initial_size = ((guint64) channels *
(guint64) template->width *
(guint64) template->height);
template->initial_size +=
gimp_projection_estimate_memsize (template->image_type,
template->width, template->height);
if (! strcmp (pspec->name, "stock-id"))
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (object));
}