ну вот тебе идея. ускорить можно если перейти к работе с TBitmap.ScanLine и уйти от TCanvas.Pixels
| Код | program PicDemo;
{$APPTYPE CONSOLE}
uses SysUtils, Graphics, Jpeg;
function TiltPic(Gr: TGraphic; dy: Integer): TBitmap; var d: Double; x, y: Integer; begin Result := TBitmap.Create; try Result.Assign(Gr); Result.Height := Result.Height + dy; d := dy / Gr.Width; for x := 0 to Gr.Width - 1 do begin dy := Round(d * x); for y := Gr.Height - 1 downto 0 do Result.Canvas.Pixels[x, y + dy] := Result.Canvas.Pixels[x, y]; for y := dy - 1 downto 0 do Result.Canvas.Pixels[x, y] := clWhite end except Result.Free; raise end end;
const Src = 'D:\Íîâàÿ ïàïêà\DSC02985.JPG'; Dst = 'D:\out.bmp'; var Pic: TPicture; Bmp: TBitmap; begin try Pic := TPicture.Create; try Pic.LoadFromFile(Src); Bmp := TiltPic(Pic.Graphic, 500); try Bmp.SaveToFile(Dst) finally Bmp.Free end finally Pic.Free end except on E: Exception do writeln(E.ClassName, ' ', E.Message) end; readln end.
|
|