[plt-scheme] Writing a game and have questions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Sep 21 09:58:51 EDT 2008

Neil and Robby have given you good general answers --- compute the
target without referring to the image, or use regions instead of an
offscreen image --- but I'll answer the original questions:

At Sat, 20 Sep 2008 11:23:32 -0400, "deepankar" wrote:
> 1) Is it possible to draw a canvas to an offscreen buffer ?

You can take a function that draws to a canvas and redirect it so that
it draws to an offscreen image (i.e., swap a `bitmap-dc%' in place of a
canvas `dc<%>').

> 2) Is it possible to fetch pixel values from a canvas. 

Canvas drawing is one-way only: you can send an image out to the user
to see, but you cannot programmatically "look" at the canvas. Also,
there's no way to take a snapshot of the canvas to get back an
offscreen image.

If you redirect a drawing function to an offscreen image, then you
can, of course, inspect the pixels of the offscreen image.


Posted on the users mailing list.