the start of a tiff library
parent
1979fbc61a
commit
26f9df982d
|
@ -0,0 +1 @@
|
||||||
|
Doug Coleman
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
! Copyright (C) 2009 Your name.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: tools.test graphics.tiff ;
|
||||||
|
IN: graphics.tiff.tests
|
||||||
|
|
||||||
|
: tiff-test-path ( -- path )
|
||||||
|
"resource:extra/graphics/tiff/rgb.tiff" ;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
! Copyright (C) 2009 Doug Coleman.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: accessors combinators io io.encodings.binary io.files
|
||||||
|
kernel pack endian ;
|
||||||
|
IN: graphics.tiff
|
||||||
|
|
||||||
|
TUPLE: tiff
|
||||||
|
endianness
|
||||||
|
the-answer
|
||||||
|
ifd-offset
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
ERROR: bad-tiff-magic bytes ;
|
||||||
|
|
||||||
|
: tiff-endianness ( byte-array -- ? )
|
||||||
|
{
|
||||||
|
{ B{ CHAR: M CHAR: M } [ big-endian ] }
|
||||||
|
{ B{ CHAR: I CHAR: I } [ little-endian ] }
|
||||||
|
[ bad-tiff-magic ]
|
||||||
|
} case ;
|
||||||
|
|
||||||
|
: read-header ( tiff -- tiff )
|
||||||
|
2 read tiff-endianness [ >>endianness ] keep
|
||||||
|
[
|
||||||
|
2 read endian> >>the-answer
|
||||||
|
4 read endian> >>ifd-offset
|
||||||
|
] with-endianness ;
|
||||||
|
|
||||||
|
: (load-tiff) ( path -- tiff )
|
||||||
|
binary [
|
||||||
|
tiff new
|
||||||
|
read-header
|
||||||
|
] with-file-reader ;
|
||||||
|
|
||||||
|
: load-tiff ( path -- tiff )
|
||||||
|
(load-tiff) ;
|
Loading…
Reference in New Issue