首页 | 社区 | 博客 | 招聘 | 文章 | 新闻 | 下载 | 读书 | 代码
亲,您未登录哦! 登录 | 注册

TImage.Bitmap的渐隐

打印文章

分享到:
{ 添加Timage并载入一幅24位或32位bitmap ;
添加TButton 并在OnClick 事件下加入下面代码}
procedure TForm1.Button1Click(Sender: TObject);
procedure FadeOut(const BMP:TImage; Pause:integer);
var
BytesPorScan: integer;
w,h: integer;
p: pByteArray;
counter: integer;
begin
{ 仅在24 位或32位色下有效}

If Not (BMP.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit])
then raise exception.create(''Error, bitmap format not supported.'');

try
BytesPorScan := Abs ( Integer(BMP.Picture.Bitmap.ScanLine[1])-
Integer(BMP.Picture.Bitmap.ScanLine[0]));
except
raise exception.create(''Error'');
end;

{ 减小每个像素的RGB值}
for counter := 1 to 256 do
begin
for h := 0 to BMP.Picture.Bitmap.Height - 1 do
begin
P := BMP.Picture.Bitmap.ScanLine[h];
for w := 0 to BytesPorScan - 1 do
if P^[w] >0 then P^[w] := P^[w]-1;
end;
Sleep(Pause);
BMP.Refresh;
end;
end; {procedure FadeOut}

begin
FadeOut(Image1, 5);
end;

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )

编程爱好者论坛

本栏最新文章