HOW TO COMPILE 32BPP GRAPHICS FOR OPENTTD 1.2
0) This will only work on linux.
1) Install python. There are a number of ways to do this, and I don't remember which one I used, so just google how to install python if you're confused
2) Install ZLIB libraries (sudo apt-get install zlib1g-dev)
3) Install JPEG libraries (sudo apt-get install libjpeg62-dev) [not actually sure if this is necessary, but it can't hurt]
4) Install PIL (Python Imaging Library): [Edit: FooBar suggests skipping 4a-4cvi, and instead just using "sudo apt-get install python-imaging"]
4a) Download PIL Source Kit (http://www.pythonware.com/products/pil/)
4b) Extract the contents of Imaging-1.1.7.tar.gz to a folder
4c) You can follow the Build Instructions in the extracted README file, or read exactly what I did (which involves a few extra steps because of odd errors I encountered) below. Note that I originally tried the instructions under "If you're in a hurry, try this:" and it led me to lots of problems, so if you're following the README I recommend reading the entire compiling section rather than just doing the fast route. My steps:
4c-i) Navigate to the Imaging-1.1.7 directory in terminal
4c-ii) Run
Code: Select all
python setup.py build_ext -i
Code: Select all
python selftest.py
4c-iv) If selftest.py doesn't work, edit the ROOT variables in setup.py. I had to change the line 'ZLIB_ROOT = None' to 'ZLIB_ROOT = libinclude("/usr/")' before things worked for me (discussion forums led me to believe that this had something to do with being on a 64-bit machine? Or having a new ubuntu installation? I forget).
4c-v) Check that PIL actually does contain the ZLIB functionality. I ran into a problem where selftest.py would report that it had the functionality, yet the installed program would not. To check this, navigate [in terminal] to build/[temp.linuxsomething - exact name depends on your installation]. Then run:
Code: Select all
python
>>> import _imaging
>>> dir(_imaging)
python setup.py clean
then repeat from step 4c-i
4c-vi) Install PIL:
Code: Select all
python setup.py install
6) Download pngcodec from http://www.openttd.org/en/download-pngcodec
7) Download the actual 32bpp graphics from the nightly repositories at http://jupix.info/openttd/gfxdev-nightlies/files/ .
8 ) Extract the graphics
9) Download Rubidium's script and empty.pcx. empty.pcx is posted in Rubidium's post on the second page of this thread, about 1/3 of the way down. The script, create.txt, is also posted there, but an updated version is available at http://rbijker.net/openttd/create.txt
10) Place create.txt, empty.pcx, and the extracted contents of the grfcodec and pngcodec archives all inside the [extracted graphics folder]/Sprites/ogfx1_base folder. This will be your working directory
11) Mark create.txt as an executable file (right-click, Properties)
12) Double-click create.txt to run it. If all goes well, it will run for a few seconds without displaying any errors. If it doesn't work, you may need to edit in text editor and change references to "pngcodec" to "./pngcodec" [if it complains about pngcodec being unrecognized], install PIL [if it complains about "Image" not being recognized], or check that PIL includes ZLIB [if it complains about "ZIP encoder"].
13) When you have the .nfo, you're almost done! Navigate to the Sprites/ogfx1_base folder in terminal and run:
Code: Select all
./nforenum grf_32bpp.nfo
./grfcodec -f -e -g2 grf_32bpp.nfo .
13i) to tell you that a .png is true colour or is not a 256-colour image. In this case, you need to use your favourite image editor to apply an index with 256 colours (e.g. the default OpenTTD DOS palette, available at http://dev.openttdcoop.org/documents/1). It is probably worth writing a GIMP script to batch index files.
13ii) to tell you that a .png and it's corresponding mask .png have different sizes. In this case, use your favourite image editor to resize the mask file, and paint over any added area to the regular "background" colour. I recommend opening the .png and copy-pasting the modified mask on top of it to check the two still line up.
14) Again, if all goes well you'll now have a file called 32bpp.grf. Copy that file to your openttd/data/ folder and then activate it in-game; you'll have 32bpp graphics again!
Using even more graphics: If you haven't used 32bpp graphics before, this option is irrelevant to you. Since I played OpenTTD before .png loading was disabled, I'd already begun collecting 32bpp graphics which were not part of the nightly packs, including some which belonged in my OpenTTD/data/sprites/ogfx1_base file. Instead of using this script to process the .png's from the nightly pack, I processed a copy of my existing OpenTTD/data/sprites/ogfx1_base folder, which allowed me to incorporate the extra graphics which hadn't been released in the nightly packs. The drawback of this was that a lot of these graphics led to the problems listed in step 13i) and 13ii) - it ended up taking much longer.
32bpp_extra: Once you've got the base set, you can also add some more 32bpp graphics, specifically those which used to be released in the 32bpp_extra pack. The steps for this are:
1) Download 32bpp_extra.nfo and 32bpp_extra_nightly-r40.zip from http://bundles.openttdcoop.org/32bpp-ex ... es/LATEST/
2) Extract the .tar from the .zip
3) Extract the contents of the .tar's subfolder sprites/32bpp_extra to a working directory of your choice
4) Copy 32bpp_extra.nfo (downloaded in step 1) to the working directory
5) Download the zip file from http://hg.openttdcoop.org/32bpp-extra/file/987e89efd6eb (click on the "zip" link at the top right). Extract the subfolder /grfdef/pcx . Copy all the .pcx files in this directory and in the subfolder /trains to the working directory (those originally in the trains subfolder should go directly in the working directory, NOT in a subfolder called trains)
6) Copy all the extra files from your 32bpp base compilation (grfcodec, nforenum - basically everything that isn't a .png) into your working directory
7) Download the 32b_extra_2_info32_sh.txt script from this thread (1st post of 4th page, post by GeekToo). Mark this as executable (Right-click, properties) and place it in your working directory.
8 ) Run the .txt file downloaded in step 7. If all goes well, it will produce a file called 32bpp_e.nfo
9) Run ./nforenum 32bpp_e.nfo from terminal in the working directory
10) Run ./grfcodec -e -f -g2 32bpp_e.nfo . [note the extra dot at the end!]
11) If all goes well, you'll now have a .grf named 32bpp_e.grf!