]> gitweb.factorcode.org Git - factor.git/commitdiff
fix bitmap loading of odd-width files
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 16 Mar 2009 12:08:35 +0000 (07:08 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 16 Mar 2009 12:08:35 +0000 (07:08 -0500)
basis/images/bitmap/bitmap.factor

index ffe3adff481e7945f9b905a44cdd2d08d7d0facd..8209159a8e4c33386e27f6224d33b370bc54ae82 100755 (executable)
@@ -83,14 +83,15 @@ ERROR: bmp-not-supported n ;
 
 :: fixup-color-index ( loading-bitmap -- loading-bitmap )
     loading-bitmap width>> :> width
+    width 3 * :> width*3
     loading-bitmap height>> abs :> height
     loading-bitmap color-index>> length :> color-index-length
-    height 3 * :> height*3
-    color-index-length width height*3 * - height*3 /i :> misaligned
-    misaligned 0 > [
+    color-index-length height /i :> stride
+    color-index-length width*3 height * - height /i :> padding
+    padding 0 > [
         loading-bitmap [
-            loading-bitmap width>> misaligned + 3 * <sliced-groups>
-            [ 3 misaligned * head* ] map concat
+            stride <sliced-groups>
+            [ width*3 head-slice ] map concat
         ] change-color-index
     ] [
         loading-bitmap