fix bitmap-related docs

This commit is contained in:
Matthew Flatt 2010-08-01 07:08:58 -06:00
parent 439683af5e
commit af4ccd2de1
3 changed files with 17 additions and 15 deletions

View File

@ -104,7 +104,7 @@
(bytes-fill! (cairo_image_surface_get_data s) 255)]) (bytes-fill! (cairo_image_surface_get_data s) 255)])
s) s)
#f)] #f)]
[([path-string? filename] [([(make-alts path-string? input-port?) filename]
[kind-symbol? [kind 'unknown]] [kind-symbol? [kind 'unknown]]
[(make-or-false color%) [bg-color #f]]) [(make-or-false color%) [bg-color #f]])
(let-values ([(s b&w?) (do-load-bitmap filename kind bg-color)] (let-values ([(s b&w?) (do-load-bitmap filename kind bg-color)]

View File

@ -16,7 +16,7 @@ Sometimes, a bitmap object creation fails in a low-level manner. In
[height (integer-in 1 10000)] [height (integer-in 1 10000)]
[monochrome? any/c #f] [monochrome? any/c #f]
[alpha? 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 [kind (one-of/c 'unknown 'unknown/mask 'unknown/alpha
'gif 'gif/mask 'gif/alpha 'gif 'gif/mask 'gif/alpha
'jpeg 'jpeg/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 bitmap has an alpha channel; otherwise, the bitmap is color without
an alpha channel. The initial content of the bitmap is undefined. an alpha channel. The initial content of the bitmap is undefined.
When @scheme[filename] is provided: Creates a bitmap from a file, When @scheme[in] is provided: Creates a bitmap from a file format,
where @scheme[kind] specifies the kind of image file. See where @scheme[kind] specifies the format. See @method[bitmap%
@method[bitmap% load-file] for details. load-file] for details.
When a @scheme[bits] byte string is provided: Creates a monochrome 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 [kind (one-of/c 'unknown 'unknown/mask 'unknown/alpha
'gif 'gif/mask 'gif/alpha 'gif 'gif/mask 'gif/alpha
'jpeg 'jpeg/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]) [bg-color (or/c (is-a?/c color%) false/c) #f])
boolean?]{ boolean?]{
Loads a bitmap from a file. If the bitmap is in use by a Loads a bitmap from a file format that read from @racket[in].
@scheme[bitmap-dc%] object or a control, the bitmap file is not 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 loaded. The bitmap changes its size and depth to match that of
the loaded image. the loaded image.
The @scheme[kind] argument specifies the file's format: The @scheme[kind] argument specifies the file's format:
@itemize[ @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} or color bitmap without an alpha channel}
@item{@scheme['unknown/mask] --- like @scheme['unknown], but see @method[bitmap% get-loaded-mask]} @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 @item{@scheme['unknown/alpha] --- like @scheme['unknown], but if the bitmap is color, it has an

View File

@ -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 DC. The pixels are in row-major order, left to right then top to
bottom. bottom.
If @scheme[alpha?] is false, then the alpha value for each pixel is If @scheme[alpha?] is false, if the bitmap does not have an alpha
set to 255. If @scheme[alpha?] is true, then @italic{only} the alpha channel, then the alpha value for each pixel is set to 255. If
value is set for each pixel, based on each pixel's inverted value. Thus, the @scheme[alpha?] is true, then @italic{only} the alpha value is set
same @scheme[pixels] byte string is in general filled from two bitmaps: for each pixel, based on each pixel's inverted value. Thus, when a
one (the main image) for the pixel values and one (the mask) for the bitmap has a separate mask bitmap, the same @scheme[pixels] byte
alpha values. string is in general filled from two bitmaps: one (the main image)
for the pixel values and one (the mask) for the alpha values.
} }