loading some tiff files works!
parent
c379497599
commit
3672bcb08f
|
@ -14,6 +14,7 @@ the-answer
|
|||
ifd-offset
|
||||
ifds ;
|
||||
|
||||
|
||||
CONSTRUCTOR: tiff ( -- tiff )
|
||||
V{ } clone >>ifds ;
|
||||
|
||||
|
@ -327,8 +328,9 @@ ERROR: bad-small-ifd-type n ;
|
|||
dup ifd-entries>>
|
||||
[ process-ifd-entry [ class ] keep ] H{ } map>assoc >>processed-tags ;
|
||||
|
||||
: strips>buffer ( ifd -- ifd )
|
||||
dup strips>> concat >>buffer ;
|
||||
/*
|
||||
: ifd-strips>buffer ( ifd -- ifd )
|
||||
[
|
||||
[ rows-per-strip find-tag n>> ]
|
||||
[ image-length find-tag n>> ] bi
|
||||
|
@ -342,7 +344,7 @@ ERROR: bad-small-ifd-type n ;
|
|||
<tiff>
|
||||
read-header [
|
||||
read-ifds
|
||||
dup ifds>> [ process-ifd read-strips drop ] each
|
||||
dup ifds>> [ process-ifd read-strips strips>buffer drop ] each
|
||||
] with-tiff-endianness
|
||||
] with-file-reader ;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays combinators graphics.bitmap kernel math
|
||||
math.functions namespaces opengl opengl.gl ui ui.gadgets
|
||||
ui.gadgets.panes ui.render ;
|
||||
ui.gadgets.panes ui.render graphics.tiff sequences ;
|
||||
IN: graphics.viewer
|
||||
|
||||
TUPLE: graphics-gadget < gadget image ;
|
||||
|
@ -21,6 +21,14 @@ M: graphics-gadget draw-gadget* ( gadget -- )
|
|||
\ graphics-gadget new-gadget
|
||||
swap >>image ;
|
||||
|
||||
: bits>gl-params ( n -- gl-bgr gl-format )
|
||||
{
|
||||
{ 32 [ GL_BGRA GL_UNSIGNED_BYTE ] }
|
||||
{ 24 [ GL_BGR GL_UNSIGNED_BYTE ] }
|
||||
{ 8 [ GL_BGR GL_UNSIGNED_BYTE ] }
|
||||
{ 4 [ GL_BGR GL_UNSIGNED_BYTE ] }
|
||||
} case ;
|
||||
|
||||
M: bitmap draw-image ( bitmap -- )
|
||||
dup height>> 0 < [
|
||||
0 0 glRasterPos2i
|
||||
|
@ -32,12 +40,7 @@ M: bitmap draw-image ( bitmap -- )
|
|||
[ width>> ] keep
|
||||
[
|
||||
[ height>> abs ] keep
|
||||
bit-count>> {
|
||||
{ 32 [ GL_BGRA GL_UNSIGNED_BYTE ] }
|
||||
{ 24 [ GL_BGR GL_UNSIGNED_BYTE ] }
|
||||
{ 8 [ GL_BGR GL_UNSIGNED_BYTE ] }
|
||||
{ 4 [ GL_BGR GL_UNSIGNED_BYTE ] }
|
||||
} case
|
||||
bit-count>> bits>gl-params
|
||||
] keep array>> glDrawPixels ;
|
||||
|
||||
M: bitmap width ( bitmap -- ) width>> ;
|
||||
|
@ -48,3 +51,16 @@ M: bitmap height ( bitmap -- ) height>> ;
|
|||
|
||||
: bitmap-window ( path -- gadget )
|
||||
load-bitmap <graphics-gadget> [ "bitmap" open-window ] keep ;
|
||||
|
||||
M: tiff width ( tiff -- ) ifds>> first image-width find-tag n>> ;
|
||||
M: tiff height ( tiff -- ) ifds>> first image-length find-tag n>> ;
|
||||
|
||||
M: tiff draw-image ( tiff -- )
|
||||
[ 0 0 glRasterPos2i 1.0 -1.0 glPixelZoom ] dip
|
||||
ifds>> first
|
||||
{
|
||||
[ image-width find-tag n>> ]
|
||||
[ image-length find-tag n>> ]
|
||||
[ bits-per-sample find-tag n>> sum bits>gl-params ]
|
||||
[ buffer>> ]
|
||||
} cleave glDrawPixels ;
|
||||
|
|
Loading…
Reference in New Issue