encodePng16

fun encodePng16(bitmap: KiteBitmap16, options: PngEncodeOptions = PngEncodeOptions(), metadata: ImageMetadata = ImageMetadata(), cancellationCheck: () -> Unit? = null): ByteArray(source)

Encode bitmap as a PNG of up to 16 bits a sample, keeping every bit decode16 gives, as encodePng with options writes an 8-bit bitmap (#182). Its channels are gray, gray and alpha, RGB or RGBA, as KiteBitmap16 holds them.

With PngColorType.Auto, the file takes the smallest type that decode16 reads back to the same channels and samples: 8 bits where every sample is a multiple of 257 (an 8-bit v widened as v * 257), gray at 1, 2 or 4 bits where every sample is such a widened value, a palette where a picture of 8-bit samples has 256 colours or fewer, and a tRNS colour key in place of an alpha channel where the alpha allows it. A fixed type is written as asked, and decode16 then gives the channels that type has: a gray type gives one channel, or two with a colour key, and a palette three, or four with tRNS.

Throws