From 83be477643f91ed6d18df6db1fb1aa66e8716a19 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 3 Dec 2018 10:30:56 -0800 Subject: [PATCH] note re slow png --- pitfall/pitfall/png.rkt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pitfall/pitfall/png.rkt b/pitfall/pitfall/png.rkt index 387ad91c..a76f7245 100644 --- a/pitfall/pitfall/png.rkt +++ b/pitfall/pitfall/png.rkt @@ -6,7 +6,7 @@ (define-subclass object% (PNG data [label #f]) - (field [image (read-png data)] + (field [image (read-png data)] ; `image` is a hash [pixelBitlength (· image pixelBitlength)] [width (· image width)] [height (· image height)] @@ -86,11 +86,15 @@ ;; embed the actual image data (send (· this obj) end (· this imgData))) - +(require sugar/debug) +;; todo: this function is too slow. +;; switch to draw/unsafe/png (define/contract (splitAlphaChannel this) (->m void?) + #;(report 'pixels) (define pixels (decodePixels (· this imgData) (· this pixelBitlength) (· this width) (· this height))) + #;(report '(imgBytes alphaBytes)) (define-values (imgBytes alphaBytes) (for/fold ([img-bytes empty] [alpha-bytes empty]) @@ -100,7 +104,9 @@ (values img-bytes (cons b alpha-bytes)) (values (cons b img-bytes) alpha-bytes)))) + #;(report 'deflate-imgBytes) (set-field! imgData this (deflate (apply bytes (reverse imgBytes)))) + #;(report 'deflate-alphaBytes) (set-field! alphaChannel this (deflate (apply bytes (reverse alphaBytes))))) #;(module+ test