From 838d69baab20fd545b9788bf1ddd734c2ab14a7d Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Wed, 14 Mar 2012 18:55:09 +0100 Subject: util: Be faster by disabling asserts and alpha --- util.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/util.c b/util.c index 03551b5..76df227 100644 --- a/util.c +++ b/util.c @@ -8,9 +8,11 @@ */ guchar *pixbuf_point(GdkPixbuf *pixbuf, point_t point) { +#if 0 g_assert(point.x >= 0 && point.x < gdk_pixbuf_get_width (pixbuf)); g_assert(point.y >= 0 && point.y < gdk_pixbuf_get_height(pixbuf)); g_assert(gdk_pixbuf_get_bits_per_sample(pixbuf) == 8); +#endif return gdk_pixbuf_get_pixels(pixbuf) + point.y * gdk_pixbuf_get_rowstride (pixbuf) @@ -19,30 +21,36 @@ guchar *pixbuf_point(GdkPixbuf *pixbuf, point_t point) void put_pixel(GdkPixbuf *pixbuf, point_t point, color_t color) { - const gint n_channels = gdk_pixbuf_get_n_channels(pixbuf); + //const gint n_channels = gdk_pixbuf_get_n_channels(pixbuf); +#if 0 g_assert(n_channels == 4 || n_channels == 3); g_assert(gdk_pixbuf_get_colorspace(pixbuf) == GDK_COLORSPACE_RGB); g_assert(gdk_pixbuf_get_bits_per_sample(pixbuf) == 8); +#endif guchar *p = pixbuf_point(pixbuf, point); p[0] = color.r; p[1] = color.g; p[2] = color.b; +#if 0 if (n_channels == 4) p[3] = color.a; +#endif } color_t get_pixel(GdkPixbuf *pixbuf, point_t point) { - const gint n_channels = gdk_pixbuf_get_n_channels(pixbuf); + //const gint n_channels = gdk_pixbuf_get_n_channels(pixbuf); +#if 0 g_assert(gdk_pixbuf_get_colorspace(pixbuf) == GDK_COLORSPACE_RGB); g_assert(gdk_pixbuf_get_bits_per_sample(pixbuf) == 8); g_assert(n_channels == 4 || n_channels == 3); +#endif guchar *p = pixbuf_point(pixbuf, point); - return COLOR(p[0], p[1], p[2], n_channels == 4 ? p[3] : COL_MAX); + return COLOR(p[0], p[1], p[2], 0 /*n_channels == 4 ? p[3] : COL_MAX*/); } void color_to_yiq(color_t color, guint8 *y, guint8 *i, guint8 *q) -- cgit