1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| procedure tFraCollections.ChargeIconeToBitmap(sFichier: string;
wIconIndex: word; DestBitmap: TBitmap; clBackColor: TColor = clBtnFace);
var
imgTampon: TImage;
begin
imgTampon := TImage.Create(self);
imgTampon.AutoSize := True;
imgTampon.Picture.Icon.Handle :=
ExtractAssociatedIcon(application.Handle, PChar(sFichier), wIconIndex);
if imgTampon.Picture.Icon <> nil then
with DestBitmap do
begin
imgTampon.Transparent := False;
imgTampon.Picture.Icon.Transparent := False;
Transparent := False;
Width := imgTampon.Width;
Height := imgTampon.Height;
Canvas.Brush.Color := clBackColor;
Canvas.FillRect(rect(0, 0, Width, Height));
Canvas.Draw(0, 0, imgTampon.Picture.Icon);
TransparentColor := Canvas.Pixels[0, 0];
Transparent := True;
end;
imgTampon.Free;
end; |
Partager