淡入淡出

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
我这里有一个淡入淡出的程序,把关键的部分贴上,你自己看吧,希望对你有帮助。
procedure TFormDaisy.ButtonFadeOutClick(Sender: TObject);
VAR
Bitmap : TBitmap;
i : INTEGER;
j : INTEGER;
Row : pRGBTripleArray;
RowBase: pRGBTripleArray;
step : INTEGER;
begin
Bitmap := TBitmap.Create;
TRY
Bitmap.PixelFormat := pf24bit;
Bitmap.Width := ImageRGB.Width;
Bitmap.Height := ImageRGB.Height;
FOR step := 32 DOWNTO 0 DO
BEGIN
FOR j := 0 TO Bitmap.Height-1 DO
BEGIN
RowBase := BitmapBase.Scanline[j];
Row := Bitmap.Scanline[j];
FOR i := 0 TO Bitmap.Width-1 DO
BEGIN // 32 = 2^5
Row.rgbtRed := (step * RowBase.rgbtRed ) SHR 5;
Row.rgbtGreen := (step * RowBase.rgbtGreen) SHR 5;
Row.rgbtBlue := (step * RowBase.rgbtBlue ) SHR 5
END
END;
ImageRGB.Picture.Graphic := Bitmap;
// Use API calls to avoid flicker.
// See VCL Repaint alternative in FadeIn
InvalidateRect(FormDaisy.Handle, NIL {whole window},
FALSE {don't erase background});
RedrawWindow(FormDaisy.Handle, NIL, 0, RDW_UPDATENOW);
END
FINALLY
Bitmap.Free;
END;
end;
 
procedure TFormDaisy.ButtonFadeInClick(Sender: TObject);
VAR
Bitmap : TBitmap;
i : INTEGER;
j : INTEGER;
Row : pRGBTripleArray;
RowBase: pRGBTripleArray;
step : INTEGER;
begin
Bitmap := TBitmap.Create;
TRY
Bitmap.PixelFormat := pf24bit;
Bitmap.Width := ImageRGB.Width;
Bitmap.Height := ImageRGB.Height;
FOR step := 0 TO 32 DO
BEGIN
FOR j := 0 TO Bitmap.Height-1 DO
BEGIN
RowBase := BitmapBase.Scanline[j];
Row := Bitmap.Scanline[j];
FOR i := 0 TO Bitmap.Width-1 DO
BEGIN // 32 = 2^5
Row.rgbtRed := (step * RowBase.rgbtRed ) SHR 5;
Row.rgbtGreen := (step * RowBase.rgbtGreen) SHR 5;
Row.rgbtBlue := (step * RowBase.rgbtBlue ) SHR 5
END
END;
// This is just as effective as the API calls.
// (See API call alternative in FadeOut.)
ImageRGB.Picture.Graphic := Bitmap;
ImageRGB.Repaint
END
FINALLY
Bitmap.Free;
END;
end;
 

Similar threads

I
回复
0
查看
522
import
I
I
回复
0
查看
468
import
I
I
回复
0
查看
440
import
I
I
回复
0
查看
702
import
I
顶部