![]() |
bmp drehen
Hi Leute,
ich such jetzt schon seit 3h in sämtlichen Foren verzweifelt nach einer Möglichkeit ein Bild mit Delphi7 zu drehen. Ich hab mir viele Postings durchgelesen, aber es hat wirklich nichts funktioniert, weil immer irgendwelche Fehlermeldungen kamen. Ich bin langsam am verzweifeln, das können doch bloß 3 Zeilen Code sein oder nicht? Euer Arukas PS: ich bin totaler Neuling |
Re: bmp drehen
|
Re: bmp drehen
dann bekomm ich folgende Fehlermeldung:
Delphi-Quellcode:
[Error] Unit1.pas(45): Undeclared identifier: 'pRGBArray'
[Error] Unit1.pas(65): Undeclared identifier: 'rotation' [Error] Unit1.pas(66): Missing operator or semicolon [Error] Unit1.pas(66): Undeclared identifier: 'SpinEditThetaDegrees' [Error] Unit1.pas(66): ')' expected but identifier 'Value' found [Error] Unit1.pas(67): Undeclared identifier: 'SpinEditThetaDegreesHundredths' [Error] Unit1.pas(67): Missing operator or semicolon [Error] Unit1.pas(90): ';' expected but 'FOR' found [Error] Unit1.pas(92): Undeclared identifier: 'RowRotated' [Error] Unit1.pas(92): Undeclared identifier: 'BitmapRotated' [Error] Unit1.pas(92): Missing operator or semicolon [Error] Unit1.pas(96): Undeclared identifier: 'this' [Error] Unit1.pas(102): Missing operator or semicolon [Error] Unit1.pas(105): Missing operator or semicolon [Error] Unit1.pas(111): Undeclared identifier: 'vertically' [Error] Unit1.pas(116): Missing operator or semicolon [Error] Unit1.pas(123): '.' expected but 'FOR' found [Error] Unit1.pas(124): Identifier redeclared: 'Finalization' [Error] Unit1.pas(127): Undeclared identifier: 'iPrime' [Error] Unit1.pas(127): Undeclared identifier: 'i' [Error] Unit1.pas(127): Undeclared identifier: 'OldWidth' [Error] Unit1.pas(127): Undeclared identifier: 'iRotationAxis' [Error] Unit1.pas(132): Undeclared identifier: 'readable' [Warning] Unit1.pas(143): Text after final 'END.' - ignored by compiler [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas' |
Re: bmp drehen
welchen code hast du genau genommen?
![]() dort gibt es alles, Erklärung, unten ein Download mit Exe, verbesserte und schnellere Funktionen |
Re: bmp drehen
perfekt danke,
jetzt muss ichs nur noch verstehen^^, danke |
Re: bmp drehen
hi,
ich hab noch mal eine Frage.
Delphi-Quellcode:
Bei dem Code bekomme ich folgende Fehlermeldung:
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Button1: TButton; image: TImage; procedure Button1Click(Sender: TObject); FUNCTION Rotate(CONST BitmapOriginal: TBitmap; CONST iRotationAxis, jRotationAxis: INTEGER; CONST AngleOfRotation: DOUBLE {radians} ): TBitmap; private { Private declarations } public { Public declarations } end; CONST MaxPixelCount = 32768; TYPE TRGBTripleArray = ARRAY[0..MaxPixelCount-1] OF TRGBTriple; pRGBTripleArray = ^TRGBTripleArray; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin rotate(image,12,34,56); end; // "Simple" approach. For pixel (i,j), use "reverse" rotation to find // where the rotated pixel must have been before the rotation. // Don't bother with center of pixel adjustment. // Assumes input BitmapOriginal has PixelFormat = pf24bit. FUNCTION Rotate(CONST BitmapOriginal: TBitmap; CONST iRotationAxis, jRotationAxis: INTEGER; CONST AngleOfRotation: DOUBLE {radians} ): TBitmap; VAR cosTheta : EXTENDED; i : INTEGER; iOriginal : INTEGER; iPrime : INTEGER; j : INTEGER; jOriginal : INTEGER; jPrime : INTEGER; RowOriginal: pRGBTripleArray; RowRotated : pRGBTRipleArray; sinTheta : EXTENDED; BEGIN // The size of BitmapRotated is the same as BitmapOriginal. PixelFormat // must also match since 24-bit GBR triplets are assumed in ScanLine. RESULT := TBitmap.Create; RESULT.Width := BitmapOriginal.Width; RESULT.Height := BitmapOriginal.Height; RESULT.PixelFormat := pf24bit; // Force this // Get SIN and COS in single call from math library sinTheta := SIN(AngleOfRotation); // If no math library, then use this: // sinTheta := SIN(AngleOfRotation); // cosTheta := COS(AngleOfRotation); // Step through each row of rotated image. FOR j := RESULT.Height-1 DOWNTO 0 DO BEGIN RowRotated := RESULT.Scanline[j]; jPrime := j - jRotationAxis; FOR i := RESULT.Width-1 DOWNTO 0 DO BEGIN iPrime := i - iRotationAxis; iOriginal := iRotationAxis + ROUND(iPrime * CosTheta - jPrime * sinTheta); jOriginal := jRotationAxis + ROUND(iPrime * sinTheta + jPrime * cosTheta); // Make sure (iOriginal, jOriginal) is in BitmapOriginal. If not, // assign blue color to corner points. IF (iOriginal >= 0) AND (iOriginal <= BitmapOriginal.Width-1) AND (jOriginal >= 0) AND (jOriginal <= BitmapOriginal.Height-1) THEN BEGIN // Assign pixel from rotated space to current pixel in BitmapRotated RowOriginal := BitmapOriginal.Scanline[jOriginal]; RowRotated[i] := RowOriginal[iOriginal] END ELSE BEGIN RowRotated[i].rgbtBlue := 255; // assign "corner" color RowRotated[i].rgbtGreen := 0; RowRotated[i].rgbtRed := 0 END END END END {RotateBitmapMethod1}; end.
Delphi-Quellcode:
Ich dachte eigentlich, dass ich hier...
[Error] Unit1.pas(40): Incompatible types: 'TBitmap' and 'TImage'
[Error] Unit1.pas(14): Unsatisfied forward or external declaration: 'TForm1.Rotate' [Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
Delphi-Quellcode:
...nur sagen muss, welches Bild ich wie drehen möchte, aber irgendwie scheint das nicht ganz so gut zu funktionieren, wie ich mir das vorgestellt hab.
rotate(image,12,34,56);
. . FUNCTION Rotate(CONST BitmapOriginal: TBitmap; CONST iRotationAxis, jRotationAxis: INTEGER; CONST AngleOfRotation: DOUBLE {radians} ): TBitmap; pls help Euer Arukas |
Re: bmp drehen
unten im code (da du es deklariert hast)
function Form1.rotate ... statt function rotate und image.picture.bitmap (? Glaub ich ) statt image in deinem Form Create |
Re: bmp drehen
irgendwie ist das Drehen von Bildern kompliziert....
Es werden zwar keine Fehler mehr angezeigt, aber das Bild dreht sich nicht :(... |
Re: bmp drehen
rotate ist eine function
Delphi-Quellcode:
Mfg Frank
Var bmp:Tbitmap;
begin //bmp:=tbitmap.create; brauchst du nicht, da es bei rotate das Bitmap erstellt wird bmp:=rotate(....) image.picture.bitmap.assign(bmp); bmp.free; //das free ist wichtig, sonst hast du ein speicherleck |
Re: bmp drehen
Ich hab jetzt alles so geändert wie ich es glaube verstanden zu haben, aber das Bild dreht sich immer noch nicht.
Delphi-Quellcode:
euer arukas
procedure TForm1.Button1Click(Sender: TObject);
begin bmp:=image1.Picture.Bitmap; bmp:=rotate(bmp,67,34,5); image1.picture.bitmap.assign(bmp); bmp.free; //das free ist wichtig, sonst hast du ein speicherleck end; FUNCTION Tform1.rotate(CONST BitmapOriginal: TBitmap; CONST iRotationAxis, jRotationAxis: INTEGER; CONST AngleOfRotation: DOUBLE {radians} ): TBitmap; VAR cosTheta : EXTENDED; i : INTEGER; iOriginal : INTEGER; iPrime : INTEGER; j : INTEGER; jOriginal : INTEGER; jPrime : INTEGER; RowOriginal: pRGBTripleArray; RowRotated : pRGBTRipleArray; sinTheta : EXTENDED; BEGIN RESULT := BitmapOriginal; RESULT.Width := BitmapOriginal.Width; RESULT.Height := BitmapOriginal.Height; RESULT.PixelFormat := pf24bit; cosTheta := COS(AngleOfRotation); FOR j := RESULT.Height-1 DOWNTO 0 DO BEGIN RowRotated := RESULT.Scanline[j]; jPrime := j - jRotationAxis; FOR i := RESULT.Width-1 DOWNTO 0 DO BEGIN iPrime := i - iRotationAxis; iOriginal := iRotationAxis + ROUND(iPrime * CosTheta - jPrime * sinTheta); jOriginal := jRotationAxis + ROUND(iPrime * sinTheta + jPrime * cosTheta); IF (iOriginal >= 0) AND (iOriginal <= BitmapOriginal.Width-1) AND (jOriginal >= 0) AND (jOriginal <= BitmapOriginal.Height-1) THEN BEGIN RowOriginal := BitmapOriginal.Scanline[jOriginal]; RowRotated[i] := RowOriginal[iOriginal] END ELSE BEGIN RowRotated[i].rgbtBlue := 255; RowRotated[i].rgbtGreen := 0; RowRotated[i].rgbtRed := 0; END END END END; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:31 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 by Thomas Breitkreuz