Daquicker
Daquicker

Reputation: 525

Dr Racket get pixmap width/height

I'm working on a project for university and was wondering if it is possible to get the height and width of a pixmap in some way. I know it is possible for rectangles and circles and stuff... I'm using this to draw the pixmap, file is a jpg:

(define (draw-image! x y file)
  (let ((posn (my-make-posn x y)))
    ((draw-pixmap MainWindow) file posn)))

Upvotes: 1

Views: 1443

Answers (1)

John Clements
John Clements

Reputation: 17233

Perhaps you already know this, but the library you're using is deprecated: in the manual, you'll see that it's part of the "Legacy Library."

Here's a simple program that loads a picture from a jpg, displays it, and prints its dimensions, using the 2htdp/image library:

#lang racket

(require 2htdp/image)

(define pic
  (bitmap "/Users/clements/Pictures/Photo Booth Library/Pictures/Photo on 2012-02-12 at 10.53.jpg"))
pic
(image-height pic)
(image-width pic)

You'll probably have to update the path....

Upvotes: 3

Related Questions