[gimp] app: gimp_drawable_preview_bytes() -> gimp_drawable_get_preview_format()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: gimp_drawable_preview_bytes() -> gimp_drawable_get_preview_format()
- Date: Wed, 2 May 2012 16:40:22 +0000 (UTC)
commit 16635e5f0addfd5c3c14c0629c73a8a55d375659
Author: Michael Natterer <mitch gimp org>
Date: Sat Apr 21 22:09:39 2012 +0200
app: gimp_drawable_preview_bytes() -> gimp_drawable_get_preview_format()
app/core/gimpdrawable-preview.c | 27 ++++++++++---------
app/core/gimpdrawable-preview.h | 24 ++++++++--------
app/pdb/drawable-cmds.c | 45 ++++++++-----------------------
app/widgets/gimpviewrendererdrawable.c | 7 +---
tools/pdbgen/pdb/drawable.pdb | 45 ++++++++-----------------------
5 files changed, 52 insertions(+), 96 deletions(-)
---
diff --git a/app/core/gimpdrawable-preview.c b/app/core/gimpdrawable-preview.c
index 36302f7..2e3a96d 100644
--- a/app/core/gimpdrawable-preview.c
+++ b/app/core/gimpdrawable-preview.c
@@ -98,26 +98,28 @@ gimp_drawable_get_preview (GimpViewable *viewable,
return gimp_drawable_preview_private (drawable, width, height);
}
-gint
-gimp_drawable_preview_bytes (GimpDrawable *drawable)
+const Babl *
+gimp_drawable_get_preview_format (GimpDrawable *drawable)
{
- gint bytes = 0;
-
- g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
+ g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
switch (gimp_drawable_get_base_type (drawable))
{
- case GIMP_RGB:
case GIMP_GRAY:
- bytes = gimp_drawable_bytes (drawable);
- break;
+ if (gimp_drawable_has_alpha (drawable))
+ return babl_format ("Y'A u8");
+ else
+ return babl_format ("Y' u8");
+ case GIMP_RGB:
case GIMP_INDEXED:
- bytes = gimp_drawable_has_alpha (drawable) ? 4 : 3;
- break;
+ if (gimp_drawable_has_alpha (drawable))
+ return babl_format ("R'G'B'A u8");
+ else
+ return babl_format ("R'G'B' u8");
}
- return bytes;
+ g_return_val_if_reached (NULL);
}
GimpTempBuf *
@@ -208,7 +210,6 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable,
GimpTempBuf *preview_buf;
PixelRegion srcPR;
PixelRegion destPR;
- gint bytes = gimp_drawable_preview_bytes (drawable);
gint subsample = 1;
/* calculate 'acceptable' subsample */
@@ -221,7 +222,7 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable,
FALSE);
preview_buf = gimp_temp_buf_new (dest_width, dest_height,
- gimp_bpp_to_babl_format (bytes));
+ gimp_drawable_get_preview_format (drawable));
pixel_region_init_temp_buf (&destPR, preview_buf,
0, 0, dest_width, dest_height);
diff --git a/app/core/gimpdrawable-preview.h b/app/core/gimpdrawable-preview.h
index 4993774..4b4cba9 100644
--- a/app/core/gimpdrawable-preview.h
+++ b/app/core/gimpdrawable-preview.h
@@ -22,22 +22,22 @@
/*
* virtual function of GimpDrawable -- dont't call directly
*/
-GimpTempBuf * gimp_drawable_get_preview (GimpViewable *viewable,
- GimpContext *context,
- gint width,
- gint height);
+GimpTempBuf * gimp_drawable_get_preview (GimpViewable *viewable,
+ GimpContext *context,
+ gint width,
+ gint height);
/*
* normal functions (no virtuals)
*/
-gint gimp_drawable_preview_bytes (GimpDrawable *drawable);
-GimpTempBuf * gimp_drawable_get_sub_preview (GimpDrawable *drawable,
- gint src_x,
- gint src_y,
- gint src_width,
- gint src_height,
- gint dest_width,
- gint dest_height);
+const Babl * gimp_drawable_get_preview_format (GimpDrawable *drawable);
+GimpTempBuf * gimp_drawable_get_sub_preview (GimpDrawable *drawable,
+ gint src_x,
+ gint src_y,
+ gint src_width,
+ gint src_height,
+ gint dest_width,
+ gint dest_height);
#endif /* __GIMP_DRAWABLE__PREVIEW_H__ */
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 3a5a1a6..0252f45 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -735,22 +735,12 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews)
- {
- buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
- width, height);
- }
+ buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
+ width, height);
else
- {
- const Babl *format;
-
- if (gimp_drawable_has_alpha (drawable))
- format = babl_format ("R'G'B'A u8");
- else
- format = babl_format ("R'G'B' u8");
-
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- width, height, format);
- }
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ width, height,
+ gimp_drawable_get_preview_format (drawable));
if (buf)
{
@@ -822,25 +812,14 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
GimpTempBuf *buf;
if (image->gimp->config->layer_previews)
- {
- buf = gimp_drawable_get_sub_preview (drawable,
- src_x, src_y,
- src_width, src_height,
- dest_width, dest_height);
- }
+ buf = gimp_drawable_get_sub_preview (drawable,
+ src_x, src_y,
+ src_width, src_height,
+ dest_width, dest_height);
else
- {
- const Babl *format;
-
- if (gimp_drawable_has_alpha (drawable))
- format = babl_format ("R'G'B'A u8");
- else
- format = babl_format ("R'G'B' u8");
-
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- dest_width, dest_height,
- format);
- }
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ dest_width, dest_height,
+ gimp_drawable_get_preview_format (drawable));
if (buf)
{
diff --git a/app/widgets/gimpviewrendererdrawable.c b/app/widgets/gimpviewrendererdrawable.c
index 7ffd814..cd67d9b 100644
--- a/app/widgets/gimpviewrendererdrawable.c
+++ b/app/widgets/gimpviewrendererdrawable.c
@@ -28,8 +28,6 @@
#include "widgets-types.h"
-#include "gegl/gimp-gegl-utils.h"
-
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-preview.h"
#include "core/gimpimage.h"
@@ -165,10 +163,9 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
}
else
{
- gint bytes = gimp_drawable_preview_bytes (drawable);
+ const Babl *format = gimp_drawable_get_preview_format (drawable);
- render_buf = gimp_temp_buf_new (1, 1,
- gimp_bpp_to_babl_format (bytes));
+ render_buf = gimp_temp_buf_new (1, 1, format);
gimp_temp_buf_data_clear (render_buf);
}
}
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index ced571a..cc20f42 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -719,22 +719,12 @@ HELP
width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews)
- {
- buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
- width, height);
- }
+ buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
+ width, height);
else
- {
- const Babl *format;
-
- if (gimp_drawable_has_alpha (drawable))
- format = babl_format ("R'G'B'A u8");
- else
- format = babl_format ("R'G'B' u8");
-
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- width, height, format);
- }
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ width, height,
+ gimp_drawable_get_preview_format (drawable));
if (buf)
{
@@ -807,25 +797,14 @@ HELP
GimpTempBuf *buf;
if (image->gimp->config->layer_previews)
- {
- buf = gimp_drawable_get_sub_preview (drawable,
- src_x, src_y,
- src_width, src_height,
- dest_width, dest_height);
- }
+ buf = gimp_drawable_get_sub_preview (drawable,
+ src_x, src_y,
+ src_width, src_height,
+ dest_width, dest_height);
else
- {
- const Babl *format;
-
- if (gimp_drawable_has_alpha (drawable))
- format = babl_format ("R'G'B'A u8");
- else
- format = babl_format ("R'G'B' u8");
-
- buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
- dest_width, dest_height,
- format);
- }
+ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
+ dest_width, dest_height,
+ gimp_drawable_get_preview_format (drawable));
if (buf)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]