app: pass a format, not bpp, to gimp_viewable_get_dummy_pixbuf()

and add tons of <gegl.h> includes.
This commit is contained in:
Michael Natterer
2012-04-21 21:41:36 +02:00
parent c291524e6c
commit 85bd6b0dd9
34 changed files with 115 additions and 62 deletions

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -19,7 +19,7 @@
#include <string.h> #include <string.h>
#include <glib-object.h> #include <gegl.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -19,7 +19,7 @@
#include <errno.h> #include <errno.h>
#include <glib-object.h> #include <gegl.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -19,7 +19,7 @@
#include <string.h> #include <string.h>
#include <glib-object.h> #include <gegl.h>
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"

View File

@ -19,7 +19,7 @@
#include <errno.h> #include <errno.h>
#include <glib-object.h> #include <gegl.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -20,7 +20,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> /* memcmp */ #include <string.h> /* memcmp */
#include <glib-object.h> #include <gegl.h>
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -17,7 +17,7 @@
#include "config.h" #include "config.h"
#include <glib-object.h> #include <gegl.h>
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -17,7 +17,7 @@
#include "config.h" #include "config.h"
#include <glib-object.h> #include <gegl.h>
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -17,7 +17,7 @@
#include "config.h" #include "config.h"
#include <glib-object.h> #include <gegl.h>
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -20,7 +20,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <glib-object.h> #include <gegl.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -22,7 +22,7 @@
#include <string.h> #include <string.h>
#include <glib-object.h> #include <gegl.h>
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -17,7 +17,7 @@
#include "config.h" #include "config.h"
#include <glib-object.h> #include <gegl.h>
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -794,35 +794,33 @@ gimp_viewable_get_new_preview (GimpViewable *viewable,
* Returns: a #GimpTempBuf containing the preview image. * Returns: a #GimpTempBuf containing the preview image.
**/ **/
GimpTempBuf * GimpTempBuf *
gimp_viewable_get_dummy_preview (GimpViewable *viewable, gimp_viewable_get_dummy_preview (GimpViewable *viewable,
gint width, gint width,
gint height, gint height,
gint bpp) const Babl *format)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GimpTempBuf *buf; GimpTempBuf *buf;
guchar *src; GeglBuffer *src_buffer;
guchar *dest; GeglBuffer *dest_buffer;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL); g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0, NULL); g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL); g_return_val_if_fail (height > 0, NULL);
g_return_val_if_fail (bpp == 3 || bpp == 4, NULL); g_return_val_if_fail (format != NULL, NULL);
pixbuf = gimp_viewable_get_dummy_pixbuf (viewable, width, height, bpp); pixbuf = gimp_viewable_get_dummy_pixbuf (viewable, width, height,
babl_format_has_alpha (format));
buf = gimp_temp_buf_new (width, height, gimp_bpp_to_babl_format (bpp)); buf = gimp_temp_buf_new (width, height, format);
src = gdk_pixbuf_get_pixels (pixbuf); src_buffer = gimp_pixbuf_create_buffer (pixbuf);
dest = gimp_temp_buf_get_data (buf); dest_buffer = gimp_temp_buf_create_buffer (buf);
while (height--) gegl_buffer_copy (src_buffer, NULL, dest_buffer, NULL);
{
memcpy (dest, src, width * bpp);
src += gdk_pixbuf_get_rowstride (pixbuf); g_object_unref (src_buffer);
dest += width * bpp; g_object_unref (dest_buffer);
}
g_object_unref (pixbuf); g_object_unref (pixbuf);
@ -968,7 +966,7 @@ GdkPixbuf *
gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable, gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
gint width, gint width,
gint height, gint height,
gint bpp) gboolean with_alpha)
{ {
GdkPixbuf *icon; GdkPixbuf *icon;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
@ -978,7 +976,6 @@ gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL); g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
g_return_val_if_fail (width > 0, NULL); g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL); g_return_val_if_fail (height > 0, NULL);
g_return_val_if_fail (bpp == 3 || bpp == 4, NULL);
icon = gdk_pixbuf_new_from_inline (-1, stock_question_64, FALSE, NULL); icon = gdk_pixbuf_new_from_inline (-1, stock_question_64, FALSE, NULL);
@ -993,7 +990,7 @@ gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
w = RINT (ratio * (gdouble) w); w = RINT (ratio * (gdouble) w);
h = RINT (ratio * (gdouble) h); h = RINT (ratio * (gdouble) h);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, (bpp == 4), 8, width, height); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, with_alpha, 8, width, height);
gdk_pixbuf_fill (pixbuf, 0xffffffff); gdk_pixbuf_fill (pixbuf, 0xffffffff);
if (w && h) if (w && h)

