Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: how to display measurement unit programmatically
Started by Gunasekaran at 06-18-2008 5:36. Topic has 1 replies.

Print Search « Previous Thread Next Thread »
  06-18-2008, 5:36
Gunasekaran is not online. Last active: 11/17/2008 9:47:55 AM Gunasekaran



Top 25 Posts
Joined on 05-07-2008
Chennai,India
Posts 171
how to display measurement unit programmatically
Reply Quote
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





Thanks and Regards
Guna
   Report 
  06-18-2008, 14:16
GregR is not online. Last active: 11/17/2008 11:10:19 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,706
Re: how to display measurement unit programmatically
Reply Quote
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.

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » DICOM/Medical I... » Re: how to display measurement unit programmatically

Powered by Community Server, by Telligent Systems