Difference between revisions of "Create image from Form/de"

From Free Pascal wiki
Jump to navigationJump to search
m
m
Line 8: Line 8:
 
    
 
    
 
uses
 
uses
   Graphics, Controls, ...
+
   Graphics, Controls, Clipbrd, Forms, ...
 +
 
 +
  ...
 
    
 
    
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 18: Line 20:
  
 
uses
 
uses
   Forms, Graphics, Controls, Clipbrd, ...
+
   Forms, Graphics, Controls, ...
  
 
   ...
 
   ...
Line 43: Line 45:
 
Demonstration, wie z. B. die obige Funktion verwendet werden kann.<br>
 
Demonstration, wie z. B. die obige Funktion verwendet werden kann.<br>
 
<syntaxhighlight>
 
<syntaxhighlight>
 +
 +
  ...
 +
 +
uses
 +
  Clipbrd, ...;
 +
 +
  ...
 +
 
procedure Test;
 
procedure Test;
 
var
 
var
Line 69: Line 79:
  
 
end;
 
end;
 +
 +
  ...
 +
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<br>
 
<br>

Revision as of 07:52, 3 August 2013

Deutsch (de) English (en)


Für die Beispiele werden folgende Units benötigt:

  ...
  
uses
  Graphics, Controls, Clipbrd, Forms, ...

  ...


Die Funktion erstellt vom übergebenen Formular einen Bildschirmausdruck (Screenshot).

  ...

uses
  Forms, Graphics, Controls, ...

  ...

Procedure subErstelleFormularImage(Formular: TForm; out Bitmap: TBitmap);
var
  Breite: Integer;
  Hoehe:  Integer;
  Rechteck: TRect;

begin

  Breite := Formular.Width;
  Hoehe := Formular.Height;
  Rechteck := Rect(0, 0, Breite, Hoehe);

  Bitmap.Width := Breite;
  Bitmap.Height := Hoehe;
  Bitmap.Canvas.CopyRect(Rechteck, Formular.Canvas, Rechteck);

end;


Demonstration, wie z. B. die obige Funktion verwendet werden kann.

  ...

uses
  Clipbrd, ...;

  ...

procedure Test;
var
  Bitmap: TBitMap;

begin

  ...

  // Fordert den Speicher für die Bitmap an
  Bitmap := TBitmap.Create;

  // Ruft die Funktion zum erstellen des Bildschirmausdrucks / Screenshots auf
  subErstelleFormularImage(Form1, Bitmap);

  // Beispiel 1: Weist den Screenschot einem Image zu
  image1.Picture.Assign(Bitmap);

  // Beispiel 2: Weist den Screenschot der Zwischenablage zu
  Clipboard.Assign(Bitmap);

  // Gibt den Speicher der Bitmap frei
  FreeAndNil(Bitmap)

  ...

end;

  ...



--Olaf 07:45, 3 August 2013 (CEST)