4.2 Bitmaps
class | ||||||
|
The backing_scale argument determines the bitmap’s backing scale, which is the number of pixels that correspond to a drawing unit for the bitmap, either when the bitmap is used as a target for drawing or when the bitmap is drawn into another context. A monochrome bitmap must have a backing scale of 1.0.
A bitmap is convertible to #'#{png-bytes} through the file/convertible protocol.
function | ||||
|
property | |
| |
property | |
| |
property | |
| |
property | |
| |
property | |
| |
property | |
| |
property | |
method | ||||||||||
|
The pixel red, green blue, and alpha values are copied into dest (or just alpha values if just_alpha is true). 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 green value, etc. In this way, the first width*height*4 bytes of dest 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 the bitmap has an alpha channel, then the alpha value for each pixel is always set in dest. If just_alpha is false and the bitmap does not have an alpha channel, then the alpha value for each pixel is set to 255. If just_alpha is true, then only the alpha value is set for each pixel; if the bitmap has no alpha channel, then the alpha value is based on each pixel’s inverted red-green-blue average.
If premultiplied is true, just_alpha is false, and the bitmap has an alpha channel, then red, green, and blue values in the result are scaled by the corresponding alpha value (i.e., multiplied by the alpha value and then divided by 255).
If the bitmap has a backing scale other than 1.0 and unscaled is #false, the result of Bitmap.argb_pixels is as if the bitmap is drawn to a bitmap with a backing scale of 1.0 and the pixels of the target bitmap are returned.
method | ||||||||||
|
method | ||||||
|
The quality argument applies only to the #'jpeg format, in which case it specifies the trade-off between image precision (high quality matches the content of the Bitmap object more precisely) and size (low quality is smaller).
The as_unscaled argument is relevant when the bitmap has a backing scale other than 1.0. In that case, if as_unscaled is #false, the bitmap is effectively converted to a single pixel per drawing unit before writing.
function | |
|
property | |
| |
function | |
enumeration | ||||
|