Image::NRGBA8
Inherits Image::PixelBuffer < Reference < Object
NRGBA8 is an in-memory image storing Color::NRGBA8 pixels.
Non-premultiplied alpha version of RGBA8. RGB values are independent of alpha. Easier for color manipulation but less efficient for compositing than RGBA8.
Storage format: Raw bytes in R, G, B, A order Memory usage: width × height × 4 bytes
Use cases:
- Color editing (adjust RGB without affecting transparency)
- Image formats that store non-premultiplied data (PNG)
- Interchange format between different alpha conventions
Features:
- Direct byte buffer access via
pixmethod - Sub-image support (shares underlying buffer)
- Stride support for flexible memory layouts
Example:
img = Image::NRGBA8.new(Image.rect(0, 0, 640, 480))
img[10, 20] = Image::Color::NRGBA8.new(255, 0, 0, 128) # 50% transparent red
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