[fpc-pascal] Drawing bitmap by pixel

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Fri Jan 20 10:52:40 CET 2017

On 2017-01-20 01:50, Ryan Joseph wrote:
> The max color value is 65535. I thought it was 1.0 or 255.

The FPImage implementation supports 16bit color channels (a bit of
future proofing that confuses many). Most programs and images use 8bits
per channel. Each color channel is thus a WORD size, not a BYTE size.

That is why my example program does the following:

      // duplicate the data to fill a WORD size channel
      r := (r shl 8) or r;
      g := (g shl 8) or g;
      b := (b shl 8) or b;

eg: if r was initial $00AC  (by using Random($FF) to populate it), I
then duplicate the initial value to fill the WORD size value, and the
above code will make r = $ACAC. Strictly not 100% correct thing to do,
but seems to work with FPImage.


fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal

My public PGP key:  http://tinyurl.com/graeme-pgp

More information about the fpc-pascal mailing list