LEADTOOLS Support
Imaging
Imaging SDK Questions
Physical X,Y coordinates of a rectangle using RasterViewerInteractiveMode.
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, August 17, 2006 10:30:15 AM(UTC)
Groups: Registered
Posts: 15
I am developing an application in vb.net 2.0 with the raster imaging tools v14.5 where I need to use (and subsequently store) a drawn rectangles physical X,Y pixel coordinates as opposed to the coordinates relative to the control/screen. These values are needed to pass to a document management system. I have racked my brain trying to figure it out and am sure I am missing something very simple. Thanks in advance!
#2
Posted
:
Tuesday, August 22, 2006 4:02:24 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
Hello,
LEADTOOLS Raster Imaging SDK
alone (without Raster Imaging Pro .NET) does not contain .NET classes.
If you are using it, this means you are using the Main OCX. If that's
the case, you can use the ClientToBitmap method to do the conversion
from Control coordinates to Physical (Bitmap pixel) coordinates.
If that's not what you're trying to do, please explain it in more detail.
Thanks,
Maen Badwan
LEADTOOLS Technical Support
#3
Posted
:
Tuesday, August 22, 2006 4:33:29 AM(UTC)
Groups: Registered
Posts: 15
My fault, we are using the Raster Imaging Pro .NET, selecting a region using the following and needing the physical coordinates of the rectangle -
RasterImageViewer1.InteractiveMode = Leadtools.WinForms.RasterViewerInteractiveMode.Region
RasterImageViewer1.InteractiveRegionType = Leadtools.WinForms.RasterViewerInteractiveRegionType.Rectangle
Thanks!
#4
Posted
:
Thursday, August 24, 2006 3:06:26 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
Hello,
You may try to use the following code to translate the rectangle coordinates to physical coordinates:
+------------------------------+
Rectangle Rect = new Rectangle(0,0,100,100);
Transformer trans = new Transformer(rasterImageViewer1.Transform);
RectangleF RectF = new RectangleF(Rect.X,Rect.Y,Rect.Width,Rect.Height);
RectF = trans.RectangleToPhysical(RectF);
+------------------------------+
Please let me know if this helps.
Thanks,
Maen Badwan
LEADTOOLS Technical Support
#5
Posted
:
Thursday, August 24, 2006 6:35:46 AM(UTC)
Groups: Registered
Posts: 15
Thanks for the reply but unfortunately that did not do the trick and maybe I'm not explaining it very well. I need to design an application where the user selects certain fields off of a scanned form and the locations of those fields are then stored in a table that is later used as a template by a document management system. The document management system then takes all 'like' forms and strips portions of the images based on the coordinates that the user selected with my application. When the user selects the rectangle, I need the actual coordinates and not relative coordinates to zoom, size of window, etc. Maybe I'm reading this wrong but when I apply the above transformation to the drawn rectangle, I still get a position returned that is relative to how the image is being displayed. I have to be missing something extremely simple here as the standard VS2005 PictureBox control returns the physical coordinate.
Here is the code I'm using
(Loading Image)
Dim codec As RasterCodecs = New RasterCodecs
Dim image As IRasterImage = codec.Load(strImagePath)
Dim info As CodecsImageInfo = codec.GetInformation(strImagePath, True)
RasterImageViewer1.Image = image
RasterImageViewer1.SizeMode = RasterViewerSizeMode.Fit
RasterImageViewer1.InteractiveMode = Leadtools.WinForms.RasterViewerInteractiveMode.Region
RasterImageViewer1.InteractiveRegionType = Leadtools.WinForms.RasterViewerInteractiveRegionType.Rectangle
AddHandler RasterImageViewer1.InteractiveRegionRectangle, New RasterViewerRectangleEventHandler(AddressOf rasterImageViewer1_InteractiveRegionRetangleRgnRect)
And the event handler for the drawn rectangle -
Private Sub rasterImageViewer1_InteractiveRegionRetangleRgnRect(ByVal sender As System.Object, ByVal e As RasterViewerRectangleEventArgs)
If e.Status = RasterViewerInteractiveStatus.End Then
If e.Rectangle.IsEmpty() = False Then
SelectedRect = e.Rectangle
tbLeft.Text = SelectedRect.X
tbTop.Text = SelectedRect.Y
tbBottom.Text = SelectedRect.Y + SelectedRect.Height
tbRight.Text = SelectedRect.X + SelectedRect.Width
Dim trans As New Transformer(RasterImageViewer1.Transform)
Dim RectF As New RectangleF(SelectedRect.X, SelectedRect.Y, SelectedRect.Width, SelectedRect.Height)
RectF = trans.RectangleToPhysical(RectF)
MsgBox(RectF.X.ToString & "," & RectF.Y.ToString & "," & RectF.Top.ToString & "," & RectF.Bottom.ToString)
End If
End If
End Sub
Any help is greatly appreciated on this!
#6
Posted
:
Sunday, August 27, 2006 3:11:35 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
Hello,
If you want the actual pixels coordinates regardless of zooming or scrolling,try to use the trans.RectangleToLogical(RectF) instead of trans.RectangleToPhysical(RectF) in your code.
Please let me know if this helps.
Thanks,
Maen Badwan
LEADTOOLS Technical Support
LEADTOOLS Support
Imaging
Imaging SDK Questions
Physical X,Y coordinates of a rectangle using RasterViewerInteractiveMode.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.