Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2004

    Tracking bitmap coordinates

    I'm trying to implement an image viewer (that has zooming and panning capabilities) where I can place a "dot" or some sort of graphics thing over a specific part of the bitmap.

    Of course if the image was only as big as the viewer, this would be easy (just drawing based on the window coordinates).. but since I'm supposed to support zoom and panning, I need information about the bitmap's coordinates in order to have the drawing on the bitmap to stay on the same place (and to know whether to display it or not when panning through a larger version of the image).

    Does anyone know of any way to do this, or if there's a class other than CPAlbImageViewerBasic that can achieve this?

    In Java, I managed to do this with Layer Managers, since those classes kept track of both the coordinates in the canvas and the coordinates of the window. Does Symbian C++ have something similar?


  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003

    Easiest way is to have the image in its full size, then just use standard draw methods of the gc (see any example's Draw() function for how to get the gc).

    The class basically offers functions where you can specify the area of the image and the area in the screen where it is to be drawn, so all zooming stuff is done automatically.

    Then you just need to keep track on the are which is currently on the screen and put your dots there. Shouldn't be too hard math really.


  3. #3
    Registered User
    Join Date
    May 2004
    That's what I was trying to avoid - but it seems like I'll have to implement something like that anyway.

    The problem still is, though, that the class doesn't offer an observer method that tells me where the Panning center is - it merely has a SetPanningCenter, but no GetPanningCenter.

    The only solution I have thought of so far is to start with the image centered at the dot, and every time the user pans left or right, move the dot the same amount as the pan. This, however, messes up whenever a zoom in or zoom out operation is done *unless* I reset the Panning Center to the dot once again.

    One cool thing I found was that CPAlbImageViewerBasic keeps consistent map coordinates throughout scaling - that is, point (x,y) at a certain zoom ratio corresponds to the same point (x,y) at any other zoom ratio. Unfortunately, there seems to be no method to simply draw at that point, since gc's draw method is relative to the window and not the canvas. And there seems to be no easy math way of doing this because I can't find an observer method that tells me where the current window is at in relation to the canvas.

    Thanks for the suggestions though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts