我需要能够将透明 PNG 图像作为图层添加到 ImgView32(来自 graphics32 库)。有谁知道如何做到这一点?
基本上,我可以将任何图像作为图层添加到我的 Image32,但所有图像(即使它们本质上是透明的)都有白色背景。我需要解决这个问题。有人知道吗?
这就是我将图像添加为图层的方式:
var
B: TBitmapLayer;
P: TPoint;
W, H: Single;
const
MasterAlpha: SmallInt = 100;
begin
with OpenPictureDialog do
if Execute then
begin
B := TBitmapLayer.Create(ImgView321.Layers);
with B do
try
Bitmap.LoadFromFile(FileName);
Bitmap.DrawMode := dmTransparent;
with ImgView321.GetViewportRect do
P := ImgView321.ControlToBitmap(GR32.Point((Right + Left) div 2, (Top + Bottom) div 2));
W := Bitmap.Width * 0.5;
H := Bitmap.Height * 0.5;
with ImgView321.Bitmap do
Location := GR32.FloatRect(P.X - W, P.Y - H, P.X + W, P.Y + H);
Scaled := True;
B.Bitmap.CombineMode := cmBlend;
B.Bitmap.DrawMode := dmTransparent;
OnMouseDown := LayerMouseDown;
OnKeyUp :=LayerKeyUp;
except
Free;
raise;
end;
Selection := B;
end;
end;
所以我设置Bitmap.DrawMode := dmTransparent;似乎并不重要 它什么也不做。即使我添加了 PNGImage 来使用,除了我现在可以选择 png 图像添加到我的图像之外,没有任何变化
所以请告诉我我做错了什么以及我应该怎么做才能解决这个问题。
谢谢
编辑
我知道将PNG加载到Bitmap32中,如此链接http://graphics32.org/wiki/FAQ/ImageFormatRelated中所述,但显然我“无法将TBitmap32分配给TBitmapLayer”,因此在将透明PNG加载到Bitmap32之后就好了(理论上)如何将它分配给我的图层?