What am I missing in the above example to produce 16bit 565?
pf16bit means that the internal storage is supposed to be 16 bit (but in practice that may not be the case).
The pixels properties are either TFPColor or an index to the palette. So it is not possible to assign the 16 bit encoding. This could be done though with a
TLazIntfImage with proper initialization. Or by having the image writing quantize the RGB channels.
With a 32bit image, which is the default with TBitmap, you can simulate 16 bit by reducing the number of colors you're using and avoiding antialiasing. For this, you would quantize the RGB channels. The generic way for this would be as follows:
maxEncodedRed := 1 shl bitDepth - 1; // with bitDepth = 5, maxEncodedRed = 31
encodedRed := (red16bit * maxEncodedRed + 32767) div 65535;
quantizedRed := (encodedRed * 65535 + (maxEncodedRed shr 1)) div maxEncodedRed;
Which route would you rather take?
Regards