Hmm.
Well, understanding that I'm writing this off the top of my head (ie: could be complete bs ... but I don't think it is
) this is how I'd do it:
var
R,G,B: Byte;
Src,Dst: Integer;
begin
R := (Src shr 3) and $1F;
G := (Src shr 11) and $1F;
B := (Src shr 19) and $1F;
Dst := (R) or (G shl 5) or (B shl 10);
end;
Takes a 24-bit value in Src, puts a 16-bit value in Dst.
How? Well, first of all extract the colour components R/G/B from the source. Not hard if you know anything about pixel layouts. However: Instead of extracting the top 8 bits, we shift 3 bits more than normal (3/11/19 instead of 0/8/16) and extract 5 bits ($1F = 11111 in binary) into each colour component.
So, now we've got a 5 bit value in each component. Now we just recombine them into a single 16 (well, 15 bit really) bit value by the standard shift, or methods for combining components.
I emphasise: NOT TESTED! May be wrong! But it should give you the basic idea...
[edited] 68 2001-10-16 22:46