1,000,000 $ question...answer and win!! :)

Discussion in 'Questions (Windows Mobile)' started by europe, Nov 10, 2008.

  1. europe

    europe Member

    hello and welcome to my 1,000,000 $ question....be the first to answer and win 1,000,000 $ (virtually of course :sign0147:)

    that's the issue:

    I have a form, with an image 1500x500 streched. I'm using ImageScroller from Byak@ and i wrote an easy function to zoom in/out the image (basically add more pixel to the streched image).

    Well, I'd like to make the zoom scrolling the image to the same point at the centre of the screen, so the new zoomed image has the same view centered as the 1:1 image.

    here is the code for explain better; under the code i've linked a pic to show better what i need.

    Sub dzem_MagicEvent ' -----> Byak@ SCROLL IMAGE
    If down=1  Then
    Dim LowWord, HighWord, X, Y
    LowWord = 
    bit.OR2(dzem.lParam, 4294901760)
    X = 
    bit.XOR2(LowWord, 4294901760)
    HighWord = 
    bit.OR2(dzem.lParam, 65535)
    Y = 
    bit.XOR2(HighWord, 65535)/2^16
    Img.Left = Img.Left - (DownX - X)
    Img.Top = Img.Top - (DownY - Y)
    End If
    End Sub

    Sub zoominbtn_Click ' ------> ZOOM IN FUNCTION
    If zoom < 3 AND zoom >= -3 Then
      Img.Width = Img.Width + 
      Img.Height = Img.Height +  
        Img.Left = Img.Left - 
    ' WHICH VALUE!?!?
        Img.Top = Img.Top - ' WHICH VALUE!?!?
    End If
    End Sub

    Sub zoomoutbtn_Click      ' ------> ZOOM IN FUNCTION
      If zoom <= 3 AND zoom > -3 Then
      Img.Width = Img.Width - 
      Img.Height = Img.Height - 
        Img.Left = Img.Left + 
    ' WHICH VALUE!?!?
        Img.Top = Img.Top + ' WHICH VALUE!?!?
    End If
    End Sub

    The grey part is the one i get right now, but i want to get the centered part (what a wonderful nose, uh? :p).

    Any help will be muuuuuch appreciated thanks as always in advance! :sign0060:

    Last edited: Nov 10, 2008
  2. klaus

    klaus Expert Licensed User

    For me the .Left and .Top values should be changed by the half of the values you add or subtract from the width or the height.

    In your case
    Img.Left = Img.Left + 100
    Img.Top = Img.Top + 50

    Img.Left = Img.Left - 100
    Img.Top = Img.Top - 50

    I don't know what to do with 1,000,000 $

    Best regards.
  3. europe

    europe Member

    already tried but when you're at the edge of the img, the zoom will bring you progressivly to the centre of the img; so it's working right only near the centre of the image.....i think I should use some math functions...but which one :confused:
  4. klaus

    klaus Expert Licensed User

    You are right, I didn't look at depp enough.

    You should use following formulas.

    Old coordinates of screen midle
    x = Img.Left + HalfScreenWidth
    y = Img.Top + HalfScreenheight

    New coordinates of screen middle
    x = x * Img.WidthNew/Img.WidthOld
    y = y * Img.HeightNew / Img.HeightOld

    Img.Left = x - HalfSrceenWidth
    Img.Top = y - HalfScreenHeight

    The principle doesn't work when unzooming and the screen is neer the left and or the top.

    Best regards.
  5. europe

    europe Member

    thanks klaus, seems to work fine, now i'll try to fix the unzoom function...
  6. europe

    europe Member

    hey klaus works for the unzoom too...i modify some value and now works great thanks!

    as promised...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice