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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Selection in image and remove the rest

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndyColmes Posted - Feb 28 2017 : 00:43:07
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
2   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - Mar 06 2017 : 03:03:03
Thank you very much Bill. I will give that a try.

Andy
w2m Posted - Feb 28 2017 : 12:09:10
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