bitmap-dc% : class? | ||
superclass: object% | ||
|
Drawing to a bitmap-dc% with a color bitmap is guaranteed to produce the same result as drawing into a canvas% instance (with appropriate clipping and offsets). Thus, a bitmap-dc% can be used for offscreen staging of canvas content.
(new bitmap-dc% [bitmap bitmap]) → (is-a?/c bitmap-dc%) |
bitmap : (or/c (is-a?/c bitmap%) false/c) |
| ||||||||||||||||||||||||||||||||||||||||
→ boolean? | ||||||||||||||||||||||||||||||||||||||||
source : (is-a?/c bitmap%) | ||||||||||||||||||||||||||||||||||||||||
dest-x : real? | ||||||||||||||||||||||||||||||||||||||||
dest-y : real? | ||||||||||||||||||||||||||||||||||||||||
dest-width : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||
dest-height : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||
src-x : real? | ||||||||||||||||||||||||||||||||||||||||
src-y : real? | ||||||||||||||||||||||||||||||||||||||||
src-width : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||
src-height : (and/c real? (not/c negative?)) | ||||||||||||||||||||||||||||||||||||||||
mask : (or/c (is-a?/c bitmap%) false/c) |
| ||||||||||||||||||||||||||||||||||||||||||
x : real? | ||||||||||||||||||||||||||||||||||||||||||
y : real? | ||||||||||||||||||||||||||||||||||||||||||
width : (integer-in 1 10000) | ||||||||||||||||||||||||||||||||||||||||||
height : (integer-in 1 10000) | ||||||||||||||||||||||||||||||||||||||||||
pixels : (and/c bytes? (not/c immutable?)) | ||||||||||||||||||||||||||||||||||||||||||
alpha? : any/c = #f |
The pixel RGB values are copied into pixels. The first byte represents an alpha value of the pixel at (x, y), the second byte represents a red value of the pixel at (x, y), the third byte is the blue value, etc. In this way, the first width * height *4 bytes of pixels are set to reflect the current pixel values in the DC. The pixels are in row-major order, left to right then top to bottom.
If alpha? is false, then the alpha value for each pixel is set to 255. If alpha? is true, then only the alpha value is set for each pixel, based on each pixel’s inverted value. Thus, the same 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.
Under X, interleaving drawing commands with get-pixel calls (for the same bitmap-dc% object) incurs a substantial performance penalty, except for interleaved calls to set-pixel, set-argb-pixels, and get-argb-pixels.
| ||||||||||||||||||||||||||||||||||||||||||
x : real? | ||||||||||||||||||||||||||||||||||||||||||
y : real? | ||||||||||||||||||||||||||||||||||||||||||
width : (integer-in 1 10000) | ||||||||||||||||||||||||||||||||||||||||||
height : (integer-in 1 10000) | ||||||||||||||||||||||||||||||||||||||||||
pixels : bytes? | ||||||||||||||||||||||||||||||||||||||||||
alpha? : any/c = #f |
Sets a rectangle of pixels in the bitmap, subject to the same rules and performance characteristics of set-pixel, except that the block set is likely to be faster than the sequence of individual sets.
The pixel RGB values are taken from pixels. The first byte represents an alpha value, the second byte represents a red value to used for the pixel at (x, y), the third byte is a blue value, etc. In this way, the first width * height * 4 bytes of pixels determine the new pixel values in the DC. The pixels are in row-major order, left to right then top to bottom.
If alpha? is false, then the alpha value for each pixel is ignored. If alpha? is true, then each pixel is set based only on the alpha value, but inverted to serve as a mask. Thus, the same pixels byte string is in general used with two bitmaps, one (the main image) for the pixel values and one (the mask) for the alpha values.
A bitmap can be selected into at most one bitmap DC, and only when it is not used by a control (as a label) or in a pen% or brush% (as a stipple). If the argument to set-bitmap is already in use by another DC, a control, a pen%, or a brush%, an exn:fail:contract exception is raised.