Image::Gray8
Inherits Image::PixelBuffer < Reference < Object
Gray8 is an in-memory image storing Color::Gray8 pixels.
Optimized for grayscale images - uses 1 byte per pixel instead of 4.
Storage format: Raw bytes, one byte per pixel (grayscale value) Memory usage: width × height × 1 byte
Features:
- Direct byte buffer access via
pixmethod - Sub-image support (shares underlying buffer)
- Stride support for flexible memory layouts
Example:
img = Image::Gray8.new(Image.rect(0, 0, 640, 480))
img[10, 20] = Image::Color::Gray8.new(128)
Constructors
new(rect : Rectangle)
SourceInstance methods
Returns the pixel at (x, y), or default value if out of bounds
Sets the pixel at (x, y), no-op if out of bounds