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