class

Image::RGBA16

Inherits Image::PixelBuffer < Reference < Object

RGBA16 is an in-memory image storing Color::RGBA16 pixels.

Higher precision version of RGBA8 for professional imaging and HDR. Uses 16 bits per channel (8 bytes per pixel: R, G, B, A).

Storage format: Raw bytes in big-endian, R, G, B, A order (2 bytes each) Memory usage: width × height × 8 bytes

Use cases:

  • Professional photography and image editing
  • HDR (High Dynamic Range) images
  • Reduced banding in gradients
  • Precision for color transformations

Features:

  • Direct byte buffer access via pix method
  • Sub-image support (shares underlying buffer)
  • Stride support for flexible memory layouts

Example:

img = Image::RGBA16.new(Image.rect(0, 0, 640, 480))
img[10, 20] = Image::Color::RGBA16.new(65535, 0, 0, 65535)

Constructors

new(pix : Bytes, stride : Int32, rect : Rectangle)
Source
new(rect : Rectangle)
Source

Instance methods

at(x : Int32, y : Int32) : Color::RGBA16

Returns the pixel at (x, y), or default value if out of bounds

Source
bounds

Returns the rectangular bounds where pixels are defined

Source
pix

Direct access to underlying byte buffer

Source
set(x : Int32, y : Int32, pixel : Color::RGBA16) : Nil

Sets the pixel at (x, y), no-op if out of bounds

Source
stride

Stride in bytes (bytes per row)

Source
sub_image(rect : Rectangle) : RGBA16

Returns a sub-image that shares the same byte buffer

Source
unsafe_at(x : Int32, y : Int32) : Color::RGBA16

Returns the pixel at (x, y) without bounds checking. undefined behavior if out of bounds.

Source