From e8f774f485f201f4284fb3ea876c01abfe9831e7 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 6 Nov 2009 00:43:59 -0600 Subject: [PATCH] fix display issue with png files where height not a multiple of 4 --- basis/images/png/png.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/basis/images/png/png.factor b/basis/images/png/png.factor index cb9a347de1..26c3ebee34 100755 --- a/basis/images/png/png.factor +++ b/basis/images/png/png.factor @@ -290,6 +290,14 @@ ERROR: invalid-color-type/bit-depth loading-png ; : validate-truecolor-alpha ( loading-png -- loading-png ) { 8 16 } validate-bit-depth ; +: pad-bitmap ( image -- image ) + dup dim>> first 4 divisor? [ + dup [ bytes-per-pixel ] + [ dim>> first * ] + [ dim>> first 4 mod ] tri + '[ _ group [ _ 0 append ] map B{ } concat-as ] change-bitmap + ] unless ; + : loading-png>bitmap ( loading-png -- bytes component-order ) dup color-type>> { { greyscale [ @@ -315,7 +323,7 @@ ERROR: invalid-color-type/bit-depth loading-png ; [ loading-png>bitmap [ >>bitmap ] [ >>component-order ] bi* ] [ [ width>> ] [ height>> ] bi 2array >>dim ] [ png-component >>component-type ] - } cleave ; + } cleave pad-bitmap ; : load-png ( stream -- loading-png ) [