ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Selection Questions
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

graphman

259 Posts

Posted - Nov 23 2016 :  14:25:40  Show Profile  Reply
Is there ability to

1) expand the selection border (1-2 pixels)?

2) copy selection (border only) from one ImageEn to other ImageEn
without saving to file and restore from file?

w2m

USA
1990 Posts

Posted - Nov 23 2016 :  14:28:03  Show Profile  Reply
Please expand your questions to be more specific. Do you mean expand the selection by 1-2 pixels? There is no selection border.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

graphman

259 Posts

Posted - Nov 23 2016 :  17:09:21  Show Profile  Reply
Like "Expand selection" in PhotoShop.

"Expand will add a set amount of pixels to the edges of your selection."
Go to Top of Page

xequte

38615 Posts

Posted - Nov 24 2016 :  03:41:02  Show Profile  Reply
It will be something like:

// Enlarge the selection by ten pixels on all sides
With ImageEnView1 do
begin
  SelectionBase := iesbBitmap;
  Select( SelX1 - 10, SelY1 - 10, SelX2 - 10, SelY2 - 10 );
End;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

graphman

259 Posts

Posted - Nov 24 2016 :  06:35:50  Show Profile  Reply
It only creates the rectangular selection.
Original selection may has an arbitrary shape.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Nov 24 2016 :  09:31:51  Show Profile  Reply
You should have asked what kind of selection you wanted to change to begin with. Anyway, you would have to change the position of each point to do this.

Maybe you can try to scale the array of points:
procedure ScalePoint(var APoint: TPoint; AHorzontalScale, AVerticalScale: extended; AOrigin: TPoint);
var
  iLeft, iTop: Integer;
begin
  iLeft := APoint.X - AOrigin.X;
  iTop := APoint.Y - AOrigin.Y;
  APoint := Point(Round(iLeft * AHorzontalScale) + AOrigin.X, Round(iTop * AVerticalScale) + AOrigin.Y);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;
  iPoint: TPoint;
  iPointCount: Integer;
  iPoints: Array of TPoint;
begin
  ImageEnView1.LockPaint;
  iPointCount := ImageEnView1.PolySelCount;
  SetLength(iPoints, iPointCount);
  for i := 0 to iPointCount - 1 do
  begin
    iPoint := ImageEnView1.PolySel[i];
    ScalePoint(iPoint, 1.1, 1.1, ImageEnView1.PolySel[0]);
    iPoints[i].X := iPoint.X;
    iPoints[i].Y := iPoint.Y;
  end;
  ImageEnView1.DeSelect;
  for i := 0 to iPointCount - 1 do
    ImageEnView1.AddSelPoint(iPoints[i].X, iPoints[i].Y);
  ImageEnView1.UnLockPaint;
end;
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

graphman

259 Posts

Posted - Nov 24 2016 :  14:54:11  Show Profile  Reply
> You should have asked what kind of selection you wanted to change to begin with.

Selection after "SelectMagicWand"
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Nov 24 2016 :  17:44:57  Show Profile  Reply
You can use the trick with SelectionMaskFeather.
However, selection mask must be 8-bit.
Let's say that paintView is TIMageEnView object. Here is a C++ example:

paintView->SelectionMaskDepth = 8; //set after image is loaded


// enlarge selection area using feathering (blur) with radius 4:
paintView->MakeSelectionFeather(4);
// set feathering to 0 - selection area will stay enlarged
paintView->MakeSelectionFeather(0);
// update all pixels inside mask to highest value (correct pixels < 255)
for (int i = 0; i < paintView->Height; i++)
   {
   for (int j = 0; j < paintView->Width; j++)
       {
	if (paintView->SelectionMask->IsPointInside(j, i))
	   paintView->SelectionMask->SetPixel(j, i, 255);
       }
   }


HTH,
Siniša
Go to Top of Page

graphman

259 Posts

Posted - Nov 25 2016 :  06:10:00  Show Profile  Reply
thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: