get the byte ordering correct for tiffs
parent
55434492f9
commit
813b0cb803
|
@ -3,7 +3,7 @@
|
|||
USING: accessors alien alien.c-types arrays byte-arrays columns
|
||||
combinators fry grouping io io.binary io.encodings.binary io.files
|
||||
kernel macros math math.bitwise math.functions namespaces sequences
|
||||
strings images endian summary ;
|
||||
strings images endian summary annotations ;
|
||||
IN: images.bitmap
|
||||
|
||||
TUPLE: bitmap-image < image ;
|
||||
|
@ -105,7 +105,7 @@ ERROR: unknown-component-order bitmap ;
|
|||
{
|
||||
[ [ width>> ] [ height>> ] bi 2array ]
|
||||
[ bitmap>component-order ]
|
||||
[ drop little-endian ] ! XXX
|
||||
[ drop little-endian ] !XXX
|
||||
[ buffer>> ]
|
||||
} cleave bitmap-image boa ;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ IN: images
|
|||
SINGLETONS: BGR RGB BGRA RGBA ABGR ARGB RGBX XRGB BGRX XBGR
|
||||
R16G16B16 R32G32B32 ;
|
||||
|
||||
TUPLE: image dim component-order byte-order bitmap ;
|
||||
TUPLE: image dim component-order bitmap ;
|
||||
|
||||
: <image> ( -- image ) image new ; inline
|
||||
|
||||
|
|
|
@ -286,6 +286,18 @@ ERROR: unhandled-compression compression ;
|
|||
|
||||
ERROR: unknown-component-order ifd ;
|
||||
|
||||
: fix-bitmap-endianness ( ifd -- ifd )
|
||||
dup [ bitmap>> ] [ bits-per-sample find-tag ] bi
|
||||
{
|
||||
{ { 32 32 32 32 } [ 4 seq>native-endianness ] }
|
||||
{ { 32 32 32 } [ 4 seq>native-endianness ] }
|
||||
{ { 16 16 16 16 } [ 2 seq>native-endianness ] }
|
||||
{ { 16 16 16 } [ 2 seq>native-endianness ] }
|
||||
{ { 8 8 8 8 } [ ] }
|
||||
{ { 8 8 8 } [ ] }
|
||||
[ unknown-component-order ]
|
||||
} case >>bitmap ;
|
||||
|
||||
: ifd-component-order ( ifd -- byte-order )
|
||||
bits-per-sample find-tag {
|
||||
{ { 32 32 32 } [ R32G32B32 ] }
|
||||
|
@ -299,7 +311,6 @@ ERROR: unknown-component-order ifd ;
|
|||
{
|
||||
[ [ image-width find-tag ] [ image-length find-tag ] bi 2array ]
|
||||
[ ifd-component-order ]
|
||||
[ drop big-endian ] ! XXX
|
||||
[ bitmap>> ]
|
||||
} cleave tiff-image boa ;
|
||||
|
||||
|
@ -314,7 +325,9 @@ ERROR: unknown-component-order ifd ;
|
|||
dup ifds>> [
|
||||
process-ifd read-strips
|
||||
uncompress-strips
|
||||
strips>bitmap drop
|
||||
strips>bitmap
|
||||
fix-bitmap-endianness
|
||||
drop
|
||||
] each
|
||||
] with-endianness
|
||||
] with-file-reader ;
|
||||
|
|
Loading…
Reference in New Issue