Registriert seit: 7. Jun 2003
Ort: Mülheim an der Ruhr
436 Beiträge
Delphi 10.3 Rio
|
Re: VirtualStringTree mit PNG Grafik
6. Apr 2009, 00:22
Hi,
hab mal schnell was ausprobiert sollte eigentlich funzen:
Delphi-Quellcode:
uses
pngimage;
function LoadPng(Width, Height: integer): TBitmap;
var
Png : TPngImage;
begin
Result := TBitmap.Create;
Png := TPngImage.Create;
try
Png.LoadFromFile('Your Png Image');
Result.PixelFormat := pf32bit;
Result.SetSize(Width, Height);
Result.Assign(Png);
except
Result.Free;
raise;
end;
FreeAndNil(Png);
end;
procedure TForm1.FormShow(Sender: TObject);
var
BlendRec: TBlendFunction;
TestBitmap: TBitmap;
begin
BlendRec.BlendOp := AC_SRC_OVER;
BlendRec.BlendFlags := 0;
BlendRec.SourceConstantAlpha := 255;
BlendRec.AlphaFormat := AC_SRC_ALPHA;
TestBitmap := LoadPng(Img1.Width, Img1.Height);
try
Img1.Picture.Bitmap.Assign(TestBitmap);
Windows.AlphaBlend(Img2.Canvas.Handle, 0, 0, TestBitmap.Width,
TestBitmap.Height, TestBitmap.Canvas.Handle, 0, 0,
TestBitmap.Width, TestBitmap.Height, BlendRec);
finally
TestBitmap.Free;
end;
end;
procedure TForm1.vstPaintBackground(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; R: TRect; var Handled: boolean);
var
BlendRec: TBlendFunction;
begin
Handled := True;
BlendRec.BlendOp := AC_SRC_OVER;
BlendRec.BlendFlags := 0;
BlendRec.SourceConstantAlpha := 255;
BlendRec.AlphaFormat := AC_SRC_ALPHA;
Windows.AlphaBlend(TargetCanvas.Handle,
Sender.ClientWidth - img2.Width, Sender.ClientHeight - img2.Height, Img2.Width,
Img2.Height, Img2.Canvas.Handle, 0, 0,
Img2.Width, Img2.Height, BlendRec);
end;
Benötige Komponenten Vst = VirtualStringTree
Img1 = TImage
Img2 = TImage
Ggf. sollte man noch prüfen ob die "Alphablend Function" verfügbar ist.
In TreeOptions des Vst bei PaintOptions noch toShowBackground = True einstellen.
Gruß
s!
|
|
Zitat
|