我使用了带有 alpha 通道的图片,并且某些图像部分不是完全不透明的。当我在一个对象上绘制它时TImgView32
,部分会从颜色中获得一点Clear()
颜色。让我们通过示例图片来展示它:
这是您通常在 Photoshop 中看到的原始图片:
这是我在 GR32 对象的新图层上绘制它时的结果图像,我之前用以下方法清除了它Clear($00FF0000);
:
结果像 photohop 一样透明,但红色光晕是问题所在。
或另一种颜色Clear($000000FF);
:
请注意,如您所知,我使用的颜色是完全透明的。
这是我用来创建上述结果的代码:
begin
ImageList.Bitmaps.Add; //ImageList is a TBitmap32List object
LoadPNGintoBitmap32(ImageList.Bitmap[0], ImgPath+'test.png', DummyBool);
BL:= TBitmapLayer.Create(ImgView.Layers);
ImgID:=0;
ScaleFactor:= 1;
LayerPos:= Point(100, 100);
with ImageList.Bitmap[ImgID] do
ImageRect:= Rect(0, 0, Width, Height);
{Auxilary variables}
CanvasWidth:= ImageRect.Right{*2}; //Extending width for two icon.
CanvasHeight:= ImageRect.Bottom;
BL.Location:= FloatRect(
LayerPos.X,
LayerPos.Y,
LayerPos.X + CanvasWidth * ScaleFactor,
LayerPos.Y + CanvasHeight * ScaleFactor
);
with BL.Bitmap do
begin
{Init}
SetSize(CanvasWidth, CanvasHeight);
DrawMode:= dmBlend;
Clear($00FF0000);
{Insert image}
Draw(0, 0, ImageRect, ImageList.Bitmap[ImgID]);
end;
if ScaleFactor<>1 then
TDraftResampler.Create(BL.Bitmap); //BL.Bitmap, because we used "Draw" method
end;
如何避免这种情况并获得像 Photoshop 一样的清晰结果?