decode16
Decode page page of data at 16 bits a sample, for the files whose low byte matters: depth maps, scientific and medical images, heavily graded photographs. decode keeps 8 bits a channel; this keeps every bit a 16-bit PNG or TIFF stores, including a TIFF palette's 16-bit ColorMap, every bit of a JPEG 2000 component up to 16 bits deep, through its palette, channel definitions and colour space, and every bit of a 12-bit JPEG or a lossless one of 9 to 16 bits, converted at that precision. A JPEG XL image keeps up to 16 bits a sample; a deeper or a float sample is rounded to 16 bits. A JPEG XR image keeps its 16-bit samples, and its linear fixed-point, half and float samples convert to sRGB at 16 bits. The channels are those the file stores once a palette is looked up (gray, gray and alpha, RGB or RGBA), so a gray depth map stays one sample a pixel. Narrower samples replicate up (an 8-bit v becomes v * 257, a 12-bit one v shl 4 or (v shr 8), a 1-bit one 0 or 65535), and every other format decodes as decode does and widens the same way, as RGB, or RGBA when the file declares transparency. KiteBitmap16.toBitmap then gives exactly what decode returns.
page counts from 0, as for decodePage. With applyOrientation the page's orientation tag is honoured, as decode does. colorTarget converts as for decode, at full precision, and cancellationCheck runs as for decode.
Throws
on malformed/truncated input or unknown format
on formats or features recognised but not yet decodable
if page is negative or the file has no such page