added bitmap/file

closes PR 12466
This commit is contained in:
Robby Findler 2011-12-29 22:18:07 -06:00
parent 4c86e2fe86
commit f4b4e00c55
3 changed files with 21 additions and 1 deletions

View File

@ -135,7 +135,8 @@ and they all have good sample contracts. (It is amazing what we can do with kids
save-svg-image
freeze
bitmap/url)
bitmap/url
bitmap/file)
(provide bitmap
empty-image)

View File

@ -1317,6 +1317,14 @@
(λ (port)
(make-object bitmap% port 'unknown #f #t)))))
(define/chk (bitmap/file filename)
(unless (file-exists? filename)
(error 'bitmap/file
"could not find the file ~a"
filename))
(rotate
0
(read-bitmap filename)))
(define/chk (image->color-list image)
(let* ([w (image-width image)]
@ -1495,6 +1503,7 @@
bitmap
bitmap/url
bitmap/file
swizzle

View File

@ -1247,6 +1247,16 @@ See also the @racketmodname[2htdp/planetcute] library.
and then paste it into your program or download it and use @racket[bitmap].
}
@defproc[(bitmap/file [ps path-string?]) image?]{
Loads the image from @racket[ps].
If @racket[ps] is a relative path, the file is relative to
the current directory. (When running in DrRacket, the current
directory is set to the place where the definitions window is
saved, but in general this can be an arbitrary directory.)
}
@defproc[(image->color-list [image image?]) (listof color?)]{
Returns a list of colors that correspond to the colors in the
image, reading from left to right, top to bottom.