0

我正在尝试从资源中加载 TBitmap,同时保持透明。即使启用了透明属性,它看起来仍然一样。

我试图做的事情:

procedure TMovie.BitBtn1Click(Sender: TObject);
var
 BitMap1 : TBitMap;
begin
  BitMap1 := TBitMap.Create;

  BitMap1.Transparent := TRUE;
  BitMap1.TransparentColor := clBlack;

  try
    BitMap1.LoadFromResourceName(HInstance,'Bitmap_2');
    Star_2.Picture.Assign(Bitmap1);
  finally
    BitMap1.Free;
  end;
end;
4

1 回答 1

1

您应该尝试如下反转透明度属性:

procedure TMovie.BitBtn1Click(Sender: TObject);
var
 BitMap1 : TBitMap;
begin
  BitMap1 := TBitMap.Create;
  
  try
    BitMap1.LoadFromResourceName(HInstance,'Bitmap_2');

    BitMap1.Transparent := TRUE;
    BitMap1.TransparentColor := clBlack;

    Star_2.Picture.Assign(Bitmap1);
  finally
    BitMap1.Free;
  end;
end;
于 2021-09-03T12:51:46.997 回答