Image::Gray16
Inherits Image::PixelBuffer < Reference < Object
Gray16 is an in-memory image storing Color::Gray16 pixels.
Higher precision version of Gray8 for scientific imaging and smooth gradients. Uses 16 bits per pixel (2 bytes).
Storage format: Raw bytes in big-endian (2 bytes per pixel) Memory usage: width × height × 2 bytes
Use cases:
- Medical imaging (X-rays, MRI scans)
- Scientific visualization
- Astronomy images
- Smooth gradients without banding
Features:
- Direct byte buffer access via
pixmethod - Sub-image support (shares underlying buffer)
- Stride support for flexible memory layouts
Example:
img = Image::Gray16.new(Image.rect(0, 0, 640, 480))
img[10, 20] = Image::Color::Gray16.new(32768)
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