[cc lang=»delphi»]

procedure BuildCopy24to32(_B_in: TBitmap; var _B_out: TBitmap);
const
MaxPixelCountA = MaxInt div sizeof(TRGBQuad);
MaxPixelCount = MaxInt div sizeof(TRGBTriple);
type
PRGBArray = ^TRGBArray;
TRGBArray = array [0 .. MaxPixelCount — 1] of TRGBTriple;
PRGBAArray = ^TRGBAArray;
TRGBAArray = array [0 .. MaxPixelCountA — 1] of TRGBQuad;
var
x, y: Integer;
RowOut: PRGBAArray;
RowIn: PRGBArray;
begin
_B_out.Width := _B_in.Width;
_B_out.Height := _B_in.Height;
for y := 0 to _B_in.Height — 1 do
begin
RowOut := _B_out.ScanLine[y];
RowIn := _B_in.ScanLine[y];
for x := 0 to _B_in.Width — 1 do
begin
RowOut[x].rgbReserved := 255;
RowOut[x].rgbBlue := byte (trunc(RowIn[x].rgbtBlue * RowOut[x].rgbReserved / 255));
RowOut[x].rgbGreen := byte (trunc(RowIn[x].rgbtGreen * RowOut[x].rgbReserved / 255));
RowOut[x].rgbRed := byte (trunc(RowIn[x].rgbtRed * RowOut[x].rgbReserved / 255));
end;
end
end;

пример использования:
ss := TBitmap.Create;

ss.PixelFormat := pf24bit;

si := TBitmap.Create;
si.PixelFormat := pf32bit;

BuildCopy24to32(ss, si);

si.SaveToFile(‘c:/32bit.bmp’);

[/cc]