From f81ebbfbf79f929e98d54e5e861f43a813e9d20b Mon Sep 17 00:00:00 2001 From: John Clements Date: Wed, 28 Apr 2010 11:48:07 -0700 Subject: [PATCH] Exported save-image per Matthias' request, wrote conservative documentation --- collects/2htdp/image.rkt | 2 ++ .../teachpack/2htdp/scribblings/image-gen.rkt | 3 +-- .../teachpack/2htdp/scribblings/image.scrbl | 21 ++++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/collects/2htdp/image.rkt b/collects/2htdp/image.rkt index d2f5adc208..f52e490070 100644 --- a/collects/2htdp/image.rkt +++ b/collects/2htdp/image.rkt @@ -115,6 +115,8 @@ and they all have good sample contracts. (It is amazing what we can do with kids make-color make-pen + + save-image ) (provide bitmap) diff --git a/collects/teachpack/2htdp/scribblings/image-gen.rkt b/collects/teachpack/2htdp/scribblings/image-gen.rkt index 2421d6c221..36b5fd00bb 100644 --- a/collects/teachpack/2htdp/scribblings/image-gen.rkt +++ b/collects/teachpack/2htdp/scribblings/image-gen.rkt @@ -5,8 +5,7 @@ (require 2htdp/image lang/posn - scheme/runtime-path - (only-in 2htdp/private/image-more save-image)) + scheme/runtime-path) (define-runtime-path image.scrbl "image.scrbl") (define-runtime-path img "img") diff --git a/collects/teachpack/2htdp/scribblings/image.scrbl b/collects/teachpack/2htdp/scribblings/image.scrbl index 1ff710b855..830879cb24 100644 --- a/collects/teachpack/2htdp/scribblings/image.scrbl +++ b/collects/teachpack/2htdp/scribblings/image.scrbl @@ -4,7 +4,8 @@ 2htdp/image (except-in lang/htdp-beginner make-posn posn? posn-x posn-y image?) lang/posn - scheme/gui/base) + scheme/gui/base + (only-in scheme/base path-string?)) lang/posn "shared.ss" "image-util.ss" @@ -1044,3 +1045,21 @@ pixel wide pen draws the pixels above and below the line, but each with a color that is half of the intensity of the given color. Using a @scheme[pen] with with two, colors the pixels above and below the line with the full intensity. + + +@;----------------------------------------------------------------------------- +@section{Exporting Images to Disk} + +In order to use an image as an input to another program (Photoshop, e.g., or +a web browser), it is necessary to represent it in a format that these programs +can understand. The @scheme[save-image] function provides this functionality, +writing an image to disk using the @tt{PNG} format. Since this +format represents an image using a set of pixel values, an image written to disk +generally contains less information than the image that was written, and cannot be scaled +or manipulated as cleanly (by any image program). + +@defproc[(save-image [image image?] [filename path-string?]) boolean?]{ + writes an image to the path specified by @scheme[filename], using the + @tt{PNG} format.} + +