• Advertisement
Sign in to follow this  

Large Map ...

This topic is 4242 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm writing an 2d MapViewer with VC++ and GDI+ ... The Map is so large ... I just want to know ur technics for displaying this map ... Thanks, Hadi

Share this post


Link to post
Share on other sites
Advertisement
Well, if your map is small enough that it can be stored as an array without using up your all your memory, selecting the portion that is visible for display isn't terribly difficult.

If your map is too big for memory, you'll likely need to employ a spatial subdivision scheme and a method for procedurally generating the map at a particular location when it comes into view. The details of this algorithm will depend entirely on the specifics of what you are trying to do.

Share this post


Link to post
Share on other sites
If your map is grid-based then it is just a matter of
storing the top left corner and drawing only the amount of tiles that
can fit into the screen.

Share this post


Link to post
Share on other sites
Thanks alot for replies ...
Let me test ur ways and I'll write reply ...

Best Regards,
Hadi

Share this post


Link to post
Share on other sites
Hi,

I've 2 other questions about this issue ...

1- In this program the user should be able to Zoom In / Out on the map ...
So , what i need to do more ?!

2- Can do Double-Buffering in GDI+ ?!

Regards,
Hadi

Share this post


Link to post
Share on other sites
Im not an expert, but heres my thoughts...

I think you have to do the double buffering yourself in GDI.
Simply make a bitmap in memory and render all the images and objects to it.
When you are done rendering things on the memory buffer, copy it to the screen with BitBlt or StretchBlt.

Im not sure if double buffering will be of much help if you only copy potions of a static image each frame.

As for zooming, I would consider using the StretchBlt function.

Pseudo code:

...
source_rect.left = current_user_position.x
source_rect.top = current_user_position.y
source_rect.right = current_user_position.x + user_screen_width * zoom;
source_rect.bottom = current_user_position.y + user_screen_height * zoom;
...
StretchBlt(...)


This is a quite simple example though, I suspect there is ways to make zooming look better

[Edited by - pulpfist on July 9, 2006 8:47:24 AM]

Share this post


Link to post
Share on other sites
For the double buffering you can create two
BufferedGraphics classes and do the double buffering your self
ie. Render your graphics to one buffer while displaying the other.

For the scaling you can draw your tiles with a rect larger than the original and the gdi will scale it for you.

Share this post


Link to post
Share on other sites
Hi again and thanks alot for replies ...

Ok, Now I came back from writing the program .
and i think i did it ..

I simply get the area that should be shown on the screen ...
I also used double-buffer ...
and draw the buffer on screen ...

But there is two strange problem ...

1- I've .4 sec delay on displaying each area only in first time ...
It means .. for example if didn't check (see, display) the right-corner of map , it takes time to display that area .. but in second time it displays smoothly ...

2- When i scroll my view fast ... i still see some flickers just in my window border ...

Plz help me ,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement