0

I have some transparent icons smaller in size than the ImageList where I want to add them. I try to add them as usual with ImageList.AddIcon(IcoHandle); but it seems they are scaled to the ImageList size. I want find a way to increase the canvas of my Icon with transparent color so it will be added in the ImageList without scaling. Is this possible ?

Update1:

I've done as David said, but the icon lost transparency...

 LoadIconWithScaleDown(HInstance, PChar('NUT_VITAL'), ISmall, ISmall, hI);
 Ico.Handle:= hI;

 Bmp:= TBitmap.Create;
 Bmp.Transparent:= True;
 Bmp.PixelFormat:= pf32bit;
 Bmp.SetSize(ISize, ISize);
 Bmp.Canvas.Draw(0, 0, Ico);
 Pics.Add(Bmp, nil);
 Bmp.Free;
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55

1 Answers1

0

I finally figured it out... thanks to David, Ken and Torbins answer from here.

I had to set brush style to bsClear before setting the size of the bitmap. :)

LoadIconWithScaleDown(HInstance, PChar('NUT_VITAL'), ISmall, ISmall, hI);
Ico.Handle := hI;

Bmp := TBitmap.Create;
try
  Bmp.Canvas.Brush.Style := bsClear;
  Bmp.SetSize(ISize, ISize);
  N := (ISize - ISmall) div 2;
  Bmp.Canvas.Draw(N, N, Ico);
  Pics.Add(Bmp, nil);
finally
  Bmp.Free; 
end;
Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55