Converting 16-bit Grayscale Values

If you want to use a 16-bit grayscale value in a non LEADTOOLS procedure, you need to convert the value as follows:

Var
color: TColorRef;
gray: Cardinal;

begin
color := Lead1.Pixel[X, Y];
if (color AND COLORREF_GRAY16) <> 0 then
begin
{non standard colorref value, convert it to a windows COLORREF}
{get an 8 bit gray value corresponding to the 16 bit gray value}
gray := (color AND $FFFF) shr 8;
{ use the standard windows RGB macro to get a windows COLORREF }
color := RGB(gray, gray, gray);
end;
end;