Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Paintbox to Bitmap (https://www.delphipraxis.net/87864-paintbox-bitmap.html)

alexwess 6. Mär 2007 14:19


Paintbox to Bitmap
 
hallo zusammen

ich habe eine panintbox, in dessen hintergrund ein TImage liegt (sozusagen Hintergrundbild)

nun zeichne ich in der Paintbox und speichere die erstellte grafik als bitmap ab.

wenn ich mir dieses bild dann anschaue habe ich im hintergrund die grafik des hintergundbildes, was ich aber nicht möchte.

was mache ich falsch?

mfg

alexwess

turboPASCAL 6. Mär 2007 14:39

Re: Paintbox to Bitmap
 
Da sellt sich die Frage, wie speichert du den Inhalt der PaintBox.

alexwess 6. Mär 2007 14:44

Re: Paintbox to Bitmap
 
Bitmap.Canvas.CopyRect(Bounds(0,0,bitmap.Width, Bitmap.Height),
PaintBox1.Canvas, PaintBox1.ClientRect);

Bitmap.SaveToFile('file.bmp');

turboPASCAL 6. Mär 2007 15:13

Re: Paintbox to Bitmap
 
Das liegt daran das die PaintBox transparent ist. Kopiert man nun die "leere" PaintBox
wird alles was sich hinter der PaintBox befindet mit kopiert.

Bevor du die Sache mit CopyRect kopiets blende das Image aus.

Delphi-Quellcode:
  ImageX.Visible := FALSE;

  Bitmap.Canvas.CopyRect(Bounds(0,0,bitmap.Width, Bitmap.Height),
    PaintBox1.Canvas, PaintBox1.ClientRect);

  Bitmap.SaveToFile('file.bmp');
  ImageX.Visible := TRUE;

// Edit: :wall: Ach ja, das klappt nicht da die Paintbox dann gelöscht wird.
Du müsstest also an zu der PaintBox noch ein Bitmap verwenden. Alles was du nun in die PB
zeichnes müsstes du dann auch mit in das Bitmap zeichnen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz