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
 Getting Viewed Image Position and Size

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
wshowalter Posted - Oct 07 2014 : 09:12:30
I have what should be a fairly simple question to answer, but I can't seem to tease it out of the forums or help.

I have an image displayed in an ImageEnView component. The user can zoom the image as they choose. I simply want to know what to know what the image coordinates are (X, Y, Width and Height) for what the user is seeing. I can get part of that using the Scr2Bmp( ViewX ), but then there's the OffsetX and ExtentX which confuse the matter.

Can anyone help me?

Wayne
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Oct 09 2014 : 16:22:51
Sorry Wayne,

You are quite right. I neglected to consider images smaller than the view.

In v5.1.2 you can use the VisibleBitmapRect property. It is read and write, so you can also use it to show an area of the image.

Examples

// Show the central portion of an image
ImageEnView1.VisibleBitmapRect := Rect(100, 100, 200, 200);

// Output the visible bitmap in ImageEnView1 to ImageEnView2
ImageEnView2.IEBitmap.Width  := IERectangle( ImageEnView1.VisibleBitmapRect ).Width;
ImageEnView2.IEBitmap.Height := IERectangle( ImageEnView1.VisibleBitmapRect ).Height;
ImageEnView1.IEBitmap.DrawToTIEBitmap( ImageEnView2.IEBitmap, 0, 0, IERectangle( ImageEnView1.VisibleBitmapRect ) );
ImageEnView2.Update;



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
wshowalter Posted - Oct 09 2014 : 08:14:33
Nigel,

Your post lead to my ultimate solution, so thanks. If the image does not fully fit the frame, your equations are not quite correct. I believe this is accurate, though:

function VisibleImageCoordinates( AnImageEnView: TImageEnView ) : TRect;
begin
Result.Left := AnImageEnView.XScr2Bmp( AnImageEnView.OffsetX );
Result.Top := AnImageEnView.YScr2Bmp( AnImageEnView.OffsetY );
Result.Right := AnImageEnView.XScr2Bmp( AnImageEnView.ClientWidth - AnImageEnView.OffsetX ) - 1;
Result.Bottom := AnImageEnView.YScr2Bmp( AnImageEnView.ClientHeight - AnImageEnView.OffsetY ) - 1;
end;

What is returned are the left/top most and right/bottom most pixel indexes in the image, as currently displayed. Very handy. Build this into a future version of TImageEnView?

Cheers,
Wayne Showalter
xequte Posted - Oct 08 2014 : 17:59:54
This is one of those things that seems more complex than it is. To get the visible are of the bitmap you can use:

function TfrmMain.VisibleBitmapRect(aImageEnView : TImageEnView) : TRect;
begin
  Result.Left   := aImageEnView.XScr2Bmp( 0 );
  Result.Top    := aImageEnView.YScr2Bmp( 0 );
  Result.Right  := aImageEnView.XScr2Bmp( aImageEnView.ClientWidth );
  Result.Bottom := aImageEnView.YScr2Bmp( aImageEnView.ClientHeight );
end;


Another example:

  // OUTPUT THE VISIBLE BITMAP IN IEVIEW1 to IEVIEW2

  // Get a rect of the bitmap area showing
  VisibleBmpRect.Left   := ImageEnView1.XScr2Bmp( 0 );
  VisibleBmpRect.Top    := ImageEnView1.YScr2Bmp( 0 );
  VisibleBmpRect.Right  := ImageEnView1.XScr2Bmp( ImageEnView1.ClientWidth );
  VisibleBmpRect.Bottom := ImageEnView1.YScr2Bmp( ImageEnView1.ClientHeight );

  // Draw VisibleBmpRect area of IEView1 bitmap to IEView2 bitmap
  IEView2.IEBitmap.Width  := IERectangle( VisibleBmpRect ).Width;
  IEView2.IEBitmap.Height := IERectangle( VisibleBmpRect ).Height;
  IEView1.IEBitmap.DrawToTIEBitmap( IEView2.IEBitmap, 0, 0, IERectangle( VisibleBmpRect ) );
  IEView2.Update;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Oct 07 2014 : 14:17:20
It sure would be nice if there was a VisibleBitmapLeft, VisibleBitmapTop, VisibleBitmapHeight, and VisibleBitmapWidth values and/or VisibleBitmapRect to precisely return the values which automatically adjusts for zoom.

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