--- /dev/null
+USING: help.markup help.syntax math ;
+IN: images
+
+HELP: rowstride
+{ $values { "image" image } { "n" integer } }
+{ $description "Returns an images rowstride metric." } ;
IN: images.tests
[ B{ 57 57 57 255 } ] [ 1 1 T{ image f { 2 3 } RGBA ubyte-components f f B{
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
57 57 57 255
- 0 0 0 0
- 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
} } pixel-at ] unit-test
[ B{
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
57 57 57 255
- 0 0 0 0
- 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
} ] [ B{ 57 57 57 255 } 1 1 T{ image f { 2 3 } RGBA ubyte-components f f B{
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
- 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
+ 0 0 0 0
} } [ set-pixel-at ] keep bitmap>> ] unit-test
+
+{ 40 30 } [
+ T{ image f { 10 3 } RGBA ubyte-components f f } rowstride
+ T{ image f { 10 3 } RGB ubyte-components f f } rowstride
+] unit-test
u-9-9-9-e5-components
float-11-11-10-components ;
-UNION: component-order
+UNION: component-order
A L LA BGR RGB BGRA RGBA ABGR ARGB RGBX XRGB BGRX XBGR
INTENSITY DEPTH DEPTH-STENCIL R RG ;
int-integer-components uint-integer-components ;
UNION: signed-unnormalized-integer-components
- byte-integer-components
- short-integer-components
+ byte-integer-components
+ short-integer-components
int-integer-components ;
UNION: unsigned-unnormalized-integer-components
: bytes-per-pixel ( image -- n )
[ component-order>> ] [ component-type>> ] bi (bytes-per-pixel) ;
-
+
: bytes-per-image ( image -- n )
[ dim>> product ] [ bytes-per-pixel ] bi * ;
+: rowstride ( image -- n )
+ [ dim>> first ] [ bytes-per-pixel ] bi * ;
+
<PRIVATE
:: pixel@ ( x y w image -- start end bitmap )
: set-pixel-at ( pixel x y image -- )
[ 1 ] dip set-pixel-row-at ; inline
-
f >>premultiplied-alpha?
f >>upside-down? ;
-: bits-per-sample ( image -- bits )
- component-type>> bits>components value-at ;
-
-: rowstride ( image -- rowstride )
- [ dim>> first ] [ bits-per-sample 8 / ] [ has-alpha? 4 3 ? ] tri * * ;
-
: image>GdkPixbuf ( image -- GdkPixbuf )
{
[ bitmap>> ]
[ drop GDK_COLORSPACE_RGB ]
[ has-alpha? ]
- [ bits-per-sample ]
+ [ bytes-per-component 8 * ]
[ dim>> first2 ]
[ rowstride ]
} cleave f f gdk_pixbuf_new_from_data ;