Created
March 8, 2017 21:59
-
-
Save LeifAndersen/8a4b9e5b80e3de35c4f8c289a2dd46c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define (grayscale-pict s) | |
| (define buf (pict->argb-pixels s)) | |
| (define gray-buf | |
| (apply bytes | |
| (append* | |
| (for/list ([i (in-range 0 (bytes-length buf) 4)]) | |
| (define a (bytes-ref buf i)) | |
| (define r (bytes-ref buf (+ i 1))) | |
| (define g (bytes-ref buf (+ i 2))) | |
| (define b (bytes-ref buf (+ i 3))) | |
| (define av (exact-floor (/ (+ r g b) 3))) | |
| (list a av av av))))) | |
| (argb-pixels->pict gray-buf (pict-width s))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment