Kaan Aykut KABAKÇI Kaan Aykut KABAKÇI - 3 months ago 11
Pascal Question

How can i draw polygon by using mouse on an image Delphi?

I want to take a determined mask from an image by using mouse. I tried like these properties below:

ImageEnVect.SelectionMask;
ImageEnVect.MouseInteract:= [miSelectLasso];


But i do not know completely what should i do. Could you help me ?

Answer

The code that i used listed below:

  if ImageEnMView1.ImageCount > 0 then
  begin
    ImageEnMView1.SelectedImage:= 0;
    ImageEnMView1ImageSelect(Nil, 0);
    ImageEnVect1.MouseInteract:= [miSelectLasso];//this part allow drawing polygon
  end;

i can get mask image information like this:

  GrayImg:= TGrayImage.Create(ImageEnVect1.SelectionMask.Width,ImageEnVect1.SelectionMask.Height);
  GrayImg.Paint(0);

  for i := 0 to GrayImg.Height-1 do
  begin
    for j := 0 to GrayImg.Width-1 do
    begin
      if ImageEnVect1.SelectionMask.GetPixel(j,i) > 0 then
        GrayImg.PixelData[i,j]:= 255;

    end;

  end;