images: adding "2x" images.

db4
John Benediktsson 2012-11-01 16:11:55 -07:00
parent 44b7bbc76d
commit e5d325df44
2 changed files with 11 additions and 8 deletions

View File

@ -65,10 +65,13 @@ UNION: alpha-channel-precedes-colors ABGR ARGB XBGR XRGB ;
TUPLE: image TUPLE: image
dim component-order component-type dim component-order component-type
upside-down? premultiplied-alpha? upside-down? premultiplied-alpha?
bitmap ; bitmap 2x? ;
: <image> ( -- image ) image new ; inline : <image> ( -- image ) image new ; inline
: image-dim ( image -- dim )
[ dim>> ] [ 2x?>> ] bi [ [ 2/ ] map ] when ;
: has-alpha? ( image -- ? ) component-order>> alpha-channel? ; : has-alpha? ( image -- ? ) component-order>> alpha-channel? ;
: bytes-per-component ( component-type -- n ) : bytes-per-component ( component-type -- n )

View File

@ -1,16 +1,16 @@
! Copyright (C) 2007, 2009 Doug Coleman. ! Copyright (C) 2007, 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors images images.loader io.pathnames kernel USING: accessors arrays combinators.short-circuit continuations
models namespaces opengl opengl.gl opengl.textures opengl.textures.private destructors images images.loader io.pathnames kernel locals
sequences math arrays math models opengl.gl opengl.textures opengl.textures.private
strings ui ui.gadgets ui.gadgets.panes ui.images ui.render sequences strings ui ui.gadgets ui.gadgets.panes
constructors locals combinators.short-circuit ui.gadgets.worlds ui.render ;
literals destructors ui.gadgets.worlds continuations ; FROM: images => image-dim ;
IN: images.viewer IN: images.viewer
TUPLE: image-gadget < gadget image texture ; TUPLE: image-gadget < gadget image texture ;
<PRIVATE <PRIVATE
M: image-gadget pref-dim* image>> [ dim>> ] [ { 640 480 } ] if* ; M: image-gadget pref-dim* image>> [ image-dim ] [ { 640 480 } ] if* ;
: (image-gadget-texture) ( gadget -- texture ) : (image-gadget-texture) ( gadget -- texture )
dup image>> { 0 0 } <texture> >>texture texture>> ; dup image>> { 0 0 } <texture> >>texture texture>> ;