procedure TFormMain.FlipBitmapRight(Sender: TObject); var ClickedImage: TImage; begin ClickedImage:=Sender as TImage; Edit1.text:=Files[((Sender as TImage).Tag)]; RotateBitmap90(Clickedimage.Picture.Bitmap); (Sender as TImage).Picture.Bitmap:=ClickedImage.Picture.Bitmap; end; unit PhotoUses; interface uses Windows, Classes, Sysutils, Graphics; function RotateBitmap90 (const bitmap : TBitmap) : TBitmap; implementation function BytesPerScanline(PixelsPerScanline, BitsPerPixel, Alignment: Longint): Longint; begin Dec(Alignment); Result := ((PixelsPerScanline * BitsPerPixel) + Alignment) and not Alignment; Result := Result div 8; end; function RotateBitmap90 (const bitmap : TBitmap) : TBitmap; var x, y : Integer; ps, ps1, pr, pr1 : PRGBTriple; bpss, bpsr : Integer; begin if bitmap.PixelFormat <> pf24Bit then raise Exception.Create ('Invalid pixel format'); result := TBitmap.Create; result.PixelFormat := bitmap.PixelFormat; result.Height := bitmap.Width; result.Width := bitmap.Height; ps1 := bitmap.ScanLine [bitmap.Height - 1]; pr1 := result.ScanLine [0]; bpss := BytesPerScanLine (bitmap.Width, 24, 32); bpsr := BytesPerScanLine (result.Width, 24, 32); for y := 0 to bitmap.Height - 1 do begin ps := PRGBTriple (PChar (ps1) + bpss * y); for x := 0 to Bitmap.Width - 1 do begin pr := PRGBTriple (PChar (pr1) - bpsr * x); Inc (pr, y); pr^ := ps^; Inc (ps) end end; GDIFlush end; end.