Transparency on FMXSpeedButton

How do I set the transparency color for bitmap loaded into a TTMSFMXSpeedbutton?

Hi, 


Perhaps you can try with this code:

procedure TForm33.TMSFMXSpeedButton1ApplyStyleLookup(Sender: TObject);
var
  ac: TAlphaColor;
  bmp: TBitmap;
  bmpdt: TBitmapData;
  clatr, tr, c: TAlphaColor;
  I, x, y: Integer;

begin
  bmp := TMSFMXSpeedButton1.GetImage.Bitmap;
  bmp.Map(TMapAccess.ReadWrite, bmpdt);
  clatr := bmpdt.GetPixel(0, 0);
  tr := claNull;

  for x := 0 to bmpdt.Width - 1 do
  begin
    for y := 0 to bmpdt.Height - 1 do
    begin
      c := bmpdt.GetPixel(x, y);
      if c = clatr then
        bmpdt.SetPixel(x, y, tr);
    end;
  end;
  bmp.Unmap(bmpdt);
end;

Kind Regards, 
Pieter

Thanks for the reply, I was expecting something simpler possibly.  I notice that TImage has a MultiResBitmap property which allows the transparency color to be set and I know that works. Is there any any to gain access programmatically to that facility? I am constructing a tool bar of buttons and need to set the transparency for each one.

PS The code you gave definitely works, I just tried it, just wondering is there is a more elegant way. On VCL its trivial, just set the transparency color. 

The internally used component is a TTMSFMXBitmap. 

We have experimented here and you can also use the following code:

procedure TForm1.TMSFMXSpeedButton1ApplyStyleLookup(Sender: TObject);
begin
  TMSFMXSpeedButton1.GetImage.Opacity := 0.5;
end;

Kind Regards, 
Pieter

"TMSFMXSpeedButton1.GetImage.Opacity := 0.5;" doesn't work for me because it dimms the entire image and the transparency color is still visible though also dimmed. For now I'll use your original solution but this might be a feature you might want to include in a future revision, transparency for bitmaps in buttons is a common need.