PDA

View Full Version : The png to KoH map-converter


Mephistopheles
30 Dec 2007, 20:02
Hello.

Back on the Sunflowers-forum I tinkered around with the KoH map-format and came up with the idea of making a little program to do some of the mapping-stuff automatically.
I rested the idea when I thought no one was interested, but a few days ago Doux asked me about it and thus I picked the gauntlet up again.

It's slightly complicated, but I'll show you what the program does with pictures.
Steps to get a europe-map:
1. Download this (http://www.filefront.com/16873589/KoHmapConv.zip) zip-archive and extract it somewhere, e.g. the KoH-folder.
2. Draw a map in some imaging-program of the resolution 1792x1792 (that's the internal 'resolution' of the KoH europe-map). On my laptop I only had a touchpad and MS paint, so I came up with this (http://img89.imageshack.us/my.php?image=uselessjk2.png) pretty uninsipiring replacement for a map. Make sure you save the result as a .png file. It's the only supported format for now. I plan to add more later on.
3. Doubleclick KoHmapConv.jar in the folder where you extracted the contents of the provided .zip-archive. If you have the java runtime-enviroment the program should start.
4. Click "browse" and select the map file you created. The program will show a preview of the file you selected. This sometimes takes a few seconds.
5. Click the button "textures.dt". The program now checks the image-file on wether it's suitable to be converted and then writes the textures.dt-file to the same folder as the image-file was stored in.
6. Copy the new textures.dt-file over the original one (e.g. after having copied "\maps\europe" to "\maps\Temps\europe" so you can edit the europe-map).
(How to use textures.dt-files isn't the topic of this thread. If you'd like to learn about it, create a new one, please.)
With the map I used above the result looks like this (http://img142.imageshack.us/my.php?image=resultag3.png). Compare the original png-file with the mini-map to see the result.
Earlier during development I tinkered around with "tiny" maps. Here are two shots that show that the program is very powerful: The source-map (http://img293.imageshack.us/my.php?image=englandrv9.png) and the converted KoH-map (http://img142.imageshack.us/my.php?image=resultenglandpq6.png). I'll get back to variable map-sizes once I can put some time into more fancy algorithms.

Restrictions:
- The only supported colors in the converter are green (rgb code 0,255,0) for gras, white (rgb 255,255,255) for snow and blue (0,0,255) for dirt. Unfortunately placing water is very complex in KoH because shores also need to be placed accordingly. To avoid that I place dirt. Later you can manually replace the dirt-areas with water in the KoH-editor.
If I ever understand how to place water and shores properly I'll change this problem as soon as possible.
The program will abort when it finds any other colors than these three. So please don't use interpolation-algorithms when you scale an original map as the converter will become confused and stop working when it finds any other colors.
- I'd like to generate terrain.dt from a heightmap later on, so you can use real geological height-data for your KoH map. That feature isn't implemented yet though.
- There are propably several major bugs left and I'm still a novice on java-program distribution, so it may happen that not everyone will be able to open the application right away. Please report any issues so I can sort them out.

Tips:
- Use a real map in a layer-based image-manipulation program like photoshop and draw your map in a second layer on top of it.
- Use snow to denote specific locations, like towns, or province borders.
- Use the finished map to create the political map etc. It's guaranteed to be pixel-by-pixel-perfectly identical to the KoH-map.

I hope some of you will have a lot of fun with this. :)

seloman
30 Dec 2007, 20:59
sorry I don't open this java file :cry: look this
http://img91.imageshack.us/img91/2166/adszih5.th.png (http://img91.imageshack.us/my.php?image=adszih5.png)

Mephistopheles
30 Dec 2007, 21:39
Well, as you might have guessed yourself that screenshot doesn't help very much pinning down the problem. Can you tell me what it says when you click on the Details-button?

[Edit]
Ah, I noticed that I had the tools-folder placed in c:\ and that allowed the program to work. I will upload a repackaged version that'll be fixed soon.

Mephistopheles
30 Dec 2007, 21:58
I fixed the typing error above now: Here (http://rapidshare.com/files/80145054/KoHmapConv.zip.html) is the second go.
Please report any problems. :)

Mephistopheles
31 Dec 2007, 00:39
Here's the third (http://rapidshare.com/files/80177002/KoHmapConv.zip.html) version of the day, now with support for .png files with an alpha-channel.

Hopefully that was the last major problem for a while.
By the way, here (http://img165.imageshack.us/my.php?image=gbirelb7.png) is a nice little map of the british isles to toy around with. The converter puts it into KoH nicely now.

seloman
31 Dec 2007, 10:05
Thanks my bro I am download the fixed and your program is working :D

Mephistopheles
31 Dec 2007, 15:09
Great. As said, this was the first Java-program I ever published, so I wasn't really sure on how to compose .jar files.

If any of you also tried this program and it worked, please report. If yesterday's build number 3 works as intended I can call that version 0.1 and start moving on by user-request.

wangyushi
1 Jan 2008, 14:43
Great! Build number 3 worked, but it ofen said Non-corret colors! I don't know how to solve it.

seloman
1 Jan 2008, 15:58
So sorry my bro I am making a new map and create a textures.dt but I don't understand this files upload location :cry: I make upload this old scenarios map but don't show my map in game :cry:

Mephistopheles
1 Jan 2008, 20:32
@Wangyushi:
You may only use the three colors stated above: (0,0,255), (0,255,0) and (255,255,255) - that's pure blue, pure green and pure white. Any other colors will cause the program to abort.
Many imaging-programs create nice transition-effects to make pictures appear smooth, however, in doing so they introduce new colors beside the three above. If you think that's the cause of your problems, here a hint: A technique I use to create maps for the converter is coloring a historical map in the three colors, then changing the RGB-image to an indexed colortable with 3 entries. After that I switch it back to RGB and substitute the colors the program chose for the three color entries with the three valid colors.
If you really don't know what I mean with that, upload the file you're trying to convert to imageshack. I'll explain what exactly is wrong then.

@Seloman:
Unfortunately you're not using the world 'to upload' correctly and I can't decipher what you want to ask. If I had to guess I'd say you want to know where you have to place the textures.dt-file. In that case, please read the map-editor thread here (http://forums.blackseastudios.com/showthread.php?t=71). The generated file isn't meant to be played directly, it's meant to be used as a basis to create a map on.

wangyushi
2 Jan 2008, 04:35
Thank you, Mephistopheles!

http://img216.imageshack.us/img216/1466/shot0024rs2.th.jpg (http://img216.imageshack.us/my.php?image=shot0024rs2.jpg)

seloman
2 Jan 2008, 12:51
Mephistopheles I make be enunciative of my problem with photos :D

step 1 (http://img211.imageshack.us/img211/7710/22561588yd0.png)
step 2 (http://img266.imageshack.us/img266/9222/18359861uu1.png)
step 3 (http://img266.imageshack.us/img266/6734/32231567qm1.png)

Mephistopheles
2 Jan 2008, 13:36
@Seloman:
The generator produces a textures.dt-file of the dimensions of the europe-map (1792*1792 tiles). You tried to copy it into the folder of a much smaller map. That way the dimensions of the map don't fit what KoH expects.
Here's what I did to show the generated textures.dt in the KoH map-editor:
1. Make sure europe.pak is extracted with pakman.
2. Copy the folder "maps/europe" to "maps/Temps/europe". The europe-folder should be right next to your other maps now.
3. Copy the new generated textures.dt file to "maps\Temps\europe\map\textures.dt"
4. Start KoH and open the map "europe" to see the results.
(5. Using this sequence you'll still have the provinces from the original map and a lot other stuff on the map. You'll have to remove them. It's however the most convinient sequence I could come up with.)

On your screenshots I saw that you already created a custom map called europe. To avoid any problems please delete it before you copy the original europe-map over (in step 2).

Also, a little hint: Don't use an online-translator. Rather try to express what you want to ask in simple words. That'll be a lot easier to understand. Even if it won't be gramatically correct, it'll at least make some sort of sense.

seloman
2 Jan 2008, 18:14
thanks my bro very very much :D
Where is the change our Royal Courts names files for our custom maps ? :D:D

IWM
7 Jan 2008, 15:58
Thank you Mephy for this tool!! It would be help very much (Unfortunately I can only experiment in the weekend...)

BTW this is I.W.M.

Doux
7 Jan 2008, 23:21
'Tis a very magnificent tool indeed. I'm glad that you took the time publishing it.

Marty
29 Apr 2008, 16:23
When I click KoHmapConv it doesn't respond at all or give me this message:
"Unable to launch the application"
Details:
MissingFieldException[ The following required field is missing from the launch file: <jnlp>]
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescript or(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescript or(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescript or(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

EDIT: Magically started working :)

elvain
21 Jun 2008, 12:31
ooops, I completely missed this thread... it was alive when I was too busy to care about KOH map making.. and I already had my map done. anyway, just a question, Meph, before I start using it (waiting for free download), do you think it might be possible to make a map larger than "europe-map"?

Mephistopheles
21 Jun 2008, 14:59
I toyed around with "supersized" maps, but KoH crashes frequently when the map is bigger than the current europe-map.

elvain
22 Jun 2008, 02:21
thanks, so I will better just finnish the middle east map and see what's possible later

Dahaka
8 Feb 2009, 01:37
Man! Its so hard ;( why just someone cant create +50 provinces +10 new units and that would be enough for me. ;D

Mephistopheles
8 Feb 2009, 17:38
Unfortunately there are still many unknown things regarding KoH file formats. Thus we must rely on the inbuilt KoH editor which is only in a beta status and thus difficult to operate. That impedes development of new maps a lot.

If it helps anyone making a new map I'd still offer to implement necessary features.
I have partial data on the heightmaps in terrain.dt and shore-lines. I however have no idea how provinces work. I think I'd need some information from the developers on this.

Maybe next month I'll modify the map-converter to create maps of other dimensions (much smaller than the KoH map). That could motivate some people to make new maps. I've been looking for some coding-related project anyway.

Dahaka
15 Feb 2009, 19:41
I have changed units squad size, their cost, morale, even changed that peasents require inn and granary ;) changed some flags, novgord, sweaden, norway, england, normandy, lithuanians and so on, but how to create my own flag ornament?

Doux
15 Feb 2009, 22:00
but how to create my own flag ornament?Double post -> http://forums.blackseastudios.com/showthread.php?p=12719#post12719 .

Laudan
5 Mar 2009, 07:33
Yesterday i start to create a new scenario.


http://img175.imageshack.us/img175/4184/25520896.jpg (http://img175.imageshack.us/my.php?image=25520896.jpg)


Mephistopheles, you create a nice tool. Thanks for that. With your tool i can finished the scenario very fast.

Mephistopheles
5 Mar 2009, 12:35
You're welcome.

Remember that you can draw white lines of snow to e.g. mark down province borders even before you start editing the map by hand. That way you can generate the bmp-files for the political view much more easily from the original png file.

maks
6 Mar 2009, 22:58
Yesterday i start to create a new scenario.


http://img175.imageshack.us/img175/4184/25520896.jpg (http://img175.imageshack.us/my.php?image=25520896.jpg)

Oh, this looks promising in my eyes. Do you think Archbishopy of Canterbury will work as the local Papacy?

Laudan
7 Mar 2009, 01:38
http://img150.imageshack.us/img150/7726/68787237.jpg (http://img150.imageshack.us/my.php?image=68787237.jpg)

My work goes on.

Remember that you can draw white lines of snow to e.g. mark down province borders even before you start editing the map by hand. That way you can generate the bmp-files for the political view much more easily from the original png file.

Thanks for the hint.

Do you think Archbishopy of Canterbury will work as the local Papacy?

I must test it later.

Marty
12 May 2009, 19:03
I can't get the converter to work.
When I double-click the file (KohMapConverter or whatever it's called) it doesn't do anything at all...
I have reinstalled the latest Java so that can't be the problem.

Mephistopheles
12 May 2009, 19:32
Which file exactly did you doubleclick?

Apparently rapidshare changed their uploading policy and the file appears to be unavailable. I'll try asking GogoT to host it at http://knights-of-honor.freehostia.com . Stay tuned.

[Edit] Oh, I'll have to look somewhere else. GogoT actually just hotlinks to other people's webspace on his website. If anyone wants to host the MapConverter, please contact me via forum PM.

Marty
12 May 2009, 20:03
I double clicked the Executable Jar File named KoHmapConv

Bulgaroktonos
12 May 2009, 20:48
@Mephistopheles : Why don't you just upload it on filefront ?

Mephistopheles
12 May 2009, 20:52
Interesting.

Let's go down from the top since you didn't supply many details in your original report (I didn't care to go into more detail before, because I thought you were handling the "This file is not available"-html file off rapidshare that my browser attempts to download :) ):
- Did you unzip the zip-archive completely into a directory?
- If you run the Taskmanager via Ctrl+Alt+Del and then start the MapConverter, does java launch? (On my Windows Xp system the launched process is called "javaw.exe", though this may differ for other operating systems.)

Let's see how far this gets us. I'm sorry the program doesn't work nicely for you. Hope we can fix it soon. :)

[Edit]
@Bulgaroktonos: Up to now I've used a freehoster that used to work well for years and that stopped working. Also, Filefront itself has been in rather large troubles and seemingly temporarily announced it's shutting down for the 30th of march (I was suprised to see it's still there!). To sum it all up, I'd like to move the MapConverter somewhere where it is unlikely to go down again for quite a while. And that's not a freehoster.

Marty
12 May 2009, 21:10
To go into detail:
- I did unzip the archive (to desktop and pasted it into C:/Program Files/Knights of Honor/
- It doesn't start any processes when I try to start it.

Thanks very much for try to help me so far!

Mephistopheles
12 May 2009, 21:49
That's a real bummer. I'm sure we're overlooking something basic. If Java was started and encountered a problem after attempting to launch the application it would surely notify you via an error-message.
Are you sure the .jar file is connected to the correct application in Windows? On my system it's launched by "C:\Program Files\Java\jre6\bin\javaw.exe" -jar "%1" %* (I found that in explorer via Extras -> Folder options -> File types -> jar -> Advanced -> Edit action "open").

I'm quickly running out of ideas. The problem is that my application is never launched, so e.g. putting debug statements in the sourcecode wouldn't help anything. Unfortunately I also have very few experience with distributing java applications.

Marty
12 May 2009, 23:09
I noticed Windows was blocking some Java stuff from launching, but this wasn't the case with javaw.
I did this:
Are you sure the .jar file is connected to the correct application in Windows? On my system it's launched by "C:\Program Files\Java\jre6\bin\javaw.exe" -jar "%1" %* (I found that in explorer via Extras -> Folder options -> File types -> jar -> Advanced -> Edit action "open").
But that's actually like yours and it still doesn't work.
We're probably overlooking a really simple solution >_<

Anyways, if it won't open, it won't and that's that. I'll have to live without it :P
*continues with his Sicily save*

Doux
14 May 2009, 23:14
Did you try starting the package (or the java exe + package) from the command prompt to see if it gives any messages?

Edit: I have seen a program break because of a java update. I have no idea whether this be the case though.

Marty
15 May 2009, 09:34
Did you try starting the package (or the java exe + package) from the command prompt to see if it gives any messages?

Edit: I have seen a program break because of a java update. I have no idea whether this be the case though.

No, I haven't tried starting anything from the command prompt, but I don't know how that works either :P

Mephistopheles
21 May 2009, 01:02
Well, since I still have no idea where else to upload the file, here (http://files.filefront.com/KoHmapConvzip/;13786319;/fileinfo.html) is the link to the file at filefront.com.

Marty
22 May 2009, 21:35
I downloaded and unpacked it again, and now it works :eek: :cry: :crushed:
Thanks for your help Mephistopheles (nice name, by the way)

EDIT: I tried to process texture.dt for this (http://img190.imageshack.us/img190/298/koh5.png) picture, but it stalls and gives this message: Non-correct colors! Pixel (478,999) is non-valid! But the pixel is rgb 0,0,255, so it can't be the wrong color O_o, or so would a novice like me think.

Mephistopheles
27 May 2009, 01:42
I quickly took a look at (478,999) and apparently that pixel has the color code (0,0,254). Almost, but not quite. :)
Unfortunately there're quite a few more pixels with that almost blue color code...

I'm glad it works for you now. :go:

Marty
27 May 2009, 10:11
Okay, thanks for looking at it!
I'll get a new picture editing program and I will try to hunt down all (0,0,254)'s and turn them in to pure-blue (0,0,255)'s!

EDIT: It worked! It worked! I replaced all the (0,0,254)'s with (0,0,255)'s with GIMP and it did it!

Mephistopheles
27 May 2009, 13:10
Congratulations! :go:
Have fun editing your map. :)

IWM
3 Sep 2009, 12:14
- I'd like to generate terrain.dt from a heightmap later on, so you can use real geological height-data for your KoH map. That feature isn't implemented yet though.


Has it now? >_>


Edit: Can't download the file.
File not found.

Mephistopheles
3 Sep 2009, 13:32
There was no interest in that feature, so I didn't put any work into it.
If there was a specific project going on I'd perhaps be inclined to support it by adding this feature. Otherwise I don't want to waste my time though.

IWM
3 Sep 2009, 13:49
Well, if there is THAT feature, it would help me making maps...

I want to make SEA maps! It would be glorious! Jihad against the European invaders!!!!

Bulgaroktonos
3 Sep 2009, 21:12
:sign: could you please stop about this jihad thing and arrive in the 21th century. Thanks.

Anyway such a tool would help me a lot. :go:

IWM
4 Sep 2009, 11:34
Nah, I was talking about 13th century-dwellers, thank you :D

After all, there was a Jihad against the Portuguese in Malacca (I think that was the Atjeh Sultanate... And Demak <- My ancestry)

Edit: That was 15th - 16th century :)

Edit2: Where to download? I can't get the file from filefront...

Mephistopheles
12 May 2010, 03:36
I heard that the old download link doesn't work anymore. I reuploaded the file here (http://www.filefront.com/16420455/KoHmapConv.zip) and updated the original post.

Bulgaroktonos
3 Jun 2010, 14:59
Hey Mephistopheles,

I was wondering if this would work with a 64 bit version of Windows 7? Cause when I click on KoHMapConv.jar nothing happens at all!

Alright It works fine ... I started a new map project ... will tell more soon.

Mephistopheles
3 Jun 2010, 16:53
I don't think java actually knows what sort of system it runs on. The .jar should run on any Java-VM, wether the VM runs on Windows Xp, 7, 95, Unix, BSD, ReactOS or your cellphone.

Good to see it's working for you. :go:

Bulgaroktonos
3 Jun 2010, 17:34
Ok got it to run! Thanks anyway.

PS I would love to see a terrain.dt feature !

Bulgaroktonos
26 Jun 2010, 16:34
hey its me again i need to download the program again but the link is broken. Does anybody still have it?

Mephistopheles
26 Jun 2010, 20:50
I reuploaded the file here (http://www.filefront.com/16873589/KoHmapConv.zip) and updated the original post.

Bulgaroktonos
27 Jun 2010, 02:39
thanks a million. i ll have use for it...

GogoT
30 Jul 2010, 21:38
we need to reupload it...

Mephistopheles
31 Jul 2010, 18:34
Doesn't anyone have a reliable host for this? I don't want to reupload this once a month until the end of time... ;)

However I'm very hapy that there still appears to be demand for it, so here (http://www.filefront.com/17161645/KoHmapConv.zip)'s the link.

Papiczky
31 Jul 2010, 19:23
You can download my mod "Erdély mod 2.4" from here, with the map converter. This link never be deleted.

http://spz.uw.hu/

Direct link:
http://spz.uw.hu/index_elemei/KoHmapConv.zip

Mephistopheles
31 Jul 2010, 20:16
Thanks, that's very kind of you. :go:

Bulgaroktonos
18 Dec 2010, 14:23
Hey after all I started editing one of my old maps again and I just stumbled upon the fact that the .png that is converted needs to be 24 bit ... very important cause I just spent an hour finding out whats wrong with my .png file :rolleyes:

soko
18 Dec 2010, 20:09
I never had a problem with the png.
For easiest use you must convert your image to index color, than convert to rgb again .
But when convert to rgb you must have only 2 colors green and blue after doing this you
shouldn't have problems :)
I never think for the options to save the png