2014-01-25 45 views
3

我只是畫在BitmapLayer的反鋸齒線,此代碼:顏色alpha通道沒有完全透過度

procedure TForm4.Button1Click(Sender: TObject); 
var 
    BL: TBitmapLayer; 
begin 
    BL:= TBitmapLayer.Create(ImgView.Layers); 
    LayerPos:= Point(100, 100); 
    CanvasWidth:= 100; 
    CanvasHeight:= 100; 

    BL.Location:= FloatRect(
    LayerPos.X, 
    LayerPos.Y, 
    LayerPos.X + CanvasWidth , 
    LayerPos.Y + CanvasHeight 
);  

    with BL.Bitmap do 
    begin 
    SetSize(CanvasWidth, CanvasHeight); 
    DrawMode:= dmBlend; 
    Clear($0000FF00); 
    LineAS(0, 0, 100, 80, clBlack32); 
    end 
end; 

正如你在下面的結果看,線透明度像素有一定的綠色價值。這是因爲$0000FF00(在Clear()中使用)。但這種顏色的alpha通道爲零意味着完全透明!

問:我的代碼有問題嗎?我在哪裏錯了嗎?

enter image description here

回答

0

確定。我找到了。我必須用CombineMode:= cmMerge;

with BL.Bitmap do 
begin 
    //... 
    CombineMode:= cmMerge; 
    DrawMode:= dmBlend; 
    //... 
end 
相關問題