Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, June 18, 2008 12:31:01 AM(UTC)
Gunasekaran

Groups: Registered
Posts: 53


Hello,
I am using Leadtool V.15 and medicalviewer demo as my sample....I would like get the measurement unit programmatically..
Dim x1 as integer
Dim x2as integer
Dim y1 as integer
Dim y2 as integer

Step1:  In mousedown event I stored
            X1=e.X and Y1 =e.Y
Step2:  In mouseup event I stored
            X2=e.X and Y2 =e.Y
Step3:
          Formula for converting Pixel to Cm is
          LengthCM = LenghtPixels * 2.54 / DPI
I have calculated LenghtPixels =Abs(X2-X1)*Abs(Y2-Y1) and
for DPI  I have used R_Viewer.ImageDpiX value ....
is it correct?????

 My code for calculating CM ....


   Private Sub _medicalViewer_CustomPaint(ByVal sender As Object, ByVal e As MedicalViewerPaintEventArgs)
            e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
            e.Graphics.DrawLine(Pens.Red, x1, y1, x2, y2)
            _image = _medicalViewer.Cells(0).Image                
                Dim pixel As Integer = Abs(x2 - x1) * Abs(y2 - y1)
                Dim image1 As RasterImage = _medicalViewer.Cells(0).Image
                R_Viewer.Image = image1
                Dim LengthCM As Integer = CType(((CType(pixel, Single) * 2.54) / CType(R_Viewer.ImageDpiX, Single)), Integer)
                MsgBox("LengthCM=" & (LengthCM / 10))
              
              _medicalViewer.Invalidate()
        End Sub

Problem :
1cm value is showing wrongly .

2.While I draw the  next Line ,the first line which was drawn already disappears why? what should i add for consecutive drawing line one after another...

Please solve this probs...
Thanks in advance
Sakthi




 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Wednesday, June 18, 2008 9:11:38 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


1.
Your distance calculation is incorrect.  Here's an explanation of getting the distance between two points:

http://www.purplemath.com/modules/distform.htm

2.
The Graphics object in the CustomPaint event's MedicalViewerPaintEventArgs is used for painting once on top of the viewer.  Therefore, none of the lines or objects you draw onto it will be permanent.  If you are trying to paint multiple lines, you will need to keep track of them and paint them sequentially.  One way to do this would be to make your own Line class and keep an array or LinkedList of Lines and in the CustomPaint event, loop through and draw all of the lines you have added.
 
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.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.193 seconds.