From af4ccd2de190cff8caecb0a596d7f5e4396d095a Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 1 Aug 2010 07:08:58 -0600 Subject: [PATCH] fix bitmap-related docs --- collects/racket/draw/bitmap.rkt | 2 +- collects/scribblings/gui/bitmap-class.scrbl | 17 +++++++++-------- collects/scribblings/gui/bitmap-dc-class.scrbl | 13 +++++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/collects/racket/draw/bitmap.rkt b/collects/racket/draw/bitmap.rkt index f25b996ed9..9810d4b0cd 100644 --- a/collects/racket/draw/bitmap.rkt +++ b/collects/racket/draw/bitmap.rkt @@ -104,7 +104,7 @@ (bytes-fill! (cairo_image_surface_get_data s) 255)]) s) #f)] - [([path-string? filename] + [([(make-alts path-string? input-port?) filename] [kind-symbol? [kind 'unknown]] [(make-or-false color%) [bg-color #f]]) (let-values ([(s b&w?) (do-load-bitmap filename kind bg-color)] diff --git a/collects/scribblings/gui/bitmap-class.scrbl b/collects/scribblings/gui/bitmap-class.scrbl index 2c36253cee..0cf1c9e569 100644 --- a/collects/scribblings/gui/bitmap-class.scrbl +++ b/collects/scribblings/gui/bitmap-class.scrbl @@ -16,7 +16,7 @@ Sometimes, a bitmap object creation fails in a low-level manner. In [height (integer-in 1 10000)] [monochrome? any/c #f] [alpha? any/c #f]) - ([filename path-string?] + ([in (or/c path-string? input-port?)] [kind (one-of/c 'unknown 'unknown/mask 'unknown/alpha 'gif 'gif/mask 'gif/alpha 'jpeg 'jpeg/alpha @@ -35,9 +35,9 @@ When @scheme[width] and @scheme[height] are provided: Creates a new bitmap has an alpha channel; otherwise, the bitmap is color without an alpha channel. The initial content of the bitmap is undefined. -When @scheme[filename] is provided: Creates a bitmap from a file, - where @scheme[kind] specifies the kind of image file. See - @method[bitmap% load-file] for details. +When @scheme[in] is provided: Creates a bitmap from a file format, + where @scheme[kind] specifies the format. See @method[bitmap% + load-file] for details. When a @scheme[bits] byte string is provided: Creates a monochrome @@ -139,7 +139,7 @@ Returns @scheme[#f] if the bitmap is monochrome, @scheme[#t] otherwise. } -@defmethod[(load-file [name path-string?] +@defmethod[(load-file [in (or/c path-string? input-port?)] [kind (one-of/c 'unknown 'unknown/mask 'unknown/alpha 'gif 'gif/mask 'gif/alpha 'jpeg 'jpeg/alpha @@ -150,15 +150,16 @@ Returns @scheme[#f] if the bitmap is monochrome, @scheme[#t] otherwise. [bg-color (or/c (is-a?/c color%) false/c) #f]) boolean?]{ -Loads a bitmap from a file. If the bitmap is in use by a - @scheme[bitmap-dc%] object or a control, the bitmap file is not +Loads a bitmap from a file format that read from @racket[in]. + If the bitmap is in use by a + @scheme[bitmap-dc%] object or a control, the image data is not loaded. The bitmap changes its size and depth to match that of the loaded image. The @scheme[kind] argument specifies the file's format: @itemize[ -@item{@scheme['unknown] --- examine the file to determine its format; creates either a monochrome or +@item{@scheme['unknown] --- examine the file to determine its format; creates either a monochrome or color bitmap without an alpha channel} @item{@scheme['unknown/mask] --- like @scheme['unknown], but see @method[bitmap% get-loaded-mask]} @item{@scheme['unknown/alpha] --- like @scheme['unknown], but if the bitmap is color, it has an diff --git a/collects/scribblings/gui/bitmap-dc-class.scrbl b/collects/scribblings/gui/bitmap-dc-class.scrbl index 58d649d4b8..d2f907971c 100644 --- a/collects/scribblings/gui/bitmap-dc-class.scrbl +++ b/collects/scribblings/gui/bitmap-dc-class.scrbl @@ -70,12 +70,13 @@ The pixel RGB values are copied into @scheme[pixels]. The first byte DC. The pixels are in row-major order, left to right then top to bottom. -If @scheme[alpha?] is false, then the alpha value for each pixel is - set to 255. If @scheme[alpha?] is true, then @italic{only} the alpha - value is set for each pixel, based on each pixel's inverted value. Thus, the - same @scheme[pixels] byte string is in general filled from two bitmaps: - one (the main image) for the pixel values and one (the mask) for the - alpha values. +If @scheme[alpha?] is false, if the bitmap does not have an alpha + channel, then the alpha value for each pixel is set to 255. If + @scheme[alpha?] is true, then @italic{only} the alpha value is set + for each pixel, based on each pixel's inverted value. Thus, when a + bitmap has a separate mask bitmap, the same @scheme[pixels] byte + string is in general filled from two bitmaps: one (the main image) + for the pixel values and one (the mask) for the alpha values. }