Einzelnen Beitrag anzeigen

Benutzerbild von alphaflight83
alphaflight83

Registriert seit: 5. Jun 2008
Ort: Würzburg
147 Beiträge
 
Delphi 10.4 Sydney
 
#9

AW: Performanceproblem: Anzeige von Positionen mehrerer Clients

  Alt 11. Feb 2011, 09:52
So, ich glaube ich habe nun das Ergebnis, das ich haben wollte.

Zunächst mal hab ich einen Zwischenschritt beim Zeichnen weggelassen der keinen Sinn machte
und zeichne nun alles auf EIN Offscreenbitmap.

Mit GDIPlus hab ich nun auch bei den rotierten Images ein zufriedenstellendes Ergebnis erzielt.

Anmerkungen:
Der Beispiel-Code verwendet kein Offscreenbitmap.
Die Bilsen GDIPlus Implementation verwendet Objekt-Interfaces.

Delphi-Quellcode:
uses GDIPlus;

procedure TFormDrawThis.DrawImages;
var
  Graphics: IGPGraphics;
  Image: IGPImage;
  Matrix: IGPMatrix;
  imgWidth, imgHeight : Integer;
  Angle : Single;
begin
  (* Lock the canvas *)
  Canvas.Lock;

  (* Get the dimensions of the bitmap *)
  imgWidth := Image.GetWidth;
  imgHeight := Image.GetHeight;
   
  (* Create the GDIPlus components *)
  Graphics := TGPGraphics.Create(Canvas.Handle);
  Image := TGPImage.Create(sImage_Path + 'AwesomeImage.png', TRUE);
  (* Create the transformation matrix *)
  Matrix := TGPMatrix.Create;

  (* Set the transformation *)
  Angle := 30.0;
  Matrix.Translate(150, 100);
  Matrix.RotateAt(Angle, TGPPointF.Create(150, 100), MatrixOrderAppend);
  Graphics.SetTransform(Matrix);

  (* Draw the image according to the transformation translated to it's center *)
  Graphics.DrawImage(Image,-imgWidth*0.5,-imgHeight*0.5, imgWidth, imgHeight);

  (* Reset the transformation in the matrix and the graphics *)
  Graphics.ResetTransform;
  Matrix.Reset;

  (* Set the new transformation *)
  Angle := 120.0;
  Matrix.Translate(100, 150);
  Matrix.RotateAt(Angle, TGPPointF.Create(100, 150), MatrixOrderAppend);
  Graphics.SetTransform(Matrix);

  (* Draw the next image according to the transformation translated to it's center *)
  Graphics.DrawImage(Image,-imgWidth*0.5,-imgHeight*0.5, imgWidth, imgHeight);

  (* Reset the transformation in the matrix and the graphics *)
  Graphics.ResetTransform;
  Matrix.Reset;
   
  (* aso *)

  (* Flush all the stuff to the canvas *)
  Graphics.Flush();
end;
Falls jemand eine einfachere Möglichkeit kennt, immer her damit

Gruß, alphaflight83
Make me a sandwich! - What? Make it yourself. - Sudo make me a sandwich! - Okay

Geändert von alphaflight83 (11. Feb 2011 um 10:09 Uhr) Grund: Anmerkungen
  Mit Zitat antworten Zitat