Author |
Topic  |
|
jonneve
France
6 Posts |
Posted - Mar 31 2016 : 09:47:00
|
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
|
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 |
 |
|
jonneve
France
6 Posts |
Posted - Mar 31 2016 : 10:22:15
|
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 |
 |
|
w2m
   
USA
1990 Posts |
Posted - Mar 31 2016 : 10:29:37
|
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 |
 |
|
wesleybobato
  
Brazil
367 Posts |
|
wesleybobato
  
Brazil
367 Posts |
|
w2m
   
USA
1990 Posts |
Posted - Mar 31 2016 : 10:43:15
|
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 |
 |
|
jonneve
France
6 Posts |
Posted - Mar 31 2016 : 11:01:55
|
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? |
 |
|
wesleybobato
  
Brazil
367 Posts |
|
w2m
   
USA
1990 Posts |
|
w2m
   
USA
1990 Posts |
Posted - Mar 31 2016 : 12:57:34
|
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 |
 |
|
jonneve
France
6 Posts |
Posted - May 09 2016 : 04:34:54
|
This feature is included in version 6.3 and it works beautifully! |
 |
|
|
Topic  |
|