test8 mostly works

main
Matthew Butterick 8 years ago
parent 40553cedcf
commit 197acdd78c

@ -72,7 +72,7 @@ class PNGImage
@loadIndexedAlphaChannel()
else if @image.hasAlphaChannel
console.log("got alphachannel " + @image.colorType + " in png.coffee")
#console.log("got alphachannel " + @image.colorType + " in png.coffee")
# For PNG color types 4 and 6, the transparency data is stored as a alpha
# channel mixed in with the main image data. Separate this data out into an
# SMask object and store it separately in the PDF.
@ -107,13 +107,13 @@ class PNGImage
hitme = 0
splitAlphaChannel: ->
console.log("start splitAlphaChannel in png.coffee")
#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);
#console.log("hitme=" + hitme++)
#console.log("in png.coffee")
#console.log("decoded pixels length=" + pixels.length);
#console.log("decoded pixels=");
#console.log(pixels);
colorByteSize = @image.colors * @image.bits / 8
pixelCount = @width * @height
@ -128,13 +128,13 @@ class PNGImage
imgData[p++] = pixels[i++]
alphaChannel[a++] = pixels[i++]
console.log("uncompressed imgData length=" + imgData.length)
console.log("uncompressed imgData=")
console.log(imgData)
#console.log("uncompressed imgData length=" + imgData.length)
#console.log("uncompressed imgData=")
#console.log(imgData)
console.log("uncompressed alphaChannel length=" + alphaChannel.length)
console.log("uncompressed alphaChannel=")
console.log(alphaChannel)
#console.log("uncompressed alphaChannel length=" + alphaChannel.length)
#console.log("uncompressed alphaChannel=")
#console.log(alphaChannel)
# boomstick temp
#@imgData = imgData
@ -145,22 +145,22 @@ class PNGImage
done = 0
zlib.deflate imgData, (err, @imgData) =>
throw err if err
console.log("compressed @imgData length=" + @imgData.length)
console.log("compressed @imgData=")
console.log(@imgData)
#console.log("compressed @imgData length=" + @imgData.length)
#console.log("compressed @imgData=")
#console.log(@imgData)
@finalize() if ++done is 2
zlib.deflate alphaChannel, (err, @alphaChannel) =>
throw err if err
console.log("compressed @alphaChannel length=" + @alphaChannel.length)
console.log("compressed @alphaChannel=")
console.log(@alphaChannel)
#console.log("compressed @alphaChannel length=" + @alphaChannel.length)
##console.log("compressed @alphaChannel=")
#console.log(@alphaChannel)
@finalize() if ++done is 2
loadIndexedAlphaChannel: (fn) ->
transparency = @image.transparency.indexed
console.log("oh hello")
#console.log("oh hello")
@image.decodePixels (pixels) =>
alphaChannel = new Buffer(@width * @height)

@ -140,8 +140,8 @@ module.exports = class PNG
pixelBytes = @pixelBitlength / 8
scanlineLength = pixelBytes * @width
console.log("pixelBytes="+ pixelBytes)
console.log("scanlineLength="+ scanlineLength)
#console.log("pixelBytes="+ pixelBytes)
#console.log("scanlineLength="+ scanlineLength)
pixels = new Buffer(scanlineLength * @height)
length = data.length

