Jump to content

Bitmap/Read a PPM file: Difference between revisions

Line 1,182:
 
'''</lang>
 
=={{header|Racket}}==
<lang racket>
#lang racket
(require racket/draw)
 
(define (read-ppm port)
(parameterize ([current-input-port port])
(define magic (read))
(define width (read))
(define height (read))
(define maxcol (read))
(define bm (make-object bitmap% width height))
(define dc (new bitmap-dc% [bitmap bm]))
(send dc set-smoothing 'unsmoothed)
(define (adjust v) (* 255 (/ v maxcol)))
(for/list ([x width])
(for/list ([y height])
(define red (read))
(define green (read))
(define blue (read))
(define color (make-object color% (adjust red) (adjust green) (adjust blue)))
(send dc set-pen color 1 'solid)
(send dc draw-point x y)))
bm))
</lang>
 
 
=={{header|Ruby}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.