一个关于图象镜像的问题!请高手帮忙!不胜感激!(0分)

  • 主题发起人 主题发起人 feifan
  • 开始时间 开始时间
F

feifan

Unregistered / Unconfirmed
GUEST, unregistred user!
有一段代码:
var
ii : integer;
b,btmp : Tbitmap;
begin
B := TBitmap.Create;
B.Width := 800;
B.Height := 640;
btmp := TBitmap.Create;
btmp.Width := 800;
btmp.Height := 640;
b.Canvas.TextOut(10,10,'You are Great! I think you will succeed!');
for ii := 0 to B.Width do
BitBlt(btmp.Canvas.Handle,ii,0,1,B.Height,b.Canvas.Handle,b.Width - ii -1,0,srccopy);
Canvas.Draw(0,0,btmp);
end;
这端代码实现了图象的镜像,但是速度有点慢?有没有更快的方法,请高手明示!
 
回答加分!
100分,决不食言
 
给你一个函数:不仅可以左右镜象,还可以上下
FUNCTION FlipReverseCopyRect(Const Flip, Reverse:Boolean;Const Bitmap:TBitmap):TBitmap;
Var
Bottom: integer;
Left : integer;
Right : integer;
Top : integer;
begin
Result := TBitmap.Create;
Result.Width := Bitmap.Width;
Result.Height := Bitmap.Height;
Result.PixelFormat := Bitmap.PixelFormat;
// Flip Top to Bottom
if Flip
then begin
// Unclear why extra "-1" is needed here.
Top := Bitmap.Height-1;
Bottom := -1
end
else begin
Top := 0;
Bottom := Bitmap.Height
end;
// Reverse Left to Right
if Reverse
then begin
// Unclear why extra "-1" is needed here.
Left := Bitmap.Width-1;
Right := -1;
end
else begin
Left := 0;
Right := Bitmap.Width;
end;
Result.Canvas.CopyRect(Rect(Left,Top, Right,Bottom),
Bitmap.Canvas,
Rect(0,0, Bitmap.Width,Bitmap.Height));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Image2.Picture.Graphic:=FlipReverseCopyRect(False,True,Image1.Picture.Bitmap);
end;
还可以用ScanLine(较慢),StretchBlt方法
 
兄弟,太给面子了,这100分一定给你加上!
 
后退
顶部