]> gitweb.factorcode.org Git - factor.git/commitdiff
dont scale 8,16 bit greyscale pngs. greyscale-alpha pngs are 8,16 bit already, so...
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 9 Oct 2009 00:37:14 +0000 (19:37 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 9 Oct 2009 00:37:14 +0000 (19:37 -0500)
basis/images/png/png.factor

index 469c060776ec231d6ecd4fce0b4e06ca5a077d01..254ec40f5104d54ca31f6a7cfbc762e9bf3a8df9 100755 (executable)
@@ -180,24 +180,14 @@ ERROR: unknown-component-type n ;
         { 1 [ 255 ] }
         { 2 [ 127 ] }
         { 4 [ 17 ] }
-        { 8 [ 1 ] }
     } case ;
 
 : scale-greyscale ( byte-array loading-png -- byte-array' )
-    [ bit-depth>> ] [ color-type>> ] bi {
-        { greyscale [
-            dup 16 = [
-                drop
-            ] [
-                scale-factor '[ _ * ] B{ } map-as
-            ] if
-        ] }
-        { greyscale-alpha [
-            [ 8 group ] dip '[
-                [ [ 0 5 ] dip <slice> [ _ * ] change-each ] keep
-            ] map B{ } concat-as
-        ] }
-    } case ;
+    bit-depth>> dup 8 >= [
+        drop
+    ] [
+        scale-factor '[ _ * ] B{ } map-as
+    ] if ;
 
 : decode-greyscale ( loading-png -- byte-array )
     [ raw-bytes ] keep scale-greyscale ;
@@ -235,7 +225,7 @@ ERROR: invalid-color-type/bit-depth loading-png ;
             validate-indexed-color unimplemented-color-type
         ] }
         { greyscale-alpha [
-            validate-greyscale-alpha decode-greyscale LA
+            validate-greyscale-alpha raw-bytes LA
         ] }
         { truecolor-alpha [
             validate-truecolor-alpha raw-bytes RGBA