怎样使图像渐渐消失?(100分)

  • 主题发起人 主题发起人 ngl
  • 开始时间 开始时间
N

ngl

Unregistered / Unconfirmed
GUEST, unregistred user!
(1).怎样使图像渐渐消失(出现)?
(2).怎样使窗体渐渐消失(出现)?
 
如果背景是纯色,可以用随机算法填充
 
Form Container 1.5 
http://www.chinaasp.com/delphi/component/recHits.asp?id=519&url=http%3A%2F%2Fwww%2Echinaasp%2Ecom%2Fchinaaspdownload%2Fdelphi%2FForm%2EContainer%2E1%2E5%2FFormCont%2Ev1%2E5%2Ezip
看里边的DEMO你就能HIGH一下
 
找控件吧,多的是。例如FX等,找到控件看原码。
 
Form Container 已经有2.1了
http://www.billeniumsoft.com/trial/be21d5t.exe
 
使用 Windows 的调色板技术. 我这里有 Delphi 的源代码, 可以实现图像的淡入淡出.
 
I want it .
Please delphi@email.com.cn
thankx
 
I want to get it.
pls <a herf=mailto:dxhsir@263.net>Mail me</a>
 
我也来一个:balaschen@163.net
 
我也来一个。delphijoe@163.net
 
大家何苦呐?老是要排大队。。
*******************
unit Bmp-Disaper;?
interface?
uses SysUtils,WinTypes,WinProcs,Messages,Classes,Graphics,Controls,Forms,
Dialogs,ExtCtrls,StdCtrls;?
type?
TForm1=class(TForm)?
Image1:TImage;{显示渐隐图像}?
Timer1:TTimer;{时钟构件}?
Panel1:TPanel;{显示渐隐过程,已渐隐为背景色的颜色数}?
Button1:TButton;{开始渐隐按钮}?
procedure Timer1 Timer(Sender:TObject);{始终控制过程}?
procedure Button1 Click (Sender:TObject);{激发渐隐过程}?
procedure FormCreate (Sender:TObject);{窗体构造过程}?
private?
PalDevice:Imteger;{调色板模式标志}?
go:integer;{渐隐开始标志}?
pal:arrar[0...255] of TPaletteEntry;{逻辑调色板}?
end;??
var?
Form1:TForm1;
implementation?
{$R *.DFM}??
procedure TForm1.Timer1Timer(Sender:TObject);?
var i,n:integer;?
begin?
if go=1 then{开始渐隐} begin?
for i:=0 to 255 do{调色板颜色值递减} begin?
pal[i].peFlags:=PC?-RESERVED;{调色板动画标志,一定得这样设置}?
if pal[i].peRed>0 then
pal[i].peRed:=pal[i].peRed-1;?
if pal[i].peGreen>0 then
pal[i].peGreen:=pal[i].peGreen-1;?
if pal[i].peBlue>0 then
pal[i].peBlue:=pal[i].peBlue-1;〖ZK)〗?
end;??
SetPaletteEntries(Image1.Picture.Bitmap.Palette,0,256,pal);{设置新的颜色
到DIB调色板}?
RealizePalette(Image1.Picture.Bitmap.Canvas.Handle);{影射逻辑调色板到系
统硬件调色板}?
{计算已经渐隐消失的颜色数,如全数完成则终止渐隐过程,令go=0}?
n:=0;?
for i:=0 to 255 do
if(pal[i].peRed=0) and (pal[i].peGreen=0) and (pal[i].peBlue=0) then
n:=n+1;
if n=256 then begin
Panel1.Caption:='OK';?
go:=0;
end else
Panel1.Caption:='n='+IntToStr(n);?
end;?
end;
procedure TForm1.Button1Click(Sender:TObject);?
begin?
GetPaletteEntries(Image1.Pictrue.Bitmap.Palette,0,256,pal);{获得DIB图像的调
色板}?
{判断系统是否是基于调色板的显示模式,如果是则开始渐隐过程}
PalDevice:=GetDeviceCaps(Canvas.Handle,RASTERCAPS) and RC?-PALETTE;?
if(PalDevice>0) the go:=1;?
end;?
procedure TForm1.FormCreate(Sender:TObject);?
begin?
Image1.Pictrue.Bitmap.LoadFromFile('c:\video10\ts.bmp');{加载DIB图像}?
end;?
end.
 

发个例子给你,去出吧。

我在此基础上改一改,用多线程控制,可以获得任意淡化的图。
 
Form的显示可以用AnimateWindow函数,加在ONCREATE 时间里面。这个函数的很好
用的说
 
图象的渐渐消失(出现) :
{ Put a TImage and load a bitmap of 24 bits
or 32 bits; put a TButton and put this
code in its OnClick event }

procedure TForm1.Button1Click(Sender: TObject);
procedure FadeOut(const BMP:TImage; Pause:integer);
var
BytesPorScan: integer;
w,h: integer;
p: pByteArray;
counter: integer;
begin
{ This only works with 24 or 32 bits bitmaps }

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;

{ Decrease the RGB components of each single pixel }
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;
窗体渐渐消失(出现) :
AnimateWindow(Handle,1000,AW_CENTER);//在窗体创建事件中
 
哇,你小子酷毕啦,不就是淡入淡出吗,原理是把图象的像素颜色值
相应减少到0和增加到255就可以达到这种效果,书上的例子不知道有多少,还在这里问
,这样的好人难找呀
 
看来蛋糕是吃不上了,问问味吧!
 
多人接受答案了。
 
后退
顶部