toRgbaBytes

Assemble a Kind.RAW image's already-inflated samples into a flat RGBA8888 buffer (R,G,B,A per pixel, row-major, no padding) that a platform backend can wrap in a bitmap.

Handles the cases that cover the overwhelming majority of real-world images:

  • 8-bit DeviceRGB / DeviceGray / DeviceCMYK

  • 1-bit DeviceGray (bitmask / scanned images)

  • unknown colour spaces (ICCBased, CalRGB…) at 8-bit: component count is inferred from the buffer size (1/3/4 → Gray/RGB/CMYK)

Returns null for things we can't assemble yet (Indexed needs the palette, 16-bit, exotic component counts) → the caller paints a placeholder.