G
Guest
I've been with a problem for about two months and i've bought books and
search the internet for an explanation, and haven't found one.
I'm developing a cephalometric software, that needs to capture an image from
the scanner, mark the image with dots in order to find distances and angles.
Everything is ok except when i try to zoom in/zoom out the image. Every
calculated angle and distance becomes variable because when i use the zoom
the dots have to be repositioned on the image, acording to the pacient face
I'm using a "picturebox" and the "Zoom" value in the "SizeMode" property
when i try to zoom in i'm using the following code on the button:
Private Sub ZoomIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomIn.Click
Dim intWidthAnterior As Integer, intWidthPosterior As Integer
Dim intHeightAnterior As Integer, intHeightPosterior As Integer
Dim sngDpiX As Single, sngDpiY As Single
Dim g As Graphics = picDraw.CreateGraphics
sngDpiX = g.DpiX
sngDpiY = g.DpiY
intWidthAnterior = picDraw.Width
intHeightAnterior = picDraw.Height
picDraw.Width = picDraw.Width * 1.2 'Here i'm making the
picturebox larger
picDraw.Height = picDraw.Height * 1.2 'Here i'm making the
picturebox larger
intWidthPosterior = picDraw.Width
intHeightPosterior = picDraw.Height
MainDrawPics.RedefinePontosAdicao(intWidthAnterior,
intHeightAnterior, intWidthPosterior, intHeightPosterior, picDraw, sngDpiX,
sngDpiY)
picDraw.Refresh()
End Sub
'And this function is used to reposition the dots (point) on the screen
Friend Overloads Sub RedefinePontosAdicao(ByVal intWidthPictureBoxAnterior
As Integer, ByVal intHeightPictureBoxAnterior As Integer, _
ByVal
intWidthPictureBoxPosterior As Integer, ByVal intHeightPictureBoxPosterior As
Integer, _
ByVal picDesenho As
System.Windows.Forms.PictureBox, ByVal sngDesenhoDpix As Single, _
ByVal sngDesenhoDpiy As Single)
Dim intContador As Integer
Dim intResultado As Integer
Dim sngFactor As Single = 1.2
'I have an array with all the dots that have been marked on the patient
face, and this procedure
'tries to reposition the dots on the screen in order to show the
user the place where he clicked
'but in a larger scale
For intContador = 0 To UBound(ArrayPontos) - 1
intResultado = CInt(ArrayPontos(intContador).lngValorX *
sngFactor)
ArrayPontos(intContador).lngValorX = intResultado
intResultado = CInt(ArrayPontos(intContador).lngValorY *
sngFactor)
ArrayPontos(intContador).lngValorY = intResultado
Next
End Sub
I'm really desperate!
My thanks in advanced
search the internet for an explanation, and haven't found one.
I'm developing a cephalometric software, that needs to capture an image from
the scanner, mark the image with dots in order to find distances and angles.
Everything is ok except when i try to zoom in/zoom out the image. Every
calculated angle and distance becomes variable because when i use the zoom
the dots have to be repositioned on the image, acording to the pacient face
I'm using a "picturebox" and the "Zoom" value in the "SizeMode" property
when i try to zoom in i'm using the following code on the button:
Private Sub ZoomIn_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ZoomIn.Click
Dim intWidthAnterior As Integer, intWidthPosterior As Integer
Dim intHeightAnterior As Integer, intHeightPosterior As Integer
Dim sngDpiX As Single, sngDpiY As Single
Dim g As Graphics = picDraw.CreateGraphics
sngDpiX = g.DpiX
sngDpiY = g.DpiY
intWidthAnterior = picDraw.Width
intHeightAnterior = picDraw.Height
picDraw.Width = picDraw.Width * 1.2 'Here i'm making the
picturebox larger
picDraw.Height = picDraw.Height * 1.2 'Here i'm making the
picturebox larger
intWidthPosterior = picDraw.Width
intHeightPosterior = picDraw.Height
MainDrawPics.RedefinePontosAdicao(intWidthAnterior,
intHeightAnterior, intWidthPosterior, intHeightPosterior, picDraw, sngDpiX,
sngDpiY)
picDraw.Refresh()
End Sub
'And this function is used to reposition the dots (point) on the screen
Friend Overloads Sub RedefinePontosAdicao(ByVal intWidthPictureBoxAnterior
As Integer, ByVal intHeightPictureBoxAnterior As Integer, _
ByVal
intWidthPictureBoxPosterior As Integer, ByVal intHeightPictureBoxPosterior As
Integer, _
ByVal picDesenho As
System.Windows.Forms.PictureBox, ByVal sngDesenhoDpix As Single, _
ByVal sngDesenhoDpiy As Single)
Dim intContador As Integer
Dim intResultado As Integer
Dim sngFactor As Single = 1.2
'I have an array with all the dots that have been marked on the patient
face, and this procedure
'tries to reposition the dots on the screen in order to show the
user the place where he clicked
'but in a larger scale
For intContador = 0 To UBound(ArrayPontos) - 1
intResultado = CInt(ArrayPontos(intContador).lngValorX *
sngFactor)
ArrayPontos(intContador).lngValorX = intResultado
intResultado = CInt(ArrayPontos(intContador).lngValorY *
sngFactor)
ArrayPontos(intContador).lngValorY = intResultado
Next
End Sub
I'm really desperate!
My thanks in advanced