[racket] reading pixels from a file...

From: geb a (geb_a at yahoo.com)
Date: Wed Apr 11 16:49:45 EDT 2012

Some students are trying to do a pixel by pixel operation on a 640x480 size picture and my student's code is operating very slowly.  I've heard that Racket can process images quickly but apparently we are doing something very wrong.  There are a few parts to this problem.  This is the first one:  Reading the image into a representation.  I'm not sure how to make this more efficient. Is there something I'm missing?

We have very new computers running the latest stable version of Racket. Operating system is Fedora Core 14  (64 bit version).

#lang racket
(require mred)
(define bmdc (make-object bitmap% "apple.jpg"))
(define-struct rect (x y w h))

(define pw (send bmdc get-width))
(define ph (send bmdc get-height))

;get-my-colors: num num num num -> byte-string
(define (get-mycolors x y w h)
  (let* (
         (pixels (make-bytes (* w h 4) 0))
         (myrectangle (send bmdc get-argb-pixels x y w h pixels false)))
(get-mycolors 0 0 pw ph)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120411/4c9f2b82/attachment.html>

Posted on the users mailing list.