请求指点:让位从中间往两边显示(100分)

  • 主题发起人 主题发起人 daoba_wolf
  • 开始时间 开始时间
D

daoba_wolf

Unregistered / Unconfirmed
GUEST, unregistred user!
那位大哥帮我看看怎么不行?小弟不胜感激。
procedure Tform1.button1click(sender:tobject);
const
step=10000;
var
bitmap:Tbitmap;
x0,y0:integer;
midx,midy:integer;
ratiox,ratioy:real;
fname:string;
I:integer;
begin
bitmap:=Tbitmap.Create;
opendialog1.Execute;
fname:=opendialog1.FileName;
bitmap.LoadFromFile(fname);
ratiox:=bitmap.Width/step;
ratioy:=bitmap.Height/step;
x0:=width div 2;
y0:=0;
for i:=0 to step do
begin

midx:=round(ratiox*i*0.5);
midy:=round(ratioy*i);
bitblt(form1.Canvas.Handle,x0-midx,0,round(ratiox*i*0.5),width,
bitmap.Canvas.Handle,x0-midx,0,srccopy);
bitblt(form1.Canvas.Handle,width div 2,0,round(ratiox*i*0.5),
width,bitmap.Canvas.Handle,width div 2,0,srccopy);
end;
bitmap.free;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
const
step=10000;
var
bitmap:Tbitmap;
x0,y0:integer;
midx,midy:integer;
ratiox,ratioy:real;
fname:string;
I:integer;
begin
bitmap:=Tbitmap.Create;
opendialog1.Execute;
fname:=opendialog1.FileName;
bitmap.LoadFromFile(fname);
ratiox:=bitmap.Width/step;
ratioy:=bitmap.Height/step;
x0:=width div 2;
y0:=0;
for i:=0 to step do
begin
midx:=round(ratiox*i*0.5);
midy:=round(ratioy*i);
bitblt(form1.Canvas.Handle,x0-midx,0,midx,bitmap.Height,bitmap.Canvas.Handle,round((bitmap.Width/2)-midx),0,srccopy);
bitblt(form1.Canvas.Handle,x0+midx,0,midx,bitmap.Height,bitmap.Canvas.Handle,round((bitmap.Width/2)+midx),0,srccopy);
end;
bitmap.free;
end;
 
上面的稍微有点问题,不平衡。
应该更简洁!

procedure TForm1.Button1Click(Sender: TObject);
const
step=100;
var
bitmap:Tbitmap;
x0,midx,i:integer;
ratiox:real;
begin
bitmap:=Tbitmap.Create;
if not(opendialog1.Execute) then exit;
bitmap.LoadFromFile(opendialog1.FileName);
ratiox:=bitmap.Width/step;
x0:=width div 2;
for i:=0 to step do
begin
midx:=round(ratiox*i*0.5);
bitblt(form1.Canvas.Handle,x0-midx,0,2*midx,bitmap.Height,bitmap.Canvas.Handle,round((bitmap.Width/2)-midx),0,srccopy);
end;
bitmap.free;
end;
 
sorry,我还想问一下,我的那个程序,光标操作码用blackness却可以显示只是黑色当然没有图片,
但srccopy为什么不能按那个方式显示呢?
 
多人接受答案了。
 
后退
顶部