diff --git a/basis/images/images.factor b/basis/images/images.factor index d033186fc0..430f5bee5e 100644 --- a/basis/images/images.factor +++ b/basis/images/images.factor @@ -65,10 +65,13 @@ UNION: alpha-channel-precedes-colors ABGR ARGB XBGR XRGB ; TUPLE: image dim component-order component-type upside-down? premultiplied-alpha? - bitmap ; + bitmap 2x? ; : ( -- image ) image new ; inline +: image-dim ( image -- dim ) + [ dim>> ] [ 2x?>> ] bi [ [ 2/ ] map ] when ; + : has-alpha? ( image -- ? ) component-order>> alpha-channel? ; : bytes-per-component ( component-type -- n ) diff --git a/extra/images/viewer/viewer.factor b/extra/images/viewer/viewer.factor index ef36413a56..76dbfc32bf 100644 --- a/extra/images/viewer/viewer.factor +++ b/extra/images/viewer/viewer.factor @@ -1,16 +1,16 @@ ! Copyright (C) 2007, 2009 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors images images.loader io.pathnames kernel -models namespaces opengl opengl.gl opengl.textures opengl.textures.private -sequences math arrays -strings ui ui.gadgets ui.gadgets.panes ui.images ui.render -constructors locals combinators.short-circuit -literals destructors ui.gadgets.worlds continuations ; +USING: accessors arrays combinators.short-circuit continuations +destructors images images.loader io.pathnames kernel locals +math models opengl.gl opengl.textures opengl.textures.private +sequences strings ui ui.gadgets ui.gadgets.panes +ui.gadgets.worlds ui.render ; +FROM: images => image-dim ; IN: images.viewer TUPLE: image-gadget < gadget image texture ; > [ dim>> ] [ { 640 480 } ] if* ; +M: image-gadget pref-dim* image>> [ image-dim ] [ { 640 480 } ] if* ; : (image-gadget-texture) ( gadget -- texture ) dup image>> { 0 0 } >>texture texture>> ;