From bb50d31b39c929f0da971161840d405b5463c6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= Date: Sat, 17 Jul 2010 11:47:31 +0200 Subject: [PATCH] images.gtk: update to new with-out-parameters, small speedup when loading aligned images --- basis/images/gtk/gtk.factor | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/basis/images/gtk/gtk.factor b/basis/images/gtk/gtk.factor index 6f6921d21f..9b50bf6a62 100644 --- a/basis/images/gtk/gtk.factor +++ b/basis/images/gtk/gtk.factor @@ -39,27 +39,30 @@ ERROR: g-error domain code message ; throw ] when* ; -STRUCT: GErrorPointer { to pointer: GError } ; - : GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf ) - f GErrorPointer malloc-struct &free - [ gdk_pixbuf_new_from_stream ] keep - to>> handle-GError &g_object_unref ; + f { { pointer: GError initial: f } } + [ gdk_pixbuf_new_from_stream ] with-out-parameters + handle-GError &g_object_unref ; : image-data ( GdkPixbuf -- data ) - [let - { - [ gdk_pixbuf_get_pixels ] - [ gdk_pixbuf_get_width ] - [ gdk_pixbuf_get_height ] - [ gdk_pixbuf_get_rowstride ] - [ gdk_pixbuf_get_n_channels ] - [ gdk_pixbuf_get_bits_per_sample ] - } cleave :> ( pixels w h rowstride channels bps ) + { + [ gdk_pixbuf_get_pixels ] + [ gdk_pixbuf_get_width ] + [ gdk_pixbuf_get_height ] + [ gdk_pixbuf_get_rowstride ] + [ gdk_pixbuf_get_n_channels ] + [ gdk_pixbuf_get_bits_per_sample ] + } cleave + [let :> ( pixels w h rowstride channels bps ) bps channels * 7 + 8 /i w * :> bytes-per-row - pixels rowstride h * - rowstride - [ bytes-per-row head-slice ] map concat + + bytes-per-row rowstride = + [ pixels h rowstride * memory>byte-array ] + [ + pixels rowstride h * + rowstride + [ bytes-per-row head-slice ] map concat + ] if ] ; : component-type ( GdkPixbuf -- component-type )