diff --git a/pitfall/pdfkit/lib/image/png.coffee b/pitfall/pdfkit/lib/image/png.coffee index a66d5414..07ca725a 100644 --- a/pitfall/pdfkit/lib/image/png.coffee +++ b/pitfall/pdfkit/lib/image/png.coffee @@ -104,9 +104,13 @@ class PNGImage @image = null @imgData = null + hitme = 0 + splitAlphaChannel: -> console.log("start splitAlphaChannel in png.coffee") @image.decodePixels (pixels) => + console.log("hitme=" + hitme++) + console.log("in png.coffee") console.log("decoded pixels length=" + pixels.length); console.log("decoded pixels="); console.log(pixels); @@ -132,6 +136,12 @@ class PNGImage console.log("uncompressed alphaChannel=") console.log(alphaChannel) + # boomstick temp + #@imgData = imgData + #@alphaChannel = alphaChannel + #@finalize() + # end boomstick temp + done = 0 zlib.deflate imgData, (err, @imgData) => throw err if err @@ -150,6 +160,7 @@ class PNGImage loadIndexedAlphaChannel: (fn) -> transparency = @image.transparency.indexed + console.log("oh hello") @image.decodePixels (pixels) => alphaChannel = new Buffer(@width * @height) diff --git a/pitfall/pdfkit/node_modules/png-js/png-node.js b/pitfall/pdfkit/node_modules/png-js/png-node.js index c28e28a8..2fca0ce7 100644 --- a/pitfall/pdfkit/node_modules/png-js/png-node.js +++ b/pitfall/pdfkit/node_modules/png-js/png-node.js @@ -251,6 +251,7 @@ } row++; } + console.log("in png-node.js") console.log("decoded pixels length=" + pixels.length); console.log("decoded pixels="); console.log(pixels); diff --git a/pitfall/pitfall/png-reader.rkt b/pitfall/pitfall/png-reader.rkt index 1b0c868c..9fc9a792 100644 --- a/pitfall/pitfall/png-reader.rkt +++ b/pitfall/pitfall/png-reader.rkt @@ -113,9 +113,10 @@ Grab key chunks from PNG. Doesn't require heavy lifting from libpng. (define col ((i . - . (modulo i pixelBytes)) . / . pixelBytes)) (define upper (if (zero? row) row - (+ (* (bytes-ref pixels (sub1 row)) scanlineLength) - (* col pixelBytes) - (modulo i pixelBytes)))) + (bytes-ref pixels + (+ (* (sub1 row) scanlineLength) + (* col pixelBytes) + (modulo i pixelBytes))))) (bytes-set! pixels c (modulo (+ upper byte) 256)) (increment! c))] [(3) ; average @@ -127,9 +128,10 @@ Grab key chunks from PNG. Doesn't require heavy lifting from libpng. (bytes-ref pixels (- c pixelBytes)))) (define upper (if (zero? row) row - (+ (* (bytes-ref pixels (sub1 row)) scanlineLength) - (* col pixelBytes) - (modulo i pixelBytes)))) + (bytes-ref pixels + (+ (* (sub1 row) scanlineLength) + (* col pixelBytes) + (modulo i pixelBytes))))) (bytes-set! pixels c (modulo (+ byte (floor (/ (+ left upper) 2))) 256)) (increment! c))] [(4) ; paeth @@ -142,12 +144,16 @@ Grab key chunks from PNG. Doesn't require heavy lifting from libpng. (match-define (list upper upperLeft) (cond [(zero? row) (list 0 0)] - [else (define upper (+ (* (bytes-ref pixels (sub1 row)) scanlineLength) - (* col pixelBytes) - (modulo i pixelBytes))) - (define upperLeft (+ (* (bytes-ref pixels (sub1 row)) scanlineLength) - (* (sub1 col) pixelBytes) - (modulo i pixelBytes))) + [else (define upper (bytes-ref pixels + (+ (* (sub1 row) scanlineLength) + (* col pixelBytes) + (modulo i pixelBytes)))) + (define upperLeft (if (zero? col) + col + (bytes-ref pixels + (+ (* (sub1 row) scanlineLength) + (* (sub1 col) pixelBytes) + (modulo i pixelBytes))))) (list upper upperLeft)])) (define p (+ left upper (- upperLeft))) diff --git a/pitfall/pitfall/test/test8.pdf b/pitfall/pitfall/test/test8.pdf index b87ffa3a..ebe02788 100644 Binary files a/pitfall/pitfall/test/test8.pdf and b/pitfall/pitfall/test/test8.pdf differ diff --git a/pitfall/pitfall/test/test8rkt.pdf b/pitfall/pitfall/test/test8rkt.pdf index 69f1b03d..a3c965d5 100644 Binary files a/pitfall/pitfall/test/test8rkt.pdf and b/pitfall/pitfall/test/test8rkt.pdf differ