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
 Make area inside selection transparent?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

933 Posts

Posted - May 28 2013 :  07:33:19  Show Profile  Reply
Hi!

Is there a quick method to make all pixels inside a selection transparent?

w2m

USA
1990 Posts

Posted - May 28 2013 :  08:51:56  Show Profile  Reply
procedure TForm1.MakeTransparent1Click(Sender: TObject);
{ Make the area inside of the selection transparent. }
begin
  if ImageEnView1.Selected then
  begin
    Screen.Cursor := crHourGlass;
    try
      ImageEnView1.Proc.SaveUndoCaptioned('Make Selection Transparent ' +
        IntToStr(ImageEnView1.Proc.UndoCount));
      Undo1.Hint := 'Make Selection Transparent ' + IntToStr(ImageEnView1.Proc.UndoCount);
      ImageEnView1.EnableAlphaChannel := True;
      ImageEnView1.IO.Params.BitsPerSample := 8;
      ImageEnView1.IO.Params.SamplesPerPixel := 4;
      ImageEnVIew1.SetSelectedAreaAlpha(0);
      Undo1.Enabled := ImageEnView1.Proc.CanUndo;
      ImageEnView1.Bitmap.Modified := True;
    finally
      Screen.Cursor := crDefault;
    end;
  end
  else
  begin
    MessageDlg('There is no selection.  Please make a selection and try again.', mtWarning, [mbOK],
      0);
  end;
end
;
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

PeterPanino

933 Posts

Posted - May 28 2013 :  11:57:35  Show Profile  Reply
Hi William!

Thanks for the code! But just now I have discovered that a simple ImageEnVIew1.Proc.SetTransparentColors also makes the selection area transparent!

EDIT: Oops, I think I am wrong! ImageEnVIew1.Proc.SetTransparentColors only makes a specific color (or a range of colors) transparent, while your code makes all colors inside the selection transparent. Am I right?
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 28 2013 :  12:17:09  Show Profile  Reply
Correct!

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