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
 Copy selection always rectangular
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

864 Posts

Posted - Aug 25 2017 :  19:12:56  Show Profile  Reply
When I make a circular selection with
ImageEnView1.MouseInteract := [miSelectCircle];
:



...then the clipboard copy with
ImageEnView1.Proc.CopyToClipboard(iecpAuto);
is always rectangular:



How can I get a clipboard copy where only the circular area is visible and everything outside the circular area is transparent?

w2m

USA
1990 Posts

Posted - Aug 26 2017 :  12:21:30  Show Profile  Reply
procedure TForm1.Copy1Click(Sender: TObject);
var
  iRGB: TRGB;
  i: integer;
begin
  if (SelectEllipse1.Down) and (ImageEnView1.Selected) then
  begin
    { Save original image to restore after copy }
    ImageEnView1.Proc.SaveUndo('Copy Ellipse');
    { Invert the selection to set the transparency }
    ImageEnView1.InvertSelection;
    { Fill the selection with black }
    ImageEnView1.Proc.Fill(clBlack);
    { Remove the selection }
    ImageEnView1.DeSelect;
    { Render the trancparency }
    iRGB := TColor2TRGB(clBlack);
    { Set the transparency- make the black transparent }
    ImageEnView1.Proc.SetTransparentColors(iRGB, iRGB, 0);
    ImageEnView1.BackgroundStyle := iebsChessboard;
    ImageEnView1.IO.Params.BitsPerSample := 8;
    ImageEnView1.IO.Params.SamplesPerPixel := 4;
    { Copy to the clipboard }
    ImageEnView1.Proc.CopyToClipboard();
    { Restore the original image }
    for i := 0 to ImageEnView1.Proc.UndoCount-1 do
      ImageEnView1.Proc.UndoAt(i);
    ImageEnView1.Proc.ClearAllUndo;
    ImageEnView1.Update;
    Undo1.Enabled := ImageEnView1.Proc.CanUndo;
  end
  else
  begin
    ImageEnView1.Proc.CopyToClipboard();
  end;
end;

procedure TForm1.Paste1Click(Sender: TObject);
begin
  ImageEnView2.Proc.PasteFromClipboard();
  ImageEnView2.Update;
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

xequte

38222 Posts

Posted - Aug 27 2017 :  20:43:08  Show Profile  Reply
Hi

Yes, there seems to be an issue where it is failing to detect the alpha channel when copying.

Please try adding this code before you copy:

If ImageEnView1.EnableAlphaChannel then
  ImageEnView1.IEBitmap.AlphaChannel;

(Assumes ImageEnView1.LegacyBitmap = False).

We'll fix this for the next update.


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

PeterPanino

864 Posts

Posted - Aug 29 2017 :  14:17:17  Show Profile  Reply
Nigel,

thank you, this works when I copy from a TImageEnView with the above conditions and then e.g. paste it in Directory Opus to create an image from the clipboard.

But when I create an image file with the following code from the clipboard copied from an image to the clipboard on the same conditions then it fails again i.e. a rectangular copy is created:

procedure TFormMain.mPasteImageClick(Sender: TObject);
var
  ThisImage: TIEBitmap;
begin
  ThisImage := TIEBitmap.Create;
  try
    if ThisImage.PasteFromClipboard then          
      ThisImage.Write('R:\testimage.png');    
  finally
    ThisImage.Free;
  end;
end;
Go to Top of Page

w2m

USA
1990 Posts

Posted - Aug 29 2017 :  15:08:06  Show Profile  Reply
Did the image have an alphachannel immediately before you copied the selection to the clipboard when copying an elliptical selection?
if ImageEnView1.EnableAlphaChannel then
  ImageEnView1.IEBitmap.AlphaChannel;
ImageEnView1.Proc.CopyToClipboard;

if not your code will not work.

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

PeterPanino

864 Posts

Posted - Aug 29 2017 :  15:42:47  Show Profile  Reply
Yes, it did.

The clipboard content is the SAME both when succesfully creating the circular selection e.g. in Directory Opus and when using this code.

So it is certain that the clipboard content has the circular selection. So the error must be in the TIEBitmap code above.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Aug 29 2017 :  16:22:46  Show Profile  Reply
The problem is the image does not have an alphachannel. Add an alphachannel and it works just fine.
procedure TForm1.Button1Click(Sender: TObject);
var
  iIEBitmap: TIEBitmap;
  iIOParams: TIOParams;
begin
  iIEBitmap := TIEBitmap.Create;
  try
    if iIEBitmap.PasteFromClipboard then
    begin
      iIOParams := TIOParams.Create();
      try
        iIOParams.BitsPerSample := 8;
        iIOParams.SamplesPerPixel := 4;
        iIEBitmap.AlphaChannel;
        iIEBitmap.Write(DesktopFolder +'testimage.png', iIOParams);
      finally
        iIOParams.Free;
      end;
    end;
  finally
    iIEBitmap.Free;
  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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: