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
 Saving the position of a Magnify layer

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
AndyColmes Posted - May 02 2015 : 09:39:01
I would like to save the "ViewX" and "ViewY" of a magnify layer, but those properties do not exist for a layer. Using PosX and PosY is not good for me since it could be in another spot of the image that is not visible. I need to restore the magnify layer position relative to the visible rect of the image. How would I do that?

Thanks in advance.

Andy
7   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - May 08 2015 : 00:54:27
Thanks very much Bill. You've been very helpful.

Andy
w2m Posted - May 06 2015 : 07:18:51
Did you try the layers demo... because it works correctly. "Magnify.Rate, etc. does not update right away, even after calling Update".

The Magnify.Rate updates correctly with the layers demo. When you change the magnify rate the magnification changes.

"Is it possible to show the outer parts of the ellipse to be transparent so the ellipse is shown? Right now it is impossible to make out the ellipse at all."

With the layers demo when you use an ellipse magnifier the ellipse is clearly visible and the area outside of the ellipse (the layer) is already transparent.

"Also, for ellipse magnify layer, how do I show that it is really an ellipse and not an ellipse in a rectangle layer?"

You can't. The ellipse is inside a rectangle layer. Layers are always rectangular.

I'd look at the layers demo and proceed from there because it works as expected. If you are trying to create a ellipse magnifier with the handles of the layer around the ellipse it is not possible at this time. They would have to develop an alternate magnifier to achieve that.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - May 05 2015 : 23:52:16
Hi Bill, Fantastic! I will give it a try. I was also trying to use VisibleBitmapRect for it, but any change to it like Magnify.Rate, etc. does not update right away, even after calling Update. I had to resort to removing the magnify layer and adding it again. Also, for ellipse magnify layer, how do I show that it is really an ellipse and not an ellipse in a rectangle layer? Is it possible to show the outer parts of the ellipse to be transparent so the ellipse is shown? Right now it is impossible to make out the ellipse at all.

Thanks again Bill as always.

Andy
w2m Posted - May 04 2015 : 10:00:41
Unfortunately I have been unable to get the scrollbar positions using the windows API to set the layer position that way, but I had some success by using the VisibleBitmapRect.
procedure TForm1.ImageEnView1ViewChange(Sender: TObject; Change: Integer);
var
  iRect: TRect;
  ix: Integer;
  iy: Integer;
begin
  { If there is a magnify layer }
  if ImageEnView1.LayersCount > 1 then
    if (ImageEnView1.Layers[1].Magnify.Enabled) then
    begin
      { Get the rect of the visiblebitmap }
      iRect := ImageEnView1.VisibleBitmapRect;
      ix := iRect.Left;
      iy := iRect.Top;
      ImageEnView1.Layers[1].PosX := ix;
      ImageEnView1.Layers[1].PosY := iy;
    end;
end;

This should keep the magnify layer visible at the top left of the visible bitmap. It seems to work when zooming in but not when zooming out. I have no idea what the problem is.

Update
I finally figured it out. This keeps the magnify layer visible at all times at the top left edge of the visible bitmap regardless of the zoom level when zooming in or out.
procedure TForm1.ImageEnView1ViewChange(Sender: TObject; Change: Integer);
var
  iRect: TRect;
  ix: Integer;
  iy: Integer;
begin
  { If there is a magnify layer }
  if ImageEnView1.LayersCount > 1 then
  if (ImageEnView1.Layers[1].Magnify.Enabled) then
  begin
    { Get the rect of the visiblebitmap }
    iRect := ImageEnView1.VisibleBitmapRect;
    { Set the layers coordinates }
    ix := iRect.TopLeft.X + ImageEnView1.Layers[1].Width;
    iy := iRect.TopLeft.Y + ImageEnView1.Layers[1].Height;
    ImageEnView1.Layers[1].PosX := ix;
    ImageEnView1.Layers[1].PosY := iy;
  end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - May 03 2015 : 00:34:06
Hi Bill, I would like the magnify layer to move/follow when I scroll around the image, basically in the visible area of the image. Is that possible?

Thanks again.

Andy
AndyColmes Posted - May 02 2015 : 21:59:46
Thanks again Bill. I will give it a try.

Andy
w2m Posted - May 02 2015 : 10:10:32
Are you saying the position must be within the bitmap? If so you can constrain a magnify layer to always be on the background bitmap:
procedure TForm1.ImageEnView1LayerNotify(Sender: TObject; layer: Integer;
  event: TIELayerEvent);
var
  iRect: TRect;
begin
  { Constrain the position of a magnify layer to the bounds of the bitmap }
  if (event = ielMoving) and (ImageEnView1.Layers[layer].Magnify.Enabled) then
  begin
    if ConstrainMagnifyLayerToBitmap1.Checked then
    begin
      iRect := ImageEnView1.VisibleBitmapRect;
      if ImageEnView1.Layers[layer].PosX + ImageEnView1.Layers[layer].Width > ImageEnView1.Layers[0].Width then
         ImageEnView1.Layers[layer].PosX := ImageEnView1.Layers[0].Width -
            ImageEnView1.Layers[layer].Width;
      if ImageEnView1.Layers[layer].PosX < 0 then
         ImageEnView1.Layers[layer].PosX := 0;
      if ImageEnView1.Layers[layer].PosY + ImageEnView1.Layers[layer].Height > ImageEnView1.Layers[0].Height then
         ImageEnView1.Layers[layer].PosY := ImageEnView1.Layers[0].Height -
            ImageEnView1.Layers[layer].Height;
      if ImageEnView1.Layers[layer].PosY < ImageEnView1.ViewY then
         ImageEnView1.Layers[layer].PosY := ImageEnView1.ViewY;
    end;
  end;
end;


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