smask works

main
Matthew Butterick 8 years ago
parent 6804a31629
commit 40553cedcf

@ -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)

@ -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);

@ -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)))

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save