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
 Rotate selection rectangle
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jonneve

France
6 Posts

Posted - Mar 31 2016 :  09:47:00  Show Profile  Reply
Hello,

I'm new to ImageEN, and I would like to rotate the selection rectangle (not its contents, just the rectangle). The idea is that the end user needs to select a rectangle for cropping, and will rotate the selection rectangle as needed to fix the skew. I can't autodetect the skew, because the image itself isn't skewed, it's just that they want to frame a small area and sometimes need to change the angle while doing so. So I can't do it programmatically

They're used to using Photoshop and I'm now using ImageEN to replace Photoshop and put the image editing into our custom software, but if possible, I'd like to keep things similar to Photoshop. In Photoshop, you can rotate the selection by simply clicking on the corners of the selection rectangle. They then double-click on the selection rectangle to crop.

As I said, I'm new to this so perhaps the answer is obvious, but I could use a little help.

Thanks in advance,
Jonathan

w2m

USA
1990 Posts

Posted - Mar 31 2016 :  10:17:57  Show Profile  Reply
Unfortunately your task is a tough one for ImageEn which is not currently possible. Selections can be moved and resized but not rotated with ImageEn.

Layers can be set to rotate with the mouse. So it may be possible to create a transparent layer, rotate the layer with the mouse, then get the layer position and dimensions to create a polygon selection from the layer information, then remove the layer.

Cropping requires a TRect so the crop will be a rectangle and will not match the polygon selection. As I see it, a new CropToPolygon method would be required to accomplish your task.

So even if ImageEn was modified to support layer rotation a new cropping function would also be requited.

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

jonneve

France
6 Posts

Posted - Mar 31 2016 :  10:22:15  Show Profile  Reply
Hi Bill,

Thanks for your quick reply!

An alternative might be to rotate the image itself and then crop. If it's easy enough to do, it might be good enough, but I can't see any easy to do that either. I mean, I can rotate it programmatically, but is there a way to easily let the end user rotate it?

Thanks,
Jonathan
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 31 2016 :  10:29:37  Show Profile  Reply
Put the image in a moveable, resizable and rotatable layer, rotate the layer with the mouse then use LayersMergeAll. I have not tested this however....

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

wesleybobato

Brazil
367 Posts

Posted - Mar 31 2016 :  10:38:36  Show Profile  Reply
Hi William

Watch This Video.

He's trying to do something that currently does not support ImageEn.
Unfortunately it is not possible to do via code.


Best regards

attach/wesleybobato/2016331103821_RotateSelection.zip
791.16 KB
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - Mar 31 2016 :  10:40:48  Show Profile  Reply
Hi Again

Please Use this Demo

Rotate and Crop Automatic cropping of borders using TImageEnProc.RotateAndCrop

http://www.imageen.com/cgi-bin/dlredirect.asp?demo=run/ImageEditing/RotateAndCrop/RotateAndCrop.exe
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 31 2016 :  10:43:15  Show Profile  Reply
Nice app Wesley... Did you call LayersFixSizes and LayersFixRotation before cropping? I am not sure if it will make any difference however.

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

jonneve

France
6 Posts

Posted - Mar 31 2016 :  11:01:55  Show Profile  Reply
That RotateAndCrop demo looks interesting! Is the source available? I think if I put a trackbar like you have, it might be good enough. I'm using a TImageEnDBVect though, loading a JPG image from a database and then adding vector objects to it, and I can't figure out how to use layers with that. Do I really need layers, or can I just rotate the whole thing?
Go to Top of Page

wesleybobato

Brazil
367 Posts

Posted - Mar 31 2016 :  11:15:50  Show Profile  Reply
Sorry for Delay

Link Here
http://www.imageen.com/demos/index.html
http://www.imageen.com/cgi-bin/dlredirect.asp?demo=zips/ImageEditing.zip

Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 31 2016 :  11:59:40  Show Profile  Reply
It turns out you can rotate a layer with the mouse, merge the layer and auto crop the rotated image. I made a small demo which you may obtain here:
attach/w2m/201633112142_RotateLayer.zip
73.17 KB

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

Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 31 2016 :  12:57:34  Show Profile  Reply
Here is a simplified version where the image is opened, then you rotate with the mouse and then double click the image to crop it.

attach/w2m/2016331125656_CropLayer.zip
65.53 KB

If you desire to remove the background, SetTransparentColors in ImageEnView1DblClick.
procedure TForm1.ImageEnView1DblClick(Sender: TObject);
begin
  ImageEnView1.LayersFixSizes(ImageEnView1.LayersCurrent);
  ImageEnView1.LayersFixRotations(ImageEnView1.LayersCurrent);
  ImageEnView1.LayersFixBorders(ImageEnView1.LayersCurrent);
  ImageEnView1.LayersMergeAll;
  ImageEnView1.Proc.AutoCrop(10, CreateRGB(255, 255, 255), True);
  ImageEnView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
  ImageEnView1.MouseInteract := [];
  ImageEnView1.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

jonneve

France
6 Posts

Posted - May 09 2016 :  04:34:54  Show Profile  Reply
This feature is included in version 6.3 and it works beautifully!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: