Download the free trial version
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

Move image with mouse

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-31-2009, 11:05 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 12,926
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default Move image with mouse

The attached code draws an image on the form's fore layer which can be moved by dragging the image with the mouse (or pen).

Edit: Missing image file added.
Attached Files
File Type: zip MovingImage.zip (3.5 KB, 213 views)
__________________
Basic4android documentation
Reply With Quote
  #2 (permalink)  
Old 11-02-2009, 08:59 AM
Basic4ppc Veteran
 
Join Date: Jul 2008
Location: Borchen, Germany
Posts: 420
Send a message via ICQ to corwin42
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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
Reply With Quote
  #3 (permalink)  
Old 11-02-2009, 09:20 AM
Ariel_Z's Avatar
Basic4ppc Veteran
 
Join Date: May 2009
Posts: 246
Default

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?
Reply With Quote
  #4 (permalink)  
Old 11-02-2009, 10:01 AM
Basic4ppc Veteran
 
Join Date: Jul 2008
Location: Borchen, Germany
Posts: 420
Send a message via ICQ to corwin42
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by Ariel_Z View Post
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.

Quote:
Originally Posted by Ariel_Z View Post
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
Reply With Quote
  #5 (permalink)  
Old 11-02-2009, 02:13 PM
Ariel_Z's Avatar
Basic4ppc Veteran
 
Join Date: May 2009
Posts: 246
Default

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.
Reply With Quote
  #6 (permalink)  
Old 11-04-2009, 01:34 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,759
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

What is the size of your tiles?
Are these all the same size?
How many tiles ?
Quote:
I want to display the map as large as possible
I'm afraid that you must limit the size, due to memory limits.
Quote:
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.
Attached Files
File Type: zip Graphics2.zip (124.8 KB, 73 views)
__________________
Klaus
Switzerland
Reply With Quote
  #7 (permalink)  
Old 11-05-2009, 10:51 AM
Basic4ppc Veteran
 
Join Date: Jul 2008
Location: Borchen, Germany
Posts: 420
Send a message via ICQ to corwin42
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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
Attached Files
File Type: zip MoveMap.zip (130.4 KB, 79 views)
Reply With Quote
  #8 (permalink)  
Old 11-05-2009, 11:56 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 754
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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.
Reply With Quote
  #9 (permalink)  
Old 11-17-2009, 03:55 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,759
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Markus,
May I ask you where and how you get these 256*256 bit tiles of maps.

Tank you in advance and Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #10 (permalink)  
Old 11-17-2009, 05:10 PM
Basic4ppc Veteran
 
Join Date: Jul 2008
Location: Borchen, Germany
Posts: 420
Send a message via ICQ to corwin42
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by klaus View Post
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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
AutoScaled Mouse X and Y not integers agraham Bug Reports 7 07-30-2009 10:03 AM
Mouse OutSide A Form eww245 Questions (Windows Mobile) 9 07-15-2009 07:27 AM
getting mouse coordinates enonod Questions (Windows Mobile) 8 06-28-2009 08:10 PM
Image Mouse events LineCutter Basic4ppc Wishlist 1 05-19-2007 11:24 AM
Move an image inside an image control Cableguy Questions (Windows Mobile) 5 05-14-2007 08:40 PM


All times are GMT. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0