Introduce temp_buf_get_data_size() and use it.

* app/base/temp-buf.[ch]
* app/widgets/gimpbrushselect.c
* app/widgets/gimppatternselect.c

svn path=/trunk/; revision=27783
This commit is contained in:
Martin Nordholts 2008-12-13 10:51:16 +00:00
parent ddaa0b48ec
commit 4cb231f53b
5 changed files with 53 additions and 42 deletions

View File

@ -1,3 +1,11 @@
2008-12-13 Martin Nordholts <martinn@svn.gnome.org>
Introduce temp_buf_get_data_size() and use it.
* app/base/temp-buf.[ch]
* app/widgets/gimpbrushselect.c
* app/widgets/gimppatternselect.c
2008-12-13 Martin Nordholts <martinn@svn.gnome.org> 2008-12-13 Martin Nordholts <martinn@svn.gnome.org>
s/temp_buf_data/temp_buf_get_data/ s/temp_buf_data/temp_buf_get_data/

View File

@ -196,7 +196,7 @@ temp_buf_copy (TempBuf *src,
{ {
memcpy (temp_buf_get_data (dest), memcpy (temp_buf_get_data (dest),
temp_buf_get_data (src), temp_buf_get_data (src),
src->width * src->height * src->bytes); temp_buf_get_data_size (src));
} }
return dest; return dest;
@ -413,6 +413,12 @@ temp_buf_get_data (TempBuf *buf)
return buf->data; return buf->data;
} }
gsize
temp_buf_get_data_size (TempBuf *buf)
{
return buf->bytes * buf->width * buf->height;
}
guchar * guchar *
temp_buf_data_clear (TempBuf *buf) temp_buf_data_clear (TempBuf *buf)
{ {
@ -425,7 +431,7 @@ gsize
temp_buf_get_memsize (TempBuf *buf) temp_buf_get_memsize (TempBuf *buf)
{ {
if (buf) if (buf)
return (sizeof (TempBuf) + buf->bytes * buf->width * buf->height); return (sizeof (TempBuf) + temp_buf_get_data_size (buf));
return 0; return 0;
} }

View File

@ -33,43 +33,44 @@ struct _TempBuf
/* The temp buffer functions */ /* The temp buffer functions */
TempBuf * temp_buf_new (gint width, TempBuf * temp_buf_new (gint width,
gint height, gint height,
gint bytes, gint bytes,
gint x, gint x,
gint y, gint y,
const guchar *color); const guchar *color);
TempBuf * temp_buf_new_check (gint width, TempBuf * temp_buf_new_check (gint width,
gint height, gint height,
GimpCheckType check_type, GimpCheckType check_type,
GimpCheckSize check_size); GimpCheckSize check_size);
TempBuf * temp_buf_copy (TempBuf *src, TempBuf * temp_buf_copy (TempBuf *src,
TempBuf *dest); TempBuf *dest);
TempBuf * temp_buf_resize (TempBuf *buf, TempBuf * temp_buf_resize (TempBuf *buf,
gint bytes, gint bytes,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height); gint height);
TempBuf * temp_buf_scale (TempBuf *buf, TempBuf * temp_buf_scale (TempBuf *buf,
gint width, gint width,
gint height) G_GNUC_WARN_UNUSED_RESULT; gint height) G_GNUC_WARN_UNUSED_RESULT;
TempBuf * temp_buf_copy_area (TempBuf *src, TempBuf * temp_buf_copy_area (TempBuf *src,
TempBuf *dest, TempBuf *dest,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height, gint height,
gint dest_x, gint dest_x,
gint dest_y); gint dest_y);
void temp_buf_demultiply (TempBuf *buf); void temp_buf_demultiply (TempBuf *buf);
void temp_buf_free (TempBuf *buf); void temp_buf_free (TempBuf *buf);
guchar * temp_buf_get_data (TempBuf *buf); guchar * temp_buf_get_data (TempBuf *buf);
guchar * temp_buf_data_clear (TempBuf *buf); gsize temp_buf_get_data_size (TempBuf *buf);
guchar * temp_buf_data_clear (TempBuf *buf);
gsize temp_buf_get_memsize (TempBuf *buf); gsize temp_buf_get_memsize (TempBuf *buf);
#endif /* __TEMP_BUF_H__ */ #endif /* __TEMP_BUF_H__ */

View File

@ -263,9 +263,7 @@ gimp_brush_select_run_callback (GimpPdbDialog *dialog,
GValueArray *return_vals; GValueArray *return_vals;
array = gimp_array_new (temp_buf_get_data (brush->mask), array = gimp_array_new (temp_buf_get_data (brush->mask),
brush->mask->width * temp_buf_get_data_size (brush->mask),
brush->mask->height *
brush->mask->bytes,
TRUE); TRUE);
return_vals = return_vals =

View File

@ -113,9 +113,7 @@ gimp_pattern_select_run_callback (GimpPdbDialog *dialog,
GValueArray *return_vals; GValueArray *return_vals;
array = gimp_array_new (temp_buf_get_data (pattern->mask), array = gimp_array_new (temp_buf_get_data (pattern->mask),
pattern->mask->width * temp_buf_get_data_size (pattern->mask),
pattern->mask->height *
pattern->mask->bytes,
TRUE); TRUE);
return_vals = return_vals =