Home » Category » Microsoft Visual Basic

Microsoft Visual Basic: Zoom in Cephalometric system

205| Thu, 22 May 2008 01:23:00 GMT| anonymous| Comments (1)
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

Keywords & Tags: zoom, cephalometric, system, microsoft, visual basic, vb

URL: http://www.programmerbase.com/visual-basic/560738/
 
«« Prev - Next »» 1 helpful answers below.
Ricardo Furtado wrote:
> 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

If you work in a world-space then the positions of the dots are always the
same.
Transform from world-space to screen-space when you display it, and have a
reverse transformation from screen-space to world-space for identifying
where the user clicked.

> 'And this function is used to reposition the dots (point) on the
> screen Friend Overloads Sub RedefinePontosAdicao(
<snip>
> '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

Surely that should be UBound(ArrayPontos) without subtracting 1?

I suspect you aren't taking into account the origin when you're scaling.

It would be easier if you put screen grabs of what happens and what you want
to happen on a web page somewhere so we can see what's going wrong.

Andrew

andrew | Thu, 22 May 2008 01:24:00 GMT |

Microsoft Visual Basic Hot Answers

Microsoft Visual Basic New questions

Microsoft Visual Basic Related Categories