bitblt函数(20分)

  • 主题发起人 主题发起人 true_feiyun
  • 开始时间 开始时间
T

true_feiyun

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何让一副位图实现从四周向中心显示的视觉特效(用bitblt函数),谢谢!
 
这样的问题完全可以自已编,偷什么懒呢?
 
这是copyrect地版本,bitblt自己改一下(不同函数而已)
如果这个还不满意,那我没法子了!动手改改吧!
procedure TMainForm.run2centerClick(Sender: TObject);
var
newbmp: TBitmap;
i, bmpheight, bmpwidth: integer;
ratio: real;
Rect1, Rect2, Rect3, Rect4: Trect;
begin
childForm.DoubleBuffered := true;
newbmp := TBitmap.Create;
newbmp.Width := childForm.image1.Width;
newbmp.Height := childForm.image1.Height;
bmpheight := childForm.image1.Picture.Graphic.Height;
bmpwidth := childForm.image1.Picture.Graphic.Width;
if bmpheight < bmpwidth - 1 then
begin
ratio := bmpwidth / bmpheight;
for i := 0 to round(bmpheight / 2) + 1 do { TODO : &amp;Euml;&amp;Auml;&amp;iquest;é&amp;Iacute;&amp;not;&amp;Ecirc;±&amp;iquest;&amp;frac12;±&amp;acute; }
begin
application.ProcessMessages;
Rect1 := Rect(0, 0, bmpwidth, i);
Rect2 := Rect(0, bmpheight - i, bmpwidth, bmpheight);
Rect3 := Rect(0, 0, trunc(i * ratio), bmpheight);
Rect4 := Rect(bmpwidth - Trunc(i * ratio), 0, bmpwidth, bmpheight);
newbmp.Canvas.CopyRect(Rect1, childForm.Image1.Canvas, Rect1);
newbmp.Canvas.CopyRect(Rect2, childForm.Image1.Canvas, Rect2);
newbmp.Canvas.CopyRect(Rect3, childForm.Image1.Canvas, Rect3);
newbmp.Canvas.CopyRect(Rect4, childForm.Image1.Canvas, Rect4);
childForm.Canvas.Draw(0, 0, newbmp);

end;

newbmp.Free;
end;
if bmpheight > bmpwidth then { TODO : &amp;Icirc;&amp;raquo;&amp;Iacute;&amp;frac14;&amp;cedil;&amp;szlig;&amp;acute;ó&amp;Oacute;&amp;Uacute;&amp;iquest;í&amp;Ecirc;± }
begin
ratio := bmpheight / bmpwidth;
for i := 0 to trunc(bmpwidth / 2) + 1 do
begin
Rect1 := Rect(0, 0, bmpwidth, trunc(i * ratio));
Rect2 := Rect(0, bmpheight - trunc(i * ratio), bmpwidth, bmpheight);
Rect3 := Rect(0, 0, i, bmpheight);
Rect4 := Rect(bmpwidth - i, 0, bmpwidth, bmpheight);
newbmp.Canvas.CopyRect(Rect1, childForm.Image1.Canvas, Rect1);
newbmp.Canvas.CopyRect(Rect2, childForm.Image1.Canvas, Rect2);
newbmp.Canvas.CopyRect(Rect3, childForm.Image1.Canvas, Rect3);
newbmp.Canvas.CopyRect(Rect4, childForm.Image1.Canvas, Rect4);
childForm.Canvas.Draw(0, 0, newbmp);

end;
newbmp.Free;
end;

end;
 
很多图象显示特效的原理都是一样的,无非在循环中计算出每步的像素位置,然后将其从后台
拷贝至前台显示
 
接受答案了.
 

Similar threads

后退
顶部