Screenshot request

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
Ruudjah
Engineer
Engineer
Posts: 46
Joined: 12 Nov 2007 11:09

Screenshot request

Post by Ruudjah »

Hi all,

I like to play OTTD. I just think it is a shame that maps on a server just disappear. Some players built really cool maps with great railroad networks. But it gets lost. After the end time is reached, the server generates a new map and all is cleaned. We should be able to view the cool stuff which is made by the users.

I am building a webpage where maps can be viewed from played server maps. So when a server map is done (reached end of time), the idea is that the server then uploads a screenshot to my website. Users there can then view the map. This way, all the precious playing time is coming in to some kind of hall of fame :). Initially, I hope to enable something that allows any server to upload their screenshots to my website.

Development is going great, i now have a webcontrol which displays images of any size, á la google maps. Zooming is supported, which makes it easy to navigate trhough huge (2048x2048) maps. In developing this I created a screenshot of a 256x256 map (ctrl+g), and then manually using Irfanview scaled 4 times to 50%. That makes me having 5 zoom levels. Using the scroll wheel the image then zooms.

However, i got stuck to some limitations. Making a screenshot of a 2048x2048 borad creates a 2 gigapixel image. The webcomponent is perfectly able to view this. The problem however lies in the fact that there is no way of slicing the image down to 256x256 squares: every image editor just crashes due to the enourmous amount of memory needed.

Furthermore, since data traffic is expensive, I do not want server admins to upload an image of several hundreds of megabytes large. A savegame of the last moment is fine to upload to my server. My server then manages the rest, making screenshots & preparing it for the webcontrol.

Also, due to the way I scale my main screenshot, the map looks different than the map in OTTD. This is becuase the zoomlevels in OTTD are rendered themselves, and it is not just a scaled down version of the lowest zoom level.

Since the 'screenshot of the whole map' function works great (in non-multiplayer maps, in multiplayer the games gets out-of-sync, I presume this is due to the non-multithreading of the screenshot code). It would be nice to have a function that also makes a screenshot of the whole map in the three other zoom levels. A screenshot of the 'world view', with the company's colors highlighted would be great to have as the most outer zoom level.

I plan to implement other cool features, such as area highlighting. That way a user on the website is able to mark a selected area, and name it. For example, if a user build a massive 8-laned railroad with a 40x40 station, the users selects the station and marks it as "huge station". Other users then see a link on the website. Clicking it would bring them to the selected area. This is just one of the many ideas I have.

Off course, users would also be able to download the map and continue to play on it.

I hope you find this also cool, and maybe even have time to take a quick look at the OTTD code and tell something whether or not this i easily done or not.

When my personal internetconnection is up again, i will put a preview on the server and post a link here.
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: Screenshot request

Post by Bilbo »

2 gigapixel image requires 6 gigabytes of memory for decompressing. As 32bit operationg systems are unable to handle more than 4 GB or memory (practically even less due to user/kernel split and other things ..), you have to use either 64bit O.S. or resize the bitmap in way so that it won't be loaded in the memory entirely.

I tried once to find a program that can resize and tile images bigger than available physical memory (although I needed it for satellite imagery, not openttd screenshots) and I found nothing.

What may be useful can be "giant" screenshot of the minimap - you get entire minimap saved to a file (which is considerably smaller than regular screenshot, so even 2048 x 2048 minimap will have like 4000x2000 pixels, which is reasonable, but still too large to campture by ordinary means (resizing minimap to entire window and capturing the screen))

Perhaps the "giant minimap screenshot" would solve your problem
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
puukko
Engineer
Engineer
Posts: 3
Joined: 01 Dec 2007 21:07

Re: Screenshot request

Post by puukko »

Hmm, this is a bit odd...
I got roughly same idea today myself and made this little thing:
New console command to export current map in simpilified format (compared to savegames)
Python script that reads trought that simplified data and converts it to image
There are not many features in ottd patch nor python script but I take suggestions and do what I can.
Attachments
ottd_test.png
Sample # 1. Actually one of very first tests.
(187.58 KiB) Downloaded 229 times
ottd_test3.png
Latest version, very much testing limits. Ground colored by height. Signal and signal states marked on railroads and railroads colored by owner.
(86.34 KiB) Downloaded 215 times
ottd_test2.png
Railroad coloring test with AI
(32.13 KiB) Downloaded 193 times
Ruudjah
Engineer
Engineer
Posts: 46
Joined: 12 Nov 2007 11:09

Re: Screenshot request

Post by Ruudjah »

I created two mechanisms of rendering the image server-side. The first is to have a large image, and when the user requests a smaller image (square of256x256px), the server just opens the big image, gets the square which is needed, and posts it back via HTTP. The second one is just simply placing all the image files into one folder, pre-sliced. That means I have around 2048 imagesfor the lowest zoom level. The browser then just requests a certain image with a vertical/horizontal/zoom parameter.

I was thinking yesterday to combine both. Instead of pre-slicing to 256x256px squares, I probably would be able to slice them up to, say, 2048x2048 px images. this makes the files able to handle with off-th-shelf software/libraries. If I would just be able to take screenshots, and save them in 2048x2048 parts... I think it shouldnt be o hard to realize.

Basically, the openttd is doing something like that right now. Somehow it manages to write partial contents to the file, since ottd is able to write a gigapixel image to disk.
Last edited by Ruudjah on 02 Dec 2007 11:13, edited 1 time in total.
Ruudjah
Engineer
Engineer
Posts: 46
Joined: 12 Nov 2007 11:09

Re: Screenshot request

Post by Ruudjah »

puukko,

Definitely a nice try! I may include your screenshots as well in to the webbased screenshot viewer. Would be great to be able to navigate all theway fromthe most outer zoom level (your map) to the details (lowest zoomlevel).
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot] and 23 guests