@ -173,7 +173,7 @@
};
PNG.prototype.decodePixels = function(fn) {
console.log("start decodePixels in png-node.js")
//console.log("start decodePixels in png-node.js")
var _this = this;
return zlib.inflate(this.imgData, function(err, data) {
var byte, c, col, i, left, length, p, pa, paeth, pb, pc, pixelBytes, pixels, pos, row, scanlineLength, upper, upperLeft, _i, _j, _k, _l, _m;
@ -182,8 +182,8 @@
}
pixelBytes = _this.pixelBitlength / 8;
scanlineLength = pixelBytes * _this.width;
console.log("pixelBytes="+ pixelBytes);
console.log("scanlineLength="+ scanlineLength);
//console.log("pixelBytes="+ pixelBytes);
//console.log("scanlineLength="+ scanlineLength);
pixels = new Buffer(scanlineLength * _this.height);
length = data.length;
@ -251,10 +251,10 @@
}
row++;
}
console.log("in png-node.js")
console.log("decoded pixels length=" + pixels.length);
console.log("decoded pixels=");
console.log(pixels);
//console.log("in png-node")
//console.log("decoded pixels length=" + pixels.length);
//console.log("decoded pixels=");
//console.log(pixels);
return fn(pixels);
});
};
@ -313,7 +313,7 @@
};
PNG.prototype.decode = function(fn) {
console.log("another call to decodePixels")
//console.log("another call to decodePixels")
var ret,
_this = this;
ret = new Buffer(this.width * this.height * 4);

@ -24,14 +24,15 @@
(check-equal? (bytes-length (file->bytes this))
(bytes-length (file->bytes (this->pdfkit-control this)))))
(define (make-doc ps compress? [proc (λ (doc) doc)] #:test [test? #t])
(define (make-doc ps compress? [proc (λ (doc) doc)] #:test [test? #t] #:pdfkit [pdfkit? #t])
(define doc (make-object PDFDocument (hash 'compress compress?)))
(send doc pipe (open-output-file ps #:exists 'replace))
(proc doc)
(send doc end)
(when test?
(check-copy-equal? ps)
(check-pdfkit? ps)))
(when pdfkit?
(check-pdfkit? ps))))
(module reader syntax/module-reader

@ -171,8 +171,8 @@ Grab key chunks from PNG. Doesn't require heavy lifting from libpng.
)]
[else (error 'invalid-filter-algorithm (format "~a" b))])))
(report (bytes-length pixels) 'decoded-pixels-length)
(report (bytes->hex (subbytes pixels 0 20)))
#;(report (bytes-length pixels) 'decoded-pixels-length)
#;(report (bytes->hex (subbytes pixels 0 20)))
(fn pixels))

@ -112,11 +112,11 @@
(define alphaChannel (apply bytes (reverse alphaBytes)))
(report (bytes-length imgData) 'uncompressed-imgdata-length)
(report (bytes->hex (subbytes imgData 0 20)) 'uncompressed-imgdata)
#;(report (bytes-length imgData) 'uncompressed-imgdata-length)
#;(report (bytes->hex (subbytes imgData 0 20)) 'uncompressed-imgdata)
(report (bytes-length alphaChannel) 'uncompressed-alphaChannel-length)
(report (bytes->hex (subbytes alphaChannel 0 20)) 'uncompressed-alphaChannel)
#;(report (bytes-length alphaChannel) 'uncompressed-alphaChannel-length)
#;(report (bytes->hex (subbytes alphaChannel 0 20)) 'uncompressed-alphaChannel)
#;(report* (bytes-length imgData) (bytes-length alphaChannel))
@ -126,11 +126,11 @@
(define alphaChannelCompressed (deflate alphaChannel))
(report (bytes-length alphaChannelCompressed) 'alphaChannelCompressed-length)
(report (bytes->hex (subbytes alphaChannelCompressed 0 20)) 'alphaChannelCompressed)
#;(report (bytes-length alphaChannelCompressed) 'alphaChannelCompressed-length)
#;(report (bytes->hex (subbytes alphaChannelCompressed 0 20)) 'alphaChannelCompressed)
(report (bytes-length imgDataCompressed) 'imgDataCompressed-length)
(report (bytes->hex (subbytes imgDataCompressed 0 20)) 'imgDataCompressed)
#;(report (bytes-length imgDataCompressed) 'imgDataCompressed-length)
#;(report (bytes->hex (subbytes imgDataCompressed 0 20)) 'imgDataCompressed)
(set-field! imgData this imgDataCompressed)

Binary file not shown.

@ -10,7 +10,7 @@
[image pic 100 160 (hash 'width 412)]))
(define-runtime-path this "test8rkt.pdf")
(make-doc this #f proc #:test #f)
(make-doc this #f proc #:pdfkit #f) ; node's zlib.deflate makes smaller files, for some reason
#;(define-runtime-path that "test8crkt.pdf")
#;(make-doc that #t proc)
(define-runtime-path that "test8crkt.pdf")
(make-doc that #t proc #:pdfkit #f)

Loading…
Cancel
Save