![]() |
Bild um 270° drehen
das ist der quelltext, um ein bild mittels canvas um 90 grad zu drehen,
Code:
procedure BitmapDrehen_90Grad(const Bitmap: TBitmap);
var P: PRGBQuad; //^THelpRGB; x,y,b,h : Integer; RowOut: ^TMyHelp; help: TBitmap; begin Bitmap.PixelFormat := pf32bit; help := TBitmap.Create; try help.PixelFormat := pf32bit; b := bitmap.Height; h := bitmap.Width; help.Width := b; help.height := h; for y := 0 to (h-1) do begin rowOut := help.ScanLine[y]; P := Bitmap.scanline[bitmap.height-1]; inc(p,y); for x := 0 to (b-1) do begin rowout[x] := p^; inc(p,h); end; end; finally bitmap.Assign(help); help.Free; end; end; ich will mein bild aber auch in die andere richtung drehen, also entweder in -90° oder in 270° wie ist das möglich? |
AW: Bild um 270° drehen
Versuch mal etwas mit for x zu machen.
|
AW: Bild um 270° drehen
hab was versucht, programm bricht aber immer zusammen
|
AW: Bild um 270° drehen
Warum?
|
AW: Bild um 270° drehen
![]() eine neuere Unit ist auch enthalten in ![]() |
AW: Bild um 270° drehen
Hallo,
ich habe noch dies Problem,gibt es jemanden mir ein paar tipp zu geben?? |
AW: Bild um 270° drehen
Stell dir ein rechteckiges Bild vor. Such dir in diesem Bild ein Pixel (am besten am Rand) aus.
Dann dreh das Bild in deinem Kopf um 90° nach links schau dir an von wo nach wo dein Pixel wandert (X/Y-Position im Bild). |
AW: Bild um 270° drehen
Zitat:
Delphi-Quellcode:
type TRGBarray = array[0..0] of TRGBQuad;
procedure TFoto.rotate90(const Source:TGraphic ; Target: TBitmap); var P: PRGBQuad; y, x, h, b: integer; Rowout: ^TRGBarray; sourcebmp: TBitmap; begin sourcebmp := TBitmap.Create; try sourcebmp.PixelFormat := pf32bit; sourcebmp.Height := Source.Height; sourcebmp.Width := Source.Width; sourcebmp.Canvas.Draw(0, 0, Source); Target.PixelFormat := pf32bit; b := sourcebmp.Height; h := sourcebmp.Width; Target.Height := h; Target.Width := b; for y := 0 to (h - 1) do begin rowout := Target.ScanLine[y]; p := sourcebmp.ScanLine[sourcebmp.height-1]; inc(p, y); for x := 0 to (b-1) do begin rowout[x] := p^; inc(p, h); end; end; finally sourcebmp.Free; end; end; |
AW: Bild um 270° drehen
Weisst Du wie Deine Methode ein Bild um 90° dreht? Das dürfte Dir die Lösung nämlich deutlich erleichtern... Schlagworte als Denkansatz: Zeilen, Spalten.
Sherlock |
AW: Bild um 270° drehen
Versuch es hiermit mal:
Delphi-Quellcode:
Habe ich hier in der DP gefunden.
procedure RotateBitmap(Degree: Word; Source, Dest: TBitmap);
var Points: array[0..2] of TPoint; Angle: Double; X1, X2, Y1, Y2: integer; begin if Degree <= 360 then begin Angle:= (Degree- Degree div 90* 90)/ 180* pi; X1:= Round(Source.Width* sin(Angle)); X2:= Round(Source.Width* cos(Angle)); Y2:= Round(Source.Height* sin(Angle)); Y1:= Round(Source.Height* cos(Angle)); Case Degree of 0..89, 360: begin Points[1] := Point(X2, 0);//rechts oben Points[0] := Point(0, X1);//links oben Points[2] := Point(Y2, Y1+ X1);//links unten Dest.Width:= X2+ Y2; Dest.Height:= Y1+ X1; end; 90..179: begin Points[1] := Point(0, Y2);//rechts oben Points[0] := Point(X1, Y2+ X2);//links oben Points[2] := Point(X1+ Y1, X2);//links unten Dest.Width:= Y1+ X1; Dest.Height:= X2+ Y2; end; 180..269: begin Points[1] := Point(Y2, X1+ Y1);//rechts oben Points[0] := Point(Y2+ X2, Y1);//links oben Points[2] := Point(X2, 0);//links unten Dest.Width:= X2+ Y2; Dest.Height:= Y1+ X1; end; 270..359: begin Points[1] := Point(X1+ Y1, X2);//rechts oben Points[0] := Point(Y1, 0);//links oben Points[2] := Point(0, Y2);//links unten Dest.Width:= Y1+ X1; Dest.Height:= X2+ Y2; end; end; PlgBlt(Dest.Canvas.Handle, Points, Source.Canvas.Handle, 0, 0, Source.Width, Source.Height, 0, 0, 0); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:13 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz