Einzelnen Beitrag anzeigen

Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#5

Re: Eigene Brush-Styles mit Transparenz

  Alt 5. Jun 2007, 11:11
...konnte man an dem schnipsel nicht sehen. vielleicht hast du da ja irgendwas anderes im scope...

kann es sein, dass bitmap.transparent eine reine VCL-Sache ist und BitBlt nicht die bohne interessiert?

Außerdem:

- warum nennst du eine VCL-TBitmap-Instanz hBitmap?
- wo lädst du das muster in das bitmap? (oder verlässt du dich darauf, dass das bitmaap gefälligst komplett weiß ist?)

EDIT: Ah ja, I see.

Der in dem Thread vorgeschlagene lösungsweg ist folgender:

- Muster (mit entsprechendem $keyColor) in $tempBitmap malen
- $tempBitmap.Transparent := true, $tempBitmap.TransparentColor := $keyColor
- $tempBitmap aufs $this.Canvas malen

Hmm. Dann machst du das alles ganz ordentlich.

Aber pack doch mal das Rectangle über die transparenz-zuweisungen.

So zum Beispiel:

Delphi-Quellcode:
  //temp-bitmap initialisieren
  hBitmap := Graphics.TBitmap.Create;
  hBitmap.Width := Width;
  hBitmap.Height := Height;
  hBitmap.Canvas.Brush.Style := BrushStyle;
  hBitmap.Canvas.Brush.Color := BrushColor;
  hBitmap.Canvas.Pen.Style := psClear;
  if (fBrushBitmap.Bitmap <> nil) and (not fBrushBitmap.Bitmap.Empty) then begin
    hBitmap.Canvas.Brush.Bitmap := fBrushBitmap.Bitmap;
  end;
  //aufs temp-bitmap den brush zeichnen
  hBitmap.Canvas.Rectangle(0, 0, Width + 1, Height + 1);
  //temp-bitmap transparent schalten
  hBitmap.TransparentColor := TransparentColor;
  hBitmap.Transparent := true;
  hBitmap.TransparentMode := tmFixed;
  
  //temp-bitmap auf canvas kopieren
  Canvas.CopyRect(rect(0,0,Width,Height),hBitmap.Canvas,rect(0,0,Width,Height);
  // BitBlt(Canvas.Handle, 0, 0, Width, Height, hBitmap.Canvas.Handle, 0, 0, SRCCOPY);
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat