Pergunta

I've just draw an anti aliased line in a BitmapLayer with this code:

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;

As you see in the below result, the line transparency pixels has some green value. And that is because of $0000FF00 (used in Clear()). But the alpha channel of this color is zero means completely transparent!

Q: Is there any problem with my code? Am I wrong somewhere?

enter image description here

Foi útil?

Solução

OK. I found it. I must use CombineMode:= cmMerge;

with BL.Bitmap do
begin
  //...
  CombineMode:= cmMerge;
  DrawMode:= dmBlend;
  //...
end
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top