2

Both, the official racket tutorial and the book, "Realm of Racket" suggest using Dr. Racket to load and define images in Racket.

I however am using Geiser (racket-repl) with Emacs. I define images using the

(make-object bitmap% (image-location)) 

function.

Is this the best way to load an image? Or are there more efficient and easy ways? I ask because I was confronted with this problem.

Community
  • 1
  • 1
Roald
  • 231
  • 1
  • 12

1 Answers1

5

If you are already using the 2htdp/image library (which your other SO post suggests), then you may wish to use the bitmap function from the same library. See this section of the documentation for 2htdp/image.

You can use it like this:

#lang racket
(require 2htdp/image)
(define my-image (bitmap "path/to/image.png"))
Asumu Takikawa
  • 8,447
  • 1
  • 28
  • 43