你看一下这个程序,其中image2,image3 装入两个不同的.bmp图片
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
udtblender:TBlendFunction;
begin
with udtblender do
begin
Blendop:=AC_SRC_OVER;
Blendflag:=0;
SourceConstantAlpha:=x;
AlphaFormat=0;
end;
image1.Canvas.Draw(0,0,image2.Picture.Graphic);
AlphaBlend(image1.Canvas.Handle,0,0,image1.Width,image1.Height,
image3.Canvas.Handle,0,0,image3.Width,image3.Height,
udtblender);
end;end.来分吧!
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var
udtblender:TBlendFunction;
begin
with udtblender do
begin
Blendop:=AC_SRC_OVER;
Blendflag:=0;
SourceConstantAlpha:=x;
AlphaFormat=0;
end;
image1.Canvas.Draw(0,0,image2.Picture.Graphic);
AlphaBlend(image1.Canvas.Handle,0,0,image1.Width,image1.Height,
image3.Canvas.Handle,0,0,image3.Width,image3.Height,
udtblender);
end;end.来分吧!
解决方案 »
- 恭喜SuperTitan001升级
- 真的是令人發指啊................................................
- 用delphi来写一个推断题
- 怎样用execSQL保存日期字段,谢谢 本人刚学用Delphi改写程序,请路过的前辈帮下忙.
- for语句遇到的一个问题?
- 用DELPHI的组件做的游览器,能够拦截所载入页面中的js函数吗?
- 高手请进
- ComboBOX
- 怎样用NMFTP象网络蚂蚁那样自动获得下载文件的地址
- Delphi 如何从lookupcombobox中取值后怎样赋值给SQL中的名称然后提取其值赋值给LABEL
- (急!!!)为什么在DELPHI6.0中的ADO不能正常使用ORCALE的数据库?
- 很奇怪的问题?
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R .DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
x,y,i:integer;
Bitmap:TBitmap;
pixcolo:PByteArray;
begin
Bitmap:=TBitmap.Create;
//创建TBitMap实例
try
Bitmap.LoadFromFile
('c:\windows\clouds.bmp');
Bitmap.PixelFormat:=pf24bit;
for i:=0 to 255 do
begin
for y:=0 to Bitmap.Height-1 do
begin
pixcolo:=Bitmap.Scanline[y];
//扫描每行像素颜色
for x:=0 to ((Bitmap.Width3)-1) do
if pixcolo[x]>0 then pixcolo[x]:=(pixcolo[x]-1);
//递减颜色值,不同的递减值可改变不同的速度
end;
Image1.Canvas.Draw(0,0,Bitmap);
//画出图像
Application.ProcessMessages;
//系统做其他工作
end;
finally
Bitmap.free; //释放位图
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
x,y,i,j:integer;
Bitmap1,Bitmap2:TBitmap;
pixcolo1,pixcolo2:PByteArray;
begin
Bitmap1:=TBitmap.Create;
Bitmap2:=TBitmap.Create;
try
Bitmap1.LoadFromFile('c:\windows\clouds.bmp');
//将同一幅图像装入两个TBitmap实例
Bitmap2.LoadFromFile('c:\windows\clouds.bmp');
Bitmap1.pixelFormat:=pf24bit;
Bitmap2.pixelFormat:=pf24bit;
for y:=0 to Bitmap2.height-1 do
begin
pixcolo2:=Bitmap2.Scanline[y];
for x:=0 to ((Bitmap2.Width3)-1) do
pixcolo2[x]:=0;
//先将要处理的图像的像素颜色值设为0
end;
for i:=0 to 255 do
begin
for y:=0 to Bitmap2.Height-1 do
begin
pixcolo2:=Bitmap2.Scanline[y];
pixcolo1:=Bitmap1.Scanline[y];
for x:=0 to ((Bitmap2.Width3)-1) do if pixcolo2[x]<pixcolo1[x] then pixcolo2[x]:=(pixcolo2[x]+1);
end;
//与原始图的像素颜色值比较,并递增其值直到与原始图相等
Image1.Canvas.Draw(0,0,Bitmap2);
Application.ProcessMessages;
end;
finally
Bitmap1.free
end;
end;
end.如果是非Bitmap格式要先转化为BMP格式!
(a*X(1)+(100-a)*X(2))/100
picshow挺好
Button2.Enabled := False;procedure TForm1.Button1Click(Sender: TObject); //淡入效果
var
BlendFunction: TBlendFunction;
bCount: byte;
Src: TBitmap;
begin
Button1.Enabled := Button2.Enabled;
Src := TBitmap.Create; try
Src.PixelFormat := pf32bit;
Src.LoadFromFile('KOF.BMP');
with BlendFunction do
begin
BlendOp := AC_SRC_OVER;
BlendFlags := 0;
AlphaFormat := 0;
end; for bCount := 1 to 50 do
begin
BlendFunction.SourceConstantAlpha := bcount * 5;
Windows.AlphaBlend(form1.Canvas.Handle, 0, 0, Src.Width, Src.Height,
Src.Canvas.Handle, 0, 0, Src.Width, Src.Height,
BlendFunction);
sleep(30);
end;
finally
Src.Free;
end;
Button2.Enabled := not Button1.Enabled;
end;procedure TForm1.Button2Click(Sender: TObject); //淡出效果
var
BlendFunction: TBlendFunction;
bCount: byte;
Src: TBitmap;
begin
Button2.Enabled := Button1.Enabled;
Src := TBitmap.Create; try
Src.PixelFormat := pf32bit;
Src.LoadFromFile('KOF.BMP');
with BlendFunction do
begin
BlendOp := AC_SRC_OVER;
BlendFlags := 0;
AlphaFormat := 0;
end; for bCount := 1 to 50 do
begin
BlendFunction.SourceConstantAlpha := bcount * 5;
Windows.AlphaBlend(form1.Canvas.Handle, 0, 0, Src.Width, Src.Height,
form1.Canvas.Handle, 150, 150, Src.Width, Src.Height,
BlendFunction);
sleep(30);
end;
finally
Src.Free;
end;
Button1.Enabled := not Button2.Enabled;
end;Win2000 + Delphi6 测试通过