class

Image::NRGBA16

Inherits Image::PixelBuffer < Reference < Object

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

Non-premultiplied alpha version of RGBA16. Higher precision with independent alpha. 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 color editing with high precision
  • HDR images with independent alpha channel
  • Interchange format for high-bit-depth workflows

Features:

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

Example:

img = Image::NRGBA16.new(Image.rect(0, 0, 640, 480))
img[10, 20] = Image::Color::NRGBA16.new(65535, 0, 0, 32768) # 50% transparent red

Constructors

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

Instance methods

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

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::NRGBA16) : 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) : NRGBA16

Returns a sub-image that shares the same byte buffer

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

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

Source