diff options
author | Mark Crichton <crichton@src.gnome.org> | 1999-07-16 20:35:21 +0000 |
---|---|---|
committer | Mark Crichton <crichton@src.gnome.org> | 1999-07-16 20:35:21 +0000 |
commit | 96ba724fc5977275139e101e28c77e7558ad1cf1 (patch) | |
tree | 398551a787d0fb7bfdc3bab90a461efa810f3338 /gdk-pixbuf | |
parent | 1922a3ed01296c6a08a6a5af836a156f73b5c236 (diff) | |
download | gtk+-96ba724fc5977275139e101e28c77e7558ad1cf1.tar.gz |
Added scaling of pixmaps. Currently doesn't work, however, since I'm
Added scaling of pixmaps. Currently doesn't work, however, since I'm guessing
how art_rgb_affine really works.
Mark
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/ChangeLog | 14 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.c | 70 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.h | 5 |
3 files changed, 70 insertions, 19 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 78de67eafe..62ac792eec 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,13 @@ +1999-07-16 Mark Crichton <crichton@gimp.org> + + * src/testpixbuf.c (config_func): ConfigureEvent handler. This + calls gdk_pixbuf_scale. However, something is not working. + N.B.: current pixmap is now stored in user_data with a key of + "pixmap" + + * src/gdk-pixbuf.c (gdk_pixbuf_scale): Implemented scaling function. + Something is still borked, however. + 1999-07-15 Larry Ewing <lewing@gimp.org> * src/io-jpeg.c (image_load): add raph@gimp.org's fix to the jpeg @@ -11,11 +21,11 @@ * src/testpixbuf.c (expose_func): added an almost proper expose handler for testpixbuf -1999-07-13 <crichton@gimp.org> +1999-07-13 Mark Crichton <crichton@gimp.org> * configure.in: Fixed GIF check. Replaced " with ' * src/gdk-pixbuf.c: More (minor) work on gdk_pixbuf_scale -1999-07-13 <crichton@gimp.org> +1999-07-13 Mark Crichton <crichton@gimp.org> * configure.in: I am a bonehead. Added gif-lib check.
\ No newline at end of file diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c index ae186dda72..2fbd7213aa 100644 --- a/gdk-pixbuf/gdk-pixbuf.c +++ b/gdk-pixbuf/gdk-pixbuf.c @@ -6,6 +6,9 @@ */ #include <config.h> #include <glib.h> +#include <libart_lgpl/art_misc.h> +#include <libart_lgpl/art_rgb_affine.h> +#include <libart_lgpl/art_alphagamma.h> #include "gdk-pixbuf.h" @@ -19,35 +22,70 @@ gdk_pixbuf_destroy (GdkPixBuf *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 gdk_pixbuf_unref (GdkPixBuf *pixbuf) { - g_return_if_fail (pixbuf != NULL); - g_return_if_fail (pixbuf->ref_count == 0); + g_return_if_fail (pixbuf != NULL); + g_return_if_fail (pixbuf->ref_count == 0); + + pixbuf->ref_count--; + if (pixbuf->ref_count) + gdk_pixbuf_destroy (pixbuf); +} - pixbuf->ref_count--; - if (pixbuf->ref_count) - 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) { GdkPixBuf *spb; + art_u8 *pixels; double affine[6]; - -} + ArtAlphaGamma *alphagamma; + alphagamma = NULL; -/* - * Local variables: - * c-basic-offset: 4 - * c-file-offsets: ((substatement-open . 0)) - * End: - */ + affine[0] = affine[3] = 1; + affine[4] = affine[5] = 0; + + affine[1] = w / (pixbuf->art_pixbuf->width); + affine[2] = h / (pixbuf->art_pixbuf->height); + + spb = g_new (GdkPixBuf, 1); + if (pixbuf->art_pixbuf->has_alpha) { + /* Following code is WRONG....of course, the code for this + * transform isn't in libart yet. + */ +#if 0 + pixels = art_alloc (h * w * 4); + art_rgb_affine( pixels, 0, 0, w, h, (w * 4), + pixbuf->art_pixbuf->pixels, + pixbuf->art_pixbuf->width, + pixbuf->art_pixbuf->height, + pixbuf->art_pixbuf->rowstride, + affine, ART_FILTER_NEAREST, alphagamma); + spb->art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4)); +#endif + } else { + art_alloc (h * w * 3); + art_rgb_affine( pixels, 0, 0, w, h, (w * 3), + pixbuf->art_pixbuf->pixels, + pixbuf->art_pixbuf->width, + pixbuf->art_pixbuf->height, + pixbuf->art_pixbuf->rowstride, + affine, ART_FILTER_NEAREST, alphagamma); + spb->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3)); + } +} diff --git a/gdk-pixbuf/gdk-pixbuf.h b/gdk-pixbuf/gdk-pixbuf.h index 02132d8d86..371def2da8 100644 --- a/gdk-pixbuf/gdk-pixbuf.h +++ b/gdk-pixbuf/gdk-pixbuf.h @@ -14,6 +14,9 @@ GdkPixBuf *gdk_pixbuf_load_image (const char *file); void gdk_pixbuf_save_image (const char *format_id, const char *file, ...); void gdk_pixbuf_ref (GdkPixBuf *pixbuf); void gdk_pixbuf_unref (GdkPixBuf *pixbuf); -GdkPixBuf gdk_pixbuf_duplicate (GdkPixBuf *pixbuf); +GdkPixBuf *gdk_pixbuf_duplicate (GdkPixBuf *pixbuf); +GdkPixBuf *gdk_pixbuf_scale (GdkPixBuf *pixbuf, gint w, gint h); + +void gdk_pixbuf_free (GdkPixBuf *pixbuf); #endif /* _GDK_PIXBUF_H_ */ |