title: png to bmp conversion (maintaining transparency)
body: <p>I am using delphi XE-5 and I am loading button information from a JSON file, in order to create buttons on a TMS ADVToolBar control. Each button is 50X35 and in png format with transparency.</p>
  
  <p>I am getting each url, using the idHTTP component to retrieve it to a stream and then load it into a png. I then draw it onto a transparent BMP. However, I dont think this is the correct way. Anyway, the bmp is then added to a TImageList where it is assigned to a button using the index.  The Image shows up on the button, but with no transparency.</p>
  
  <p>see my code below:</p>
  
  <pre><code> imgUrl:= //code to get img url from JSON file;
  
   MS := TMemoryStream.Create;
   png := TPngImage.Create;
   png.Transparent:= True;
   try
    idHTTP1.get(imgUrl,MS);
    Ms.Seek(0,soFromBeginning);
    png.LoadFromStream(MS);
    bmp:= TBitmap.Create;
    bmp.Transparent:= True;
    bmp.Width:= 50;
    bmp.Height:= 50;
    png.Draw(bmp.Canvas, Rect(7, 7, png.Width, png.Height));
    ImageList1.Add(bmp, nil);
    AdvGlowBtn.Images:= ImageList1;
    AdvGlowBtn.Layout:= blGlyphTop;
    AdvGlowBtn.WordWrap:= False;
    AdvGlowBtn.AutoSize:= True;
  
    AdvGlowBtn.ImageIndex:= ImageList1.Count-1;
  
    bmp.Free;
   finally
   FreeAndNil(png);
   FreeAndNil(MS);
   end;
  </code></pre>