Hallo zusammen!
Ich möchte ein TBitmap "bmp" rotiert zeichnen. Dazu verwende ich PlgBlt. Leider wird dabei erstmal die Transparenz nicht berücksichtigt. Dafür ist wohl der Parameter
Mask: HBITMAP
da. Wenn ich dem
bmp.MaskHandle
übergebe, wird allerdings mein Bitmap wegmaskiert, nicht die transparenten Teile.
Hier mal Testcode:
Delphi-Quellcode:
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
bmp: TBitmap;
r: TRect;
Points: array[0..2] of TPoint;
begin
bmp := TBitmap.Create;
try
bmp.LoadFromFile('test.bmp');
bmp.Transparent := True;
SetRect(r, 0, 0, bmp.Width, bmp.Height);
PaintBox1.Canvas.StretchDraw(r, bmp);
OffsetRect(r, bmp.Width + 2, 0);
Points[0] := Point(r.Left, r.Top);
Points[1] := Point(r.Right, r.Top);
Points[2] := Point(r.Left, r.Bottom);
PlgBlt(PaintBox1.Canvas.Handle, Points, bmp.Canvas.Handle, 0, 0, bmp.Width, bmp.Height, 0, 0, 0);
OffsetRect(r, bmp.Width + 2, 0);
Points[0] := Point(r.Left, r.Top);
Points[1] := Point(r.Right, r.Top);
Points[2] := Point(r.Left, r.Bottom);
PlgBlt(PaintBox1.Canvas.Handle, Points, bmp.Canvas.Handle, 0, 0, bmp.Width, bmp.Height, bmp.MaskHandle, 0, 0);
finally
bmp.Free;
end;
end;
Der liefert das:
Das Originalbitmap schaut wie in der Mitte aus. Ich möchte den "Look" links, kriege aber mit PlgBlt das Ergebnis rechts.
Ich könnte mir selbst ein Maskenbitmap zusammenbasteln, aber TBitmap.MaskHandle ist doch genau dafür da:
Zitat:
Use MaskHandle to call a Windows
API function that requires the
handle of a bitmap object. Pass MaskHandle as the bitmap
handle parameter to these functions.
Hab ich da was übersehen?