diff options
-rw-r--r-- | demos/testpixbuf.c | 17 | ||||
-rw-r--r-- | gdk-pixbuf/ChangeLog | 16 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.c | 16 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.c | 63 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.h | 3 | ||||
-rw-r--r-- | gdk-pixbuf/io-bmp.c | 3 |
6 files changed, 82 insertions, 36 deletions
diff --git a/demos/testpixbuf.c b/demos/testpixbuf.c index e81d4607c1..97a82f74a5 100644 --- a/demos/testpixbuf.c +++ b/demos/testpixbuf.c @@ -1,6 +1,6 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald +/* testpixbuf -- test program for gdk-pixbuf code + * Copyright (C) 1999 Mark Crichton, Larry Ewing * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,18 +18,6 @@ * Boston, MA 02111-1307, USA. */ -/* - * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - - -/* Note: these #includes differ slightly from the testrgb.c file included - in the GdkRgb release. */ - -/* For gettimeofday */ #include <stdlib.h> #include <unistd.h> #include <string.h> @@ -161,6 +149,7 @@ main (int argc, char **argv) for (i = 1; i < argc; i++) { pixbuf = gdk_pixbuf_load_image (argv[i]); + pixbuf = gdk_pixbuf_rotate(pixbuf, 42.0); if (pixbuf) { diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 84a01ba01a..713e451121 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,19 @@ +1999-07-18 Mark Crichton <crichton@gimp.org> + + * configure.in: removed version.h. + + * src/gdk-pixbuf-io.c (pixbuf_check_tiff): Minor readability + improvements. + +1999-07-17 Mark Crichton <crichton@gimp.org> + + * src/gdk-pixbuf.c: Removed gdk_pixbuf_free, redundant code. + (gdk_pixbuf_rotate): Added pixbuf rotation code. + (gdk_pixbuf_scale): Changed // comments to /* */ + + * src/gdk-pixbuf.h (gdk_pixbuf_destroy): Added gdk_pixbuf_destroy + function to header. + 1999-07-16 Larry Ewing <lewing@gimp.org> * src/testpixbuf.c (expose_func): reverted the expose everything diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index 53da897cba..cdb0007fbb 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -47,10 +47,16 @@ pixbuf_check_tiff (unsigned char *buffer, int size) if (size < 10) return FALSE; - if (buffer [0] == 'M' && buffer [1] == 'M' && buffer [2] == 0 && buffer [3] == 0x2a) + if (buffer [0] == 'M' && + buffer [1] == 'M' && + buffer [2] == 0 && + buffer [3] == 0x2a) return TRUE; - if (buffer [0] == 'I' && buffer [1] == 'I' && buffer [2] == 0x2a && buffer [3] == 0) + if (buffer [0] == 'I' && + buffer [1] == 'I' && + buffer [2] == 0x2a && + buffer [3] == 0) return TRUE; return FALSE; @@ -139,11 +145,13 @@ image_file_format (const char *file) static void image_handler_load (int idx) { - char *module_name = g_strconcat ("pixbuf-", file_formats [idx].module_name, NULL); + char *module_name; char *path; GModule *module; void *load_sym, *save_sym; - + + module_name = g_strconcat ("pixbuf-", + file_formats [idx].module_name, NULL); path = g_module_build_path (PIXBUF_LIBDIR, module_name); g_free (module_name); diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c index 0068c163d6..1ab1105574 100644 --- a/gdk-pixbuf/gdk-pixbuf.c +++ b/gdk-pixbuf/gdk-pixbuf.c @@ -6,25 +6,26 @@ */ #include <config.h> #include <glib.h> +#include <math.h> #include <libart_lgpl/art_misc.h> #include <libart_lgpl/art_rgb_affine.h> #include <libart_lgpl/art_alphagamma.h> #include "gdk-pixbuf.h" -static void +void gdk_pixbuf_destroy (GdkPixBuf *pixbuf) { - art_pixbuf_free (pixbuf->art_pixbuf); - g_free (pixbuf); + art_pixbuf_free (pixbuf->art_pixbuf); + g_free (pixbuf); } void gdk_pixbuf_ref (GdkPixBuf *pixbuf) { - g_return_if_fail (pixbuf != NULL); - - pixbuf->ref_count++; + g_return_if_fail (pixbuf != NULL); + + pixbuf->ref_count++; } void @@ -38,14 +39,6 @@ gdk_pixbuf_unref (GdkPixBuf *pixbuf) gdk_pixbuf_destroy (pixbuf); } -void -gdk_pixbuf_free (GdkPixBuf *pixbuf) -{ - art_free(pixbuf->art_pixbuf->pixels); - art_pixbuf_free_shallow(pixbuf->art_pixbuf); - g_free(pixbuf); -} - GdkPixBuf * gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h) { @@ -64,7 +57,7 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h) affine[0] = w / (double)(pixbuf->art_pixbuf->width); affine[3] = h / (double)(pixbuf->art_pixbuf->height); - // rowstride = w * pixbuf->art_pixbuf->n_channels; + /* rowstride = w * pixbuf->art_pixbuf->n_channels; */ rowstride = w * 3; pixels = art_alloc (h * rowstride); @@ -73,7 +66,7 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h) affine, ART_FILTER_NEAREST, alphagamma); if (pixbuf->art_pixbuf->has_alpha) - // should be rgba + /* should be rgba */ art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); else art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); @@ -84,5 +77,43 @@ gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h) return pixbuf; } +GdkPixBuf * +gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle) +{ + GdkPixBuf *rotate; + art_u8 *pixels; + gint rowstride, w, h; + gdouble rad; + double affine[6]; + ArtAlphaGamma *alphagamma = NULL; + ArtPixBuf *art_pixbuf = NULL; + + w = pixbuf->art_pixbuf->width; + h = pixbuf->art_pixbuf->height; + + rad = M_PI * angle / 180.0; + + affine[0] = cos(rad); + affine[1] = sin(rad); + affine[2] = -sin(rad); + affine[3] = cos(rad); + affine[4] = affine[5] = 0; + + /* rowstride = w * pixbuf->art_pixbuf->n_channels; */ + rowstride = w * 3; + + pixels = art_alloc (h * rowstride); + art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride, + pixbuf->art_pixbuf, + affine, ART_FILTER_NEAREST, alphagamma); + if (pixbuf->art_pixbuf->has_alpha) + /* should be rgba */ + art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); + else + art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); + art_pixbuf_free (pixbuf->art_pixbuf); + pixbuf->art_pixbuf = art_pixbuf; + return pixbuf; +} diff --git a/gdk-pixbuf/gdk-pixbuf.h b/gdk-pixbuf/gdk-pixbuf.h index 371def2da8..a1886468d1 100644 --- a/gdk-pixbuf/gdk-pixbuf.h +++ b/gdk-pixbuf/gdk-pixbuf.h @@ -16,7 +16,8 @@ void gdk_pixbuf_ref (GdkPixBuf *pixbuf); void gdk_pixbuf_unref (GdkPixBuf *pixbuf); GdkPixBuf *gdk_pixbuf_duplicate (GdkPixBuf *pixbuf); GdkPixBuf *gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h); +GdkPixBuf *gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle); -void gdk_pixbuf_free (GdkPixBuf *pixbuf); +void gdk_pixbuf_destroy (GdkPixBuf *pixbuf); #endif /* _GDK_PIXBUF_H_ */ diff --git a/gdk-pixbuf/io-bmp.c b/gdk-pixbuf/io-bmp.c index ecd7f38281..6195599548 100644 --- a/gdk-pixbuf/io-bmp.c +++ b/gdk-pixbuf/io-bmp.c @@ -25,8 +25,9 @@ #include <glib.h> #include "gdk-pixbuf.h" #include "gdk-pixbuf-io.h" +#include "io-bmp.h" -/* Loosely based off the BMP loader from The GIMP */ +/* Loosely based off the BMP loader from The GIMP, hence it's complexity */ /* Shared library entry point */ GdkPixBuf *image_load(FILE * f) |