ushort pngs are byte-reversed from how i'm reading them -- fixed.
parent
2945393965
commit
fd4c6b73bb
|
@ -3,7 +3,7 @@
|
||||||
USING: accessors arrays checksums checksums.crc32 combinators
|
USING: accessors arrays checksums checksums.crc32 combinators
|
||||||
compression.inflate fry grouping images images.loader io
|
compression.inflate fry grouping images images.loader io
|
||||||
io.binary io.encodings.ascii io.encodings.string kernel locals
|
io.binary io.encodings.ascii io.encodings.string kernel locals
|
||||||
math math.bitwise math.ranges sequences sorting ;
|
math math.bitwise math.ranges sequences sorting assocs ;
|
||||||
QUALIFIED-WITH: bitstreams bs
|
QUALIFIED-WITH: bitstreams bs
|
||||||
IN: images.png
|
IN: images.png
|
||||||
|
|
||||||
|
@ -183,11 +183,11 @@ ERROR: unknown-component-type n ;
|
||||||
} case ;
|
} case ;
|
||||||
|
|
||||||
: scale-greyscale ( byte-array loading-png -- byte-array' )
|
: scale-greyscale ( byte-array loading-png -- byte-array' )
|
||||||
bit-depth>> dup 8 >= [
|
bit-depth>> {
|
||||||
drop
|
{ 8 [ ] }
|
||||||
] [
|
{ 16 [ 2 group [ swap ] assoc-map B{ } concat-as ] }
|
||||||
scale-factor '[ _ * ] B{ } map-as
|
[ scale-factor '[ _ * ] B{ } map-as ]
|
||||||
] if ;
|
} case ;
|
||||||
|
|
||||||
: decode-greyscale ( loading-png -- byte-array )
|
: decode-greyscale ( loading-png -- byte-array )
|
||||||
[ raw-bytes ] keep scale-greyscale ;
|
[ raw-bytes ] keep scale-greyscale ;
|
||||||
|
@ -213,6 +213,11 @@ ERROR: invalid-color-type/bit-depth loading-png ;
|
||||||
: validate-truecolor-alpha ( loading-png -- loading-png )
|
: validate-truecolor-alpha ( loading-png -- loading-png )
|
||||||
{ 8 16 } validate-bit-depth ;
|
{ 8 16 } validate-bit-depth ;
|
||||||
|
|
||||||
|
: decode-greyscale-alpha ( loading-image -- byte-array' )
|
||||||
|
[ raw-bytes ] [ bit-depth>> ] bi 16 = [
|
||||||
|
3 group [ first3 swapd 3array ] map B{ } concat-as
|
||||||
|
] when ;
|
||||||
|
|
||||||
: loading-png>bitmap ( loading-png -- bytes component-order )
|
: loading-png>bitmap ( loading-png -- bytes component-order )
|
||||||
dup color-type>> {
|
dup color-type>> {
|
||||||
{ greyscale [
|
{ greyscale [
|
||||||
|
@ -225,7 +230,7 @@ ERROR: invalid-color-type/bit-depth loading-png ;
|
||||||
validate-indexed-color unimplemented-color-type
|
validate-indexed-color unimplemented-color-type
|
||||||
] }
|
] }
|
||||||
{ greyscale-alpha [
|
{ greyscale-alpha [
|
||||||
validate-greyscale-alpha raw-bytes LA
|
validate-greyscale-alpha decode-greyscale-alpha LA
|
||||||
] }
|
] }
|
||||||
{ truecolor-alpha [
|
{ truecolor-alpha [
|
||||||
validate-truecolor-alpha raw-bytes RGBA
|
validate-truecolor-alpha raw-bytes RGBA
|
||||||
|
|
Loading…
Reference in New Issue