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
 Copy selection always rectangular

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
PeterPanino Posted - Aug 25 2017 : 19:12:56
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?
6   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Aug 29 2017 : 16:22:46
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
PeterPanino Posted - Aug 29 2017 : 15:42:47
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.
w2m Posted - Aug 29 2017 : 15:08:06
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
PeterPanino Posted - Aug 29 2017 : 14:17:17
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;
xequte Posted - Aug 27 2017 : 20:43:08
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
w2m Posted - Aug 26 2017 : 12:21:30
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