Delphi-PRAXiS
Seite 1 von 2  1 2   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Transparent zeichnen (https://www.delphipraxis.net/170566-transparent-zeichnen.html)

Popov 24. Sep 2012 08:50

Transparent zeichnen
 
Ich sehe wieder vor lauter Bäume den Wald nicht mehr. Ich will eine Bitmap transparent zeichnen, etwas was ich seit über 15 Jahren mit Delphi mache und plötzlich weiß ich nicht wieso es nicht klappt.

Delphi-Quellcode:
  with Image1.Picture do
  begin
    Bitmap.Width := 200;
    Bitmap.Height := 200;
    Bitmap.Canvas.FillRect(Bitmap.Canvas.ClipRect);
    Bitmap.Canvas.Ellipse(Bitmap.Canvas.ClipRect);

    Bitmap.Transparent := True;
    Bitmap.TransparentColor := Bitmap.Canvas.Pixels[0, 0];
    Self.Canvas.Draw(0, 0, Bitmap);
  end;

roga 24. Sep 2012 09:10

AW: Transparent zeichnen
 
TransparentBlt

Jonas Shinaniganz 24. Sep 2012 09:19

AW: Transparent zeichnen
 
Wäre möglich, dass dein Bitmap.Canvas.Pixels[0, 0] dieses Mal nicht deine transparente Farbe ist.

Grüße

Popov 24. Sep 2012 09:24

AW: Transparent zeichnen
 
Nun, selbst wenn es diese Funktion gibt (trotzdem danke), hier geht es um die pure TBitmap. Ich habe es in zig Programmen schon genutzt (auch ohne TransparentBlt). Es war so selbstverständlich für mich, dass ich noch nicht mal bewußt darüber nachgedacht habe wie es geht.

@Jonas Shinaniganz

Doch, ist schon.

roga 24. Sep 2012 09:59

AW: Transparent zeichnen
 
Hast Du hier mal geschaut: Bitmap und Transparent

Namenloser 24. Sep 2012 12:56

AW: Transparent zeichnen
 
Könnte es sein, dass die Farbtiefe bzw. das Pixelformat von Quelle und Ziel unterschiedlich ist?

Popov 24. Sep 2012 15:05

AW: Transparent zeichnen
 
Das habe ich mir zuerst auch gedacht und getestet, ist es aber nicht. Außerdem habe ich beide Bitmaps in der Farbtiefe angeglichen.

Sonderbarer weise funktioniert das:
Delphi-Quellcode:
var
  Bitmap: TBitmap;
begin
  Bitmap := TBitmap.Create;
  try
    Bitmap.Width := 200;
    Bitmap.Height := 200;
    Bitmap.Canvas.Ellipse(Bitmap.Canvas.ClipRect);

    Bitmap.Transparent := True;
    Bitmap.TransparentColor := Bitmap.Canvas.Pixels[0, 0];
    Self.Canvas.Draw(0, 0, Bitmap);
  finally
    Bitmap.Free;
  end;
end;

Bummi 24. Sep 2012 16:04

AW: Transparent zeichnen
 
"Dr***s" With
Delphi-Quellcode:
  with Image1.Picture do
  begin
    Bitmap.Width := 200;
    Bitmap.Height := 200;
    Bitmap.Canvas.FillRect(Bitmap.Canvas.ClipRect);
    Bitmap.Canvas.Ellipse(Bitmap.Canvas.ClipRect);

    Bitmap.Transparent := True; // welches Bitmap könnte da jetzt erwischt worden sein

Popov 24. Sep 2012 16:50

AW: Transparent zeichnen
 
Ich weiß von deiner Abneigung gegen With, aber das zweite Beispiel hat nichts mit dem ersten zu tun. Das sind zwei unabhängige Beispiele. In der Praxis benutze ich auch nie die Variablenbezeichnung Bitmap. Die Bezeichnung hat sich hier nur zufällig so ergeben.

Wenn du jedoch etwas anderes meinst, dann habe ich es nicht erkannt.

EWeiss 24. Sep 2012 17:33

AW: Transparent zeichnen
 
Welches Pixel willst du aufnehmen wenn Transparent := True?
Sollte das nicht vorher aufgenommen werden ? Bevor du Transparent = true setzt


Delphi-Quellcode:
Bitmap.TransparentColor := Bitmap.Canvas.Pixels[0, 0];
Bitmap.Transparent := True;
gruss


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:57 Uhr.
Seite 1 von 2  1 2   

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