[plt-scheme] pict->image

From: Mark Engelberg (mark.engelberg at gmail.com)
Date: Tue Dec 22 23:52:28 EST 2009

I tried this:

(define (pict->image p)
  (let* ([w (inexact->exact (ceiling (pict-width p)))]
         [h (inexact->exact (ceiling (pict-height p)))]
         [b (make-object bitmap% w h)]
         [dc (new bitmap-dc% [bitmap b])])
    (draw-pict p dc 0 0)
    b))

The bitmap doesn't seem to be interchangeable with image.  For
example, I get errors like:
place-image: expected <image> as first argument, given: #<bitmap%>

I also tried returning the bitmap-dc% object rather than bitmap%, with
similar errors.

Can you elaborate a bit on how to make this bitmap work with the image
teachpack?

Thanks,

Mark

On Tue, Dec 22, 2009 at 8:57 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> It is possible to turn a pict into a bitmap, by creating a bitmap% of
> the right size, putting it into a bitmap-dc% and then using the
> draw-pict function. This bitmap will work fine as a htdp/image, but
> won't be optimal as a 2htdp/image, because scaling and image equality
> won't work as well as it could (but it should still work).
>
> hth,.
> Robby
>
> On Mon, Dec 21, 2009 at 6:34 PM, Mark Engelberg
> <mark.engelberg at gmail.com> wrote:
>> What's the process for converting a pict (as defined in the slideshow
>> module) to an image (as defined in the image teachpack)?
>>
>> Specifically, I want to use slideshow's ability to format long text as
>> a paragraph (par) in order to create paragraphs that can be placed in
>> a universe scene.
>>
>> Thanks,
>>
>> Mark
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>


Posted on the users mailing list.