View File

@ -148,7 +148,7 @@ GimpTempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable,
GimpTempBuf * gimp_viewable_get_dummy_preview (GimpViewable *viewable, GimpTempBuf * gimp_viewable_get_dummy_preview (GimpViewable *viewable,
gint width, gint width,
gint height, gint height,
gint bpp); const Babl *format);
GdkPixbuf * gimp_viewable_get_pixbuf (GimpViewable *viewable, GdkPixbuf * gimp_viewable_get_pixbuf (GimpViewable *viewable,
GimpContext *context, GimpContext *context,
@ -162,7 +162,7 @@ GdkPixbuf * gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
GdkPixbuf * gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable, GdkPixbuf * gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
gint width, gint width,
gint height, gint height,
gint bpp); gboolean with_alpha);
gchar * gimp_viewable_get_description (GimpViewable *viewable, gchar * gimp_viewable_get_description (GimpViewable *viewable,
gchar **tooltip); gchar **tooltip);

View File

@ -19,6 +19,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"

View File

@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h" #include "libgimpwidgets/gimpwidgets.h"

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpthumb/gimpthumb.h" #include "libgimpthumb/gimpthumb.h"

View File

@ -735,13 +735,22 @@ 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, {
width, height); buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
width, height);
}
else else
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable), {
width, height, const Babl *format;
gimp_drawable_has_alpha (drawable) ?
4 : 3); 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)
{ {
@ -813,15 +822,25 @@ 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, {
src_x, src_y, buf = gimp_drawable_get_sub_preview (drawable,
src_width, src_height, src_x, src_y,
dest_width, dest_height); src_width, src_height,
dest_width, dest_height);
}
else else
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable), {
dest_width, dest_height, const Babl *format;
gimp_drawable_has_alpha (drawable) ?
4 : 3); 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)
{ {

View File

@ -24,7 +24,7 @@
#include <string.h> #include <string.h>
#include <glib-object.h> #include <gegl.h>
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#include <pango/pangofc-fontmap.h> #include <pango/pangofc-fontmap.h>

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "tools-types.h" #include "tools-types.h"

View File

@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include <config.h> #include <config.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "widgets-types.h" #include "widgets-types.h"

View File

@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "widgets-types.h" #include "widgets-types.h"

View File

@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "widgets-types.h" #include "widgets-types.h"

View File

@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h" #include "libgimpconfig/gimpconfig.h"

View File

@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h" #include "libgimpwidgets/gimpwidgets.h"

View File

@ -17,6 +17,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>

View File

@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h" #include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h" #include "libgimpmath/gimpmath.h"

View File

@ -22,6 +22,7 @@
#include "config.h" #include "config.h"
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h" #include "libgimpwidgets/gimpwidgets.h"

View File

@ -22,6 +22,7 @@
#include <string.h> #include <string.h>
#include <gegl.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpthumb/gimpthumb.h" #include "libgimpthumb/gimpthumb.h"

View File

@ -719,13 +719,22 @@ 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, {
width, height); buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
width, height);
}
else else
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable), {
width, height, const Babl *format;
gimp_drawable_has_alpha (drawable) ?
4 : 3); 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)
{ {
@ -798,15 +807,25 @@ HELP
GimpTempBuf *buf; GimpTempBuf *buf;
if (image->gimp->config->layer_previews) if (image->gimp->config->layer_previews)
buf = gimp_drawable_get_sub_preview (drawable, {
src_x, src_y, buf = gimp_drawable_get_sub_preview (drawable,
src_width, src_height, src_x, src_y,
dest_width, dest_height); src_width, src_height,
dest_width, dest_height);
}
else else
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable), {
dest_width, dest_height, const Babl *format;
gimp_drawable_has_alpha (drawable) ?
4 : 3); 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)
{ {