! Copyright (C) 2007, 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types arrays byte-arrays combinators
-compression.run-length fry grouping images images.loader
-images.normalization io io.binary io.encodings.8-bit.latin1
-io.encodings.string kernel math math.bitwise sequences
-specialized-arrays summary io.streams.throwing ;
+USING: accessors alien.c-types alien.data arrays byte-arrays
+combinators compression.run-length fry grouping images
+images.loader images.normalization io io.binary
+io.encodings.8-bit.latin1 io.encodings.string kernel math
+math.bitwise sequences specialized-arrays summary
+io.streams.throwing ;
QUALIFIED-WITH: bitstreams b
SPECIALIZED-ARRAYS: uint ushort ;
IN: images.bitmap
{ 24 [ color-index>> ] }
{ 16 [
[
- ! ushort-array-cast
+ ! ushort cast-array
2 group [ le> ] map
! 5 6 5
- ! { HEX: f800 HEX: 7e0 HEX: 1f } uncompress-bitfield
+ ! { 0xf800 0x7e0 0x1f } uncompress-bitfield
! 5 5 5
- { HEX: 7c00 HEX: 3e0 HEX: 1f } uncompress-bitfield
+ { 0x7c00 0x3e0 0x1f } uncompress-bitfield
] change-color-index
color-index>>
] }
: set-bitfield-widths ( loading-bitmap -- loading-bitmap' )
dup header>> bit-count>> {
{ 16 [ dup color-palette>> 4 group [ le> ] map ] }
- { 32 [ { HEX: ff0000 HEX: ff00 HEX: ff } ] }
+ { 32 [ { 0xff0000 0xff00 0xff } ] }
} case reverse >>bitfields ;
ERROR: unsupported-bitfield-widths n ;
dup header>> bit-count>> {
{ 16 [
dup bitfields>> '[
- ushort-array-cast _ uncompress-bitfield
+ ushort cast-array _ uncompress-bitfield
] change-color-index
] }
{ 32 [ ] }