[plt-scheme] 2htdp/image questions

From: engineer at alum.mit.edu (engineer at alum.mit.edu)
Date: Wed Apr 21 11:14:08 EDT 2010

I've been trying to do something related to this discussion.  I'd like to
convert a complicated 2htdp/image into a bitmap and back, hoping it will
make for a quicker render.

I have an animation with many shapes being drawn, however most shapes do not
frequently change.  It seems clear to me (after some investigating) that my
background being made of hundreds/thousands of shapes is my main problem, as
opposed to the other calculations I'm doing.  I was surprised to find that
even a non-mutating, constant image background was slow to render if
initially made of many shapes.  Yet a single, large, cut-n-pasted image was
not slow.

How can I "flatten" the image?  I'm thinking that a bitmap with the shape
info forgotten would really speed things up.  My plan is to separate the
overall image-scene into a static background which updates only infrequently
and a dynamic state which updates after every event.

Sorry I haven't seen any obvious way of doing this myself after searching
through the bitmap references, but I'm hoping for something like:

(bitmap->image (image->bitmap fancy-scene))

If this is not easily done yet, I am happy to use something complicated.  I
can wrap it in a Teachpack for my student.

BTW, this is being motivated by a breakout/arkanoid game my student is
working on.  The balls' movements become very choppy once we are trying to
draw lots of bricks.

Thanks very much in advance for any help,
Paul

> > On Sun, Apr 18, 2010 at 9:07 AM, Robby Findler
> > <robby at eecs.northwestern.edu> wrote:
> >> As it turns out, That is a bad idea for performance reasons (computing
> >> the bitmap is far more expensive than any of the other things that get
> >> done to images) but image equality has to do that (in the fallback
> >> slow path), so it would not be too hard to add a get-pixel function
> >> that first computed the image and the returned the pixel.
> >
> > For personal curiosity's sake, do you have to compute the bitmap to
> > display the image within DrScheme, or does the translation actually
> > happen in the video driver or somewhere else deep in the bowels of the
> > OS?
> 
> It happens on the graphics card, typically (I believe). But it depends
> on various details of the platform (and I'm not sure I know them all;
> 2htdp/image is written at the Scheme level).
> 
> Robby
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.