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