32位实际上是加上一个对齐字节的8:8:8的24位色,16位色是5:6:5的颜色 简单来说就是对应颜色位上把 $FF(8位)和 $1F(5位)、$3F(6位)之间的转换,也就是 r、b * $FF div $1F 和 g * $FF div $3F 对应转换再拼一起就可以了
我按照你给的方法转换出来的颜色不对呢. R := (Color shl 11) and $1F; G := (Color shl 5) and $3F; B := Color and $1F; R := R * $FF div $1F; B := B * $FF div $1F; G := G * $FF div $3F; OutPx^ := (B + (G shl 8) + (R shl 16));
Source\Vcl\Graphics.pas
也许对你有帮助
(它有TBitMap class的源码)
简单来说就是对应颜色位上把 $FF(8位)和 $1F(5位)、$3F(6位)之间的转换,也就是 r、b * $FF div $1F 和 g * $FF div $3F 对应转换再拼一起就可以了
G := (Color shl 5) and $3F;
B := Color and $1F; R := R * $FF div $1F;
B := B * $FF div $1F;
G := G * $FF div $3F; OutPx^ := (B + (G shl 8) + (R shl 16));