images.gtk: update to new with-out-parameters, small speedup when loading aligned images

db4
Philipp Brüschweiler 2010-07-17 11:47:31 +02:00
parent 9f7847d8ec
commit bb50d31b39
1 changed files with 20 additions and 17 deletions

View File

@ -39,15 +39,12 @@ ERROR: g-error domain code message ;
throw throw
] when* ; ] when* ;
STRUCT: GErrorPointer { to pointer: GError } ;
: GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf ) : GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf )
f GErrorPointer malloc-struct &free f { { pointer: GError initial: f } }
[ gdk_pixbuf_new_from_stream ] keep [ gdk_pixbuf_new_from_stream ] with-out-parameters
to>> handle-GError &g_object_unref ; handle-GError &g_object_unref ;
: image-data ( GdkPixbuf -- data ) : image-data ( GdkPixbuf -- data )
[let
{ {
[ gdk_pixbuf_get_pixels ] [ gdk_pixbuf_get_pixels ]
[ gdk_pixbuf_get_width ] [ gdk_pixbuf_get_width ]
@ -55,11 +52,17 @@ STRUCT: GErrorPointer { to pointer: GError } ;
[ gdk_pixbuf_get_rowstride ] [ gdk_pixbuf_get_rowstride ]
[ gdk_pixbuf_get_n_channels ] [ gdk_pixbuf_get_n_channels ]
[ gdk_pixbuf_get_bits_per_sample ] [ gdk_pixbuf_get_bits_per_sample ]
} cleave :> ( pixels w h rowstride channels bps ) } cleave
[let :> ( pixels w h rowstride channels bps )
bps channels * 7 + 8 /i w * :> bytes-per-row bps channels * 7 + 8 /i w * :> bytes-per-row
bytes-per-row rowstride =
[ pixels h rowstride * memory>byte-array ]
[
pixels rowstride h * <direct-uchar-array> pixels rowstride h * <direct-uchar-array>
rowstride <sliced-groups> rowstride <sliced-groups>
[ bytes-per-row head-slice ] map concat [ bytes-per-row head-slice ] map concat
] if
] ; ] ;
: component-type ( GdkPixbuf -- component-type ) : component-type ( GdkPixbuf -- component-type )