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
 CropSelectionEx?

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 - Mar 06 2024 : 18:07:42
Is there a built-in ImageEn method to achieve the "CropSelectionEx" feature?

1. If the selection spans the entire width of the image, the height of the image is reduced by the height of the selection. The area above the selection is then merged with the area below the selection to form a single image.

2. If the selection spans the entire height of the image, the width of the image is reduced by the width of the selection. The area to the left of the selection is then merged with the area to the right of the selection to form a single image."
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 08 2024 : 02:46:22
Yes, that is a cool feature.



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Mar 08 2024 : 00:45:51
The conventional clipboard cut operation often results in a noticeable 'scar.'

In contrast, the CropSelectionEx method I've developed leaves no visible traces:

xequte Posted - Mar 07 2024 : 19:46:23
Hi Peter

Nice one. In what context do you use it?



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Mar 07 2024 : 09:50:50
Hi Nigel,

In the meantime, I have implemented it:

procedure TformPreview.CropSelectionEx(AImageView: TImageEnView);
// 1. If the selection spans the entire width of the image, the height of the image is reduced by the height of the selection.
//    The area above the selection is then merged with the area below the selection to form a single image.
// 2. If the selection spans the entire height of the image, the width of the image is reduced by the width of the selection.
//    The area to the left of the selection is then merged with the area to the right of the selection to form a single image.
var
  SelectionRect: TIERectangle;
  ImageWidth, ImageHeight: Integer;
  SelectedRect: TRect;
  OutsideTop, OutsideBottom, OutsideLeft, OutsideRight: TIEBitmap;
begin
  // Get the dimensions of the image:
  ImageWidth := AImageView.IEBitmap.Width;
  ImageHeight := AImageView.IEBitmap.Height;

  // Get the selection rectangle:
  SelectionRect := AImageView.SelectedRect;

  // Convert the TIERectangle to TRect:
  SelectedRect := IERectangleToRect(SelectionRect);

  // Check if the selection spans the entire width of the image:
  if SelectionRect.Width = ImageWidth then
  begin
    // Extract the areas outside of the selection vertically:
    OutsideTop := TIEBitmap.Create;
    OutsideBottom := TIEBitmap.Create;
    try
      OutsideTop.Assign(AImageView.IEBitmap);
      OutsideBottom.Assign(AImageView.IEBitmap);

      // Resize the top part to remove the bottom area:
      OutsideTop.Resize(ImageWidth, ImageHeight - SelectedRect.Height - (ImageHeight - SelectedRect.Bottom),
        0, 255, iehLeft, ievTop);
      // Resize the bottom part to remove the top area:
      OutsideBottom.Resize(ImageWidth, ImageHeight - SelectedRect.Bottom, 0, 255, iehLeft, ievBottom);      

      // Join the bottom part with the top part:
      AImageView.Proc.JoinBitmaps(OutsideTop, OutsideBottom, True);
      AImageView.Deselect;
    finally
      OutsideTop.Free;
      OutsideBottom.Free;
    end;
  end
  // Check if the selection spans the entire height of the image:
  else if SelectionRect.Height = ImageHeight then
  begin
    // Extract the areas outside of the selection horizontally
    OutsideLeft := TIEBitmap.Create;
    OutsideRight := TIEBitmap.Create;
    try
      OutsideLeft.Assign(AImageView.IEBitmap);
      OutsideRight.Assign(AImageView.IEBitmap);

      // Resize the left part to remove the right area:
      OutsideLeft.Resize(ImageWidth - SelectedRect.Width - (ImageWidth - SelectedRect.Right), ImageHeight,
        0, 255, iehLeft, ievTop);
      // Resize the right part to remove the left area:
      OutsideRight.Resize(ImageWidth - SelectedRect.Right, ImageHeight, 0, 255, iehRight, ievTop);

      // Join the left part with the right part:
      AImageView.Proc.JoinBitmaps(OutsideLeft, OutsideRight, False);
      AImageView.Deselect;
    finally
      OutsideLeft.Free;
      OutsideRight.Free;
    end;
  end;

  // Refresh the view to reflect the changes
  AImageView.Update;
end;


I can donate it to ImageEn.
xequte Posted - Mar 06 2024 : 19:00:52
Hi Peter

There is not a feature available for that, I'm afraid.

Nigel
Xequte Software
www.imageen.com