1 ! Copyright (C) 2007, 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien alien.c-types arrays byte-arrays columns
4 combinators compression.run-length endian fry grouping images
5 images.loader images.normalization io io.binary
6 io.encodings.binary io.encodings.string io.files
7 io.streams.limited kernel locals macros math math.bitwise
8 math.functions namespaces sequences specialized-arrays
9 specialized-arrays.instances.uint
10 specialized-arrays.instances.ushort strings summary ;
14 "bmp" bmp-image register-image-class
16 : write2 ( n -- ) 2 >le write ;
17 : write4 ( n -- ) 4 >le write ;
19 : output-width-and-height ( image -- )
20 [ dim>> first write4 ]
22 [ dim>> second ] [ upside-down?>> ] bi
26 : output-bmp ( image -- )
27 B{ CHAR: B CHAR: M } write
29 bitmap>> length 14 + 40 + write4
35 [ output-width-and-height ]
47 [ bitmap>> length write4 ]
66 M: bmp-image image>stream
67 drop BGR reorder-components output-bmp ;