mirror of https://github.com/GNOME/gimp.git
app: gimp_drawable_preview_bytes() -> gimp_drawable_get_preview_format()
This commit is contained in:
parent
85bd6b0dd9
commit
16635e5f0a
|
@ -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);
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue