Move image with mouse

corwin42

Expert
Licensed User
Longtime User
Thanks for the example.

I'm currently writing a OpenStreetMap/GoogleMaps Tile viewer. The user should be able to scroll the map around and I'm just thinking about how to do this.

The first problem is that I have not one image but the map is created from many tiles of 256x256 pixels. My thoughts here are that I have one image object for displaying that can be moved around as in your example. If the user releases the mousebutton/stylus then the program rebuilds the content of the display image object by copying the bitmaps of all needed map tiles to the right positions and then center the display image again on the screen. So the user can drag it again.

Does anybody have some other idea on how to glue the map tiles together to a whole image?

Now I have tested your example code with moving a fullscreen size image (240x320 on my device) around with displaying the image while moving. This is far too slow for my application. Are there any hints how to speed this up?

Thanks a lot
Markus
 

Ariel_Z

Active Member
Licensed User
1. Where do you get the images from( file, internet?) Are they saved locally?
2. Speed:
- Did you try to compile? it accelerates things a lot.
- You can try to hide certain parts of the image and move a smaller part - is it feasible in your case?
 

corwin42

Expert
Licensed User
Longtime User
1. Where do you get the images from( file, internet?) Are they saved locally?
The images are stored locally on the device.

I have written a download tool for OpenStreetMap tiles (PDA TileManager) and I want to add a viewer for the downloaded tiles. Tiles not found on disk then should be displayed as a grey box or something.

2. Speed:
- Did you try to compile? it accelerates things a lot.
- You can try to hide certain parts of the image and move a smaller part - is it feasible in your case?
I want to display the map as large as possible and when the user drags the map it should move around the currently visible part of the map

Compiling the test program is not really much better.

Thanks,
Markus
 

Ariel_Z

Active Member
Licensed User
I guess in the meanwhile you can draw blank (white) space on the part of the screen where the user dragged the map from, and right when the map is released you could draw the missing parts. The sample Erel had shown uses FDrawImage, but other drawing methods found in additinal libraries here (I'm not sure which) should be faster, and you can try it later.
 

klaus

Expert
Licensed User
Longtime User
What is the size of your tiles?
Are these all the same size?
How many tiles ?
I want to display the map as large as possible
I'm afraid that you must limit the size, due to memory limits.
and when the user drags the map it should move around the currently visible part of the map
I don't really understand "move around the current visible part", could you be more precise.

Do you want to have parts of different tiles to be copied onto the screen, like GoogleMaps ?

To display maps onto the screen I use the ImageLibEx library.
Where I have:
- maps as jpg files (even different sizes)
- the images are loaded in a BitmapEx object
- with the DrawerEx object I copy onto the form the part of the map I want to display
To manage several side by side maps I load the next map when the cursor reaches the border of a map. I do not display parts of several tiles onto the screen.

Attached a small example on moving an image bigger than the form size.
 

Attachments

  • Graphics2.zip
    124.8 KB · Views: 317

corwin42

Expert
Licensed User
Longtime User
Hi klaus,

thanks for your example. I took it as a base to play around with and I've attached my result to this message.

The program simply glues 9 map tiles of 256x256 pixels together to one image and this is displayed on the screen and can be moved around with mouse/stylus/finger.
I found out that updating UI-Controls in the MouseMove event sub (like displaying the current coordinates in labels) slows down everything a bit. After removing the labels displaying the coordinates the movement with stylus/finger is much smoother. Compiled with the optimizer the speed is really smooth now.

I think this is a base I can work on for my program. Now I have a better understanding of how Image handling and manipulation works in b4ppc.

Thanks very much for your help. This forum is really invaluable.

Markus
 

Attachments

  • MoveMap.zip
    130.4 KB · Views: 321

mjcoon

Well-Known Member
Licensed User
Some time ago I bought shareware GPS mapping program GPSDash (see GPSDash 4 PocketPC).

The relevance is that it offers a map geo-calibration and tiling program that runs on the PC; the tiles are then copied to PPC for display.

Unfortunately I find a number of its moving-map features annoying although it is generally a very polished program. It also appears to be stagnant with no new releases for several years.

But you might find it interesting to download, play with and plagiarise!

Mike.
 

corwin42

Expert
Licensed User
Longtime User
May I ask you where and how you get these 256*256 bit tiles of maps.

They are from the OpenStreetMap Tileserver and I downloaded them with my PDA TileManager.

You can find some URLs of other TileServer on the above Homepage under the "Maps" section.

If you want to know how to calculate the tile numbers look here.

If you have further questions just ask me but I think then we should open a new thread or do this by PM.

Greetings,
Markus
 
Top