Mega Code Archive

 
Categories / Delphi / Graphic
 

Rotate an image by 90

Title: Rotate an image by 90 Question: I'm always needing to rotate an image but can't be bothered to write lengthy code to manipulate and capture bitmaps and their scanlines. Answer: You have to create two images first. I'm sure anyone could convert this code to use just on image by using a TBitmap. Procedure TurnImage(Src, Dst: TImage); var x,y: integer; begin Dst.Width:= Src.Height; Dst.Height:= Src.Width; For x:= 0 to Src.Width-1 do begin For y:= 0 to Src.Height-1 do begin Dst.Canvas.Pixels[(Src.Height-1)-y,x]:= Src.Canvas.Pixels[x,y]; end; end; end;