Commit 16635e5f authored by Michael Natterer's avatar Michael Natterer 😴

app: gimp_drawable_preview_bytes() -> gimp_drawable_get_preview_format()

parent 85bd6b0d
...@@ -98,26 +98,28 @@ gimp_drawable_get_preview (GimpViewable *viewable, ...@@ -98,26 +98,28 @@ gimp_drawable_get_preview (GimpViewable *viewable,
return gimp_drawable_preview_private (drawable, width, height); return gimp_drawable_preview_private (drawable, width, height);
} }
gint const Babl *
gimp_drawable_preview_bytes (GimpDrawable *drawable) gimp_drawable_get_preview_format (GimpDrawable *drawable)
{ {
gint bytes = 0; g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
switch (gimp_drawable_get_base_type (drawable)) switch (gimp_drawable_get_base_type (drawable))
{ {
case GIMP_RGB:
case GIMP_GRAY: case GIMP_GRAY:
bytes = gimp_drawable_bytes (drawable); if (gimp_drawable_has_alpha (drawable))
break; return babl_format ("Y'A u8");
else
return babl_format ("Y' u8");
case GIMP_RGB:
case GIMP_INDEXED: case GIMP_INDEXED:
bytes = gimp_drawable_has_alpha (drawable) ? 4 : 3; if (gimp_drawable_has_alpha (drawable))
break; 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 * GimpTempBuf *
...@@ -208,7 +210,6 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable, ...@@ -208,7 +210,6 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable,
GimpTempBuf *preview_buf; GimpTempBuf *preview_buf;
PixelRegion srcPR; PixelRegion srcPR;
PixelRegion destPR; PixelRegion destPR;
gint bytes = gimp_drawable_preview_bytes (drawable);
gint subsample = 1; gint subsample = 1;
/* calculate 'acceptable' subsample */ /* calculate 'acceptable' subsample */
...@@ -221,7 +222,7 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable, ...@@ -221,7 +222,7 @@ gimp_drawable_indexed_preview (GimpDrawable *drawable,
FALSE); FALSE);
preview_buf = gimp_temp_buf_new (dest_width, dest_height, 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, pixel_region_init_temp_buf (&destPR, preview_buf,
0, 0, dest_width, dest_height); 0, 0, dest_width, dest_height);
......
...@@ -22,22 +22,22 @@ ...@@ -22,22 +22,22 @@
/* /*
* virtual function of GimpDrawable -- dont't call directly * virtual function of GimpDrawable -- dont't call directly
*/ */
GimpTempBuf * gimp_drawable_get_preview (GimpViewable *viewable, GimpTempBuf * gimp_drawable_get_preview (GimpViewable *viewable,
GimpContext *context, GimpContext *context,
gint width, gint width,
gint height); gint height);
/* /*
* normal functions (no virtuals) * normal functions (no virtuals)
*/ */
gint gimp_drawable_preview_bytes (GimpDrawable *drawable); const Babl * gimp_drawable_get_preview_format (GimpDrawable *drawable);
GimpTempBuf * gimp_drawable_get_sub_preview (GimpDrawable *drawable, GimpTempBuf * gimp_drawable_get_sub_preview (GimpDrawable *drawable,
gint src_x, gint src_x,
gint src_y, gint src_y,
gint src_width, gint src_width,
gint src_height, gint src_height,
gint dest_width, gint dest_width,
gint dest_height); gint dest_height);
#endif /* __GIMP_DRAWABLE__PREVIEW_H__ */ #endif /* __GIMP_DRAWABLE__PREVIEW_H__ */
...@@ -735,22 +735,12 @@ drawable_thumbnail_invoker (GimpProcedure *procedure, ...@@ -735,22 +735,12 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
width = MAX (1, (height * dwidth) / dheight); width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews) if (image->gimp->config->layer_previews)
{ buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context, width, height);
width, height);
}
else else
{ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
const Babl *format; width, height,
gimp_drawable_get_preview_format (drawable));
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);
}
if (buf) if (buf)
{ {
...@@ -822,25 +812,14 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure, ...@@ -822,25 +812,14 @@ drawable_sub_thumbnail_invoker (GimpProcedure *procedure,
GimpTempBuf *buf; GimpTempBuf *buf;
if (image->gimp->config->layer_previews) if (image->gimp->config->layer_previews)
{ buf = gimp_drawable_get_sub_preview (drawable,
buf = gimp_drawable_get_sub_preview (drawable, src_x, src_y,
src_x, src_y, src_width, src_height,
src_width, src_height, dest_width, dest_height);
dest_width, dest_height);
}
else else
{ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
const Babl *format; dest_width, dest_height,
gimp_drawable_get_preview_format (drawable));
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);
}
if (buf) if (buf)
{ {
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#include "widgets-types.h" #include "widgets-types.h"
#include "gegl/gimp-gegl-utils.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpdrawable-preview.h" #include "core/gimpdrawable-preview.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
...@@ -165,10 +163,9 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer, ...@@ -165,10 +163,9 @@ gimp_view_renderer_drawable_render (GimpViewRenderer *renderer,
} }
else 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, render_buf = gimp_temp_buf_new (1, 1, format);
gimp_bpp_to_babl_format (bytes));
gimp_temp_buf_data_clear (render_buf); gimp_temp_buf_data_clear (render_buf);
} }
} }
......
...@@ -719,22 +719,12 @@ HELP ...@@ -719,22 +719,12 @@ HELP
width = MAX (1, (height * dwidth) / dheight); width = MAX (1, (height * dwidth) / dheight);
if (image->gimp->config->layer_previews) if (image->gimp->config->layer_previews)
{ buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context, width, height);
width, height);
}
else else
{ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
const Babl *format; width, height,
gimp_drawable_get_preview_format (drawable));
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);
}
if (buf) if (buf)
{ {
...@@ -807,25 +797,14 @@ HELP ...@@ -807,25 +797,14 @@ HELP
GimpTempBuf *buf; GimpTempBuf *buf;
if (image->gimp->config->layer_previews) if (image->gimp->config->layer_previews)
{ buf = gimp_drawable_get_sub_preview (drawable,
buf = gimp_drawable_get_sub_preview (drawable, src_x, src_y,
src_x, src_y, src_width, src_height,
src_width, src_height, dest_width, dest_height);
dest_width, dest_height);
}
else else
{ buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
const Babl *format; dest_width, dest_height,
gimp_drawable_get_preview_format (drawable));
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);
}
if (buf) if (buf)
{ {
......
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