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
 ImageEnView CurrentLayer Add Shape In Code, Then Pan Shape To Center
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

andyhill

Australia
133 Posts

Posted - Sep 03 2022 :  02:09:05  Show Profile  Reply
I load a very large image on layer 0.

Then I add via code a rectangle mask which may be out of view subject to zoom level and X/Y positioning.

ImageEnView1.LayersAdd(ielkShape);
TIEShapeLayer(ImageEnView1.CurrentLayer).Shape:= iesRoundRect;
ImageEnView1.CurrentLayer.PosX:= x1;
ImageEnView1.CurrentLayer.PosY:= y1;
ImageEnView1.CurrentLayer.Width:= x2;
ImageEnView1.CurrentLayer.Height:= y2;
ImageEnView1.CurrentLayer.FillColor:= clNone;
ImageEnView1.CurrentLayer.AlphaEdgeFeathering:= 50;
ImageEnView1.CurrentLayer.IsMask:= True;
ImageEnView1.Update();

How can I in code now pan the background image (ImageEnView1 display) centering the newly added rectangle mask within the display area, or at worst scroll it so that it is top left ?

Andy

xequte

38610 Posts

Posted - Sep 04 2022 :  00:20:58  Show Profile  Reply
Hi Andy

You can set ViewX/Y to scroll to a position on the image:

http://www.imageen.com/help/TImageEnView.ViewX.html


Or you can use VisibleBitmapRect to display a rect:

http://www.imageen.com/help/TImageEnView.VisibleBitmapRect.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 04 2022 :  00:42:24  Show Profile  Reply
Tried your suggestions no go ?

//ImageEnView1.VisibleBitmapRect:= Rect(x1, y1, x2, y2);
//ImageEnView1.VisibleBitmapRect:= ImageEnView1.Layers[1].ClientAreaBox;
//ImageEnView1.VisibleBitmapRect:= ImageEnView1.CurrentLayer.ClientAreaBox;
ImageEnView1.ViewX:= x1;
ImageEnView1.Update();
//ImageEnView1.ViewY:= y1;
//ImageEnView1.Update();


|-------------------Layer Zero---------------|
|----------------------|                     |
|---------View---------|                     |
|----------------------|                     |
|                                            |
|                             |--------------|
|                             |-----Mask-----|
|                             |--------------|
|                                            |
|                                            |
|--------------------------------------------|


Andy
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 04 2022 :  17:00:26  Show Profile  Reply
ImageEnView1.SetViewXY(x1, y2);

Brings into view barely, why y2 and not y1 ???

Andy
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 04 2022 :  18:09:18  Show Profile  Reply
Even tried

ImageEnView1.SetViewXY(ImageEnView1.XScr2Bmp(x1, False), ImageEnView1.YScr2Bmp(y1, False));

ImageEnView1.SetViewXY(ImageEnView1.XScr2Bmp(x1, True), ImageEnView1.YScr2Bmp(y1, True));

Still does not pan into view correctly (mostly fails to show Mask in view) ???


Andy
Go to Top of Page

xequte

38610 Posts

Posted - Sep 04 2022 :  18:31:42  Show Profile  Reply
Hi Andy

These methods work for me:

// Setup test
ImageEnView1.LayersClear(True);
ImageEnView1.IO.LoadFromFile('D:\Testing\Big_Big_Pix\img40946_25MP.jpg');
ImageEnView1.LayersAdd( iesEllipse, 2030, 2200, 350, 450 );

// Scroll the view to show the current layer
ImageEnView1.SetViewXY( ImageEnView1.CurrentLayer.PosX, ImageEnView1.CurrentLayer.PosY );

// Fully display layer #1 in view
ImageEnView1.VisibleBitmapRect := ImageEnView1.Layers[2].LayerRect;

// Fully display layer #1 in view
lyr := ImageEnView1.Layers[2];
ImageEnView1.VisibleBitmapRect := Rect( lyr.PosX, lyr.PosY, lyr.PosX + lyr.Width, lyr.PosY + lyr.Height );



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 05 2022 :  15:28:31  Show Profile  Reply
ImageEnView1.SetViewXY(ImageEnView1.CurrentLayer.PosX, ImageEnView1.CurrentLayer.PosY); FAILED ON VERY LARGE BASE IMAGE (10,000px x 10,000px dpi 300)

ImageEnView1.VisibleBitmapRect:= ImageEnView1.Layers[2].LayerRect; WORKED

Andy
Go to Top of Page

xequte

38610 Posts

Posted - Sep 05 2022 :  16:25:07  Show Profile  Reply
Hmm, I can't seem to reproduce that.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: