]> gitweb.factorcode.org Git - factor.git/commitdiff
images.bitmap: respect upside-down? flag when encoding
authorKeith Lazuka <klazuka@gmail.com>
Wed, 7 Oct 2009 19:36:26 +0000 (15:36 -0400)
committerKeith Lazuka <klazuka@gmail.com>
Fri, 9 Oct 2009 19:58:35 +0000 (15:58 -0400)
basis/images/bitmap/bitmap.factor

index b1ce62f4438203a44b071b434980d96f99a3c7a5..39241f5978bf1d342470dbf89064b935b01f7222 100755 (executable)
@@ -16,6 +16,13 @@ SINGLETON: bmp-image
 : write2 ( n -- ) 2 >le write ;
 : write4 ( n -- ) 4 >le write ;
 
+: output-width-and-height ( image -- )
+    [ dim>> first write4 ]
+    [
+        [ dim>> second ] [ upside-down?>> ] bi
+        [ neg ] unless write4
+    ] bi ;
+
 : output-bmp ( image -- )
     B{ CHAR: B CHAR: M } write
     [
@@ -25,8 +32,7 @@ SINGLETON: bmp-image
         40 write4
     ] [
         {
-            ! width height
-            [ dim>> first2 [ write4 ] bi@ ]
+            [ output-width-and-height ]
 
             ! planes
             [ drop 1 write2 ]