3rd
Июн

Как сделать плавный переход между картинками?

Posted by Chas under Пост-обзор

Здравствуйте, у меня на форме есть кнопки, при щелчке на которые в image должна грузиться определенная картинка. Как можно добиться плавного перехода между последующими картинками?

ZuBy:

procedure TZMSButton.Morphing(Bm1, Bm2: TBitmap; Progress: Integer);
var
dstPixel, srcPixel: PRGBQuad;
Weight: Integer;
I: Integer;
begin
if (Assigned(Bm1) and Assigned(Bm2)) then
begin
Bm1.PixelFormat := pf32bit;
Bm2.PixelFormat := pf32bit;
srcPixel := Bm2.ScanLine[Bm2.Height - 1];
dstPixel := Bm1.ScanLine[Bm1.Height - 1];
Progress := 100 - Progress;
Weight := MulDiv(256, Progress, 100);
for I := (Bm1.Width * Bm1.Height) - 1 downto 0 do
begin
with dstPixel^ do
begin
Inc(rgbRed, (Weight * (srcPixel^.rgbRed - rgbRed)) shr 8);
Inc(rgbGreen, (Weight * (srcPixel^.rgbGreen - rgbGreen)) shr 8);
Inc(rgbBlue, (Weight * (srcPixel^.rgbBlue - rgbBlue)) shr 8);
end;
Inc(srcPixel);
Inc(dstPixel);
end;
end;
end;

тема на форуме

Похожие статьи