Newsgroups: borland.public.delphi.graphics Subject: Flip a bitmap (One way to do it). From: None@Noware.non (Johnnie) User-Agent: Xnews/4.01.30 NNTP-Posting-Host: 195.97.25.2 Message-ID: <3c62c92a_2@dnews> Date: 7 Feb 2002 10:36:26 -0800 X-Trace: dnews 1013106986 195.97.25.2 (7 Feb 2002 10:36:26 -0800) Lines: 57 Path: dnews Xref: dnews borland.public.delphi.graphics:45998 Hi all, Playing around with the Windows API I created this general procedure to flip an image either horizontally, vertically or both at once. Interface Uses Graphics; Type TMirror = (MT_Horizontal,MT_Vertical,MT_Both); Procedure Flip(MirrorType:TMirror;BMp:Graphics.TBitmap); implementation {$R *.dfm} Procedure Flip(MirrorType:TMirror;BMP:Graphics.TBitMap); Var Dest :TRect; begin if assigned(BMP) then Case MirrorType of MT_Horizontal : begin Dest.Left := RotateBmp.Width; Dest.Top := 0; Dest.Right := - RotateBmp.Width; Dest.Bottom := RotateBmp.Height; end; MT_Vertical : Begin Dest.Left := 0; Dest.Top := RotateBmp.Height; Dest.Right := RotateBmp.Width; Dest.Bottom := - RotateBmp.Height; end; MT_Both : begin Dest.Left := RotateBmp.Width; Dest.Top := RotateBmp.Height; Dest.Right := -RotateBmp.Width; Dest.Bottom := - RotateBmp.Height; end; end; stretchblt(BMP.Canvas.Handle,Dest.Left,DEst.Top,Dest.Right,Dest.Bottom, BMP.Canvas.Handle,0,0,MemBmp.Width,membmp.Height,SRCCOPY); end; end; It is fast enough and it can be used in any type of image (PF8bit,pf24bit,pf4bit etc). Have Fun. Regards Johnnie.