support .tif, start 96 bpp

db4
Doug Coleman 2009-02-13 09:56:22 -06:00
parent cd82735dea
commit 753cfcfd05
3 changed files with 17 additions and 5 deletions

View File

@ -1,9 +1,11 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors grouping sequences combinators ;
USING: kernel accessors grouping sequences combinators
math specialized-arrays.direct.uint byte-arrays ;
IN: images
SINGLETONS: BGR RGB BGRA RGBA ABGR ARGB RGBX XRGB BGRX XBGR ;
SINGLETONS: BGR RGB BGRA RGBA ABGR ARGB RGBX XRGB BGRX XBGR
32R32G32B ;
TUPLE: image dim component-order byte-order bitmap ;
@ -15,6 +17,14 @@ GENERIC: load-image* ( path tuple -- image )
dup component-order>>
{
{ RGBA [ ] }
{ 32R32G32B [
[
! >byte-array
! dup length 4 /i <direct-uint-array> [ 32 2^ /i ] map
! >byte-array
! 4 <sliced-groups> le> [ 32 2^ /i ] map concat
] change-bitmap
] }
{ BGRA [
[
4 <sliced-groups> dup [ [ 0 3 ] dip <slice> reverse-here ] each

View File

@ -10,6 +10,7 @@ ERROR: unknown-image-extension extension ;
: image-class ( path -- class )
file-extension >lower {
{ "bmp" [ bitmap-image ] }
{ "tif" [ tiff-image ] }
{ "tiff" [ tiff-image ] }
[ unknown-image-extension ]
} case ;

View File

@ -276,9 +276,10 @@ ERROR: unhandled-compression compression ;
ERROR: unknown-component-order ifd ;
: ifd-component-order ( ifd -- byte-order )
bits-per-sample find-tag sum {
{ 32 [ RGBA ] }
{ 24 [ RGB ] }
bits-per-sample find-tag {
{ { 32 32 32 } [ 32R32G32B ] }
{ { 8 8 8 8 } [ RGBA ] }
{ { 8 8 8 } [ RGB ] }
[ unknown-component-order ]
} case ;