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 in image and remove the rest
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - Feb 28 2017 :  00:43:07  Show Profile  Reply
I would like to make a selection in an image and replace the rest of the image with the background color or make it into alpha. How would I do this correctly?

Thanks in advance

Andy

w2m

USA
1990 Posts

Posted - Feb 28 2017 :  12:09:10  Show Profile  Reply
procedure TForm1.FillColorOutSideSelection1Click(Sender: TObject);
begin
  if Assigned(cxPageControl1.ActivePage) then
  begin
    ImageEnView := TImageEnView(cxPageControl1.ActivePage.Controls[0]);
    if Assigned(ImageEnView) then
    begin
      ImageEnView.Proc.SaveUndo('Fill color outside selection ' + IntToStr(ImageEnView.Proc.UndoCount));
      ImageEnView.InvertSelection;
      ImageEnView.Proc.Fill(ImageEnView.Background);
      ImageEnView.Update;
      ImageEnView.DeSelect;
    end;
  end;
end;

procedure TForm1.FillAlphaOutside1Click(Sender: TObject);
begin
   if Assigned(cxPageControl1.ActivePage) then
  begin
    ImageEnView := TImageEnView(cxPageControl1.ActivePage.Controls[0]);
    if Assigned(ImageEnView) then
    begin
      ImageEnView.Proc.SaveUndo('Fill alpha outside selection ' + IntToStr(ImageEnView.Proc.UndoCount));
      ImageEnView.InvertSelection;
      ImageEnView.Proc.Fill(clBlack);
      ImageEnView.Proc.SetTransparentColors(ImageEnView.IEBitmap.Pixels[0,
      ImageEnView.IEBitmap.Height - 1], ImageEnView.IEBitmap.Pixels[0, ImageEnView.IEBitmap.Height - 1], 0);
      ImageEnView.Update;
      ImageEnView.DeSelect;
    end;
  end;
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

AndyColmes

USA
351 Posts

Posted - Mar 06 2017 :  03:03:03  Show Profile  Reply
Thank you very much Bill. I will give that a try.

Andy
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: