TTDViewer [2010-03-14]

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

TTDViewer [2010-03-14]

Post by frosch »

Hello,
during december I wrote this little tool. (The fools from IRC might already have seen parts of it.)

So what does it do?
You can open a .png or .pcx image which uses the TTD palette.
TTDViewer detects the palette of the image (DOS/Win), converts it to the DOS palette if needed, and then displays the image.
So far so boring. More interesting:
  • It does the TTD palette animation. You can start/stop animation or enable/disable particular animation cycles.
  • You can apply any of the default TTD recoloursprites, that is you can interactively apply company colours,
    random industry colours, or just display the whole image as in the newspaper.
The screenshot shows TTDViewer displaying the toy factory from OpenGFX, zoomed 3x and recoloured to yellow.
screenshot
screenshot
While TTDViewer is currently only a little gimmick and has somewhat limited usage, it is written in Java which should allow
new tools to start from it. So: Get it, start it, enjoy it, enhance it!
(Hints: Maybe someone wants to convert it into an applet, which can be display the sprites published on this forum and thus allows to zoom, animate and recolour all graphic previes here. Or well, maybe someone is bored enough, to enhance it to a full-features multi-layered paint program, but err - ok, I will stop here :p )

TTDViewer is versioned using Mercurial. The guys from #OpenTTDCoop were so nice to host the repository for it, they even provide a build-service :)

License: GPL v2
Project site: http://dev.openttdcoop.org/projects/ttdviewer
Repository: http://hg.openttdcoop.org/ttdviewer

Download (nightly build): http://bundles.openttdcoop.org/ttdviewe ... es/LATEST/
Last edited by frosch on 01 Aug 2012 17:12, edited 4 times in total.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5656
Joined: 31 Mar 2007 14:23
Location: Lost in Music

Re: New Tool: TTDViewer

Post by andythenorth »

Looks like it would be useful :)

Although it's Java, I can't get it to start on OS X (10.5). Hey ho. Here's a paste of console in case it's useful. If it's just an Apple->Java thing don't worry about it.

Code: Select all

24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045] SystemFlippers: didn't consume all data for long ID 0 (pBase = 0x100131b40, p = 0x100131b44, pEnd = 0x100131b48) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045] SystemFlippers: didn't consume all data for long ID 0 (pBase = 0x10012ca40, p = 0x10012ca44, pEnd = 0x10012ca48) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045] SystemFlippers: didn't consume all data for long ID 0 (pBase = 0x10012ca40, p = 0x10012ca44, pEnd = 0x10012ca48) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045] Exception in thread "main"  
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045] java.lang.UnsupportedClassVersionError: Bad version number in .class file 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.lang.ClassLoader.defineClass1(Native Method) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.lang.ClassLoader.defineClass(ClassLoader.java:675) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.net.URLClassLoader.access$100(URLClassLoader.java:56) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.net.URLClassLoader$1.run(URLClassLoader.java:195) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.security.AccessController.doPrivileged(Native Method) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at java.lang.ClassLoader.loadClass(ClassLoader.java:316) 
24/01/2010 22:43:45 [0x0-0xb6eb6e].com.apple.JarLauncher[86045]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280) 
Yexo
Tycoon
Tycoon
Posts: 3663
Joined: 20 Dec 2007 12:49

Re: New Tool: TTDViewer

Post by Yexo »

andythenorth wrote:Looks like it would be useful :)

Although it's Java, I can't get it to start on OS X (10.5). Hey ho. Here's a paste of console in case it's useful. If it's just an Apple->Java thing don't worry about it.
From that log it looks like your java version is too old. I just checked java.sun.com and they don't provide mac binaries, they state apple does that from time to time.
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: New Tool: TTDViewer

Post by Zephyris »

Excellent! Simple yet effective. I've done some quick testing and it works well but with a couple of bugs:
* When trying to open an "incorrect" file, ie. a non-paletted png, it gives no error or anything. A simple "incorrect palette" error would be nice.
* I tend to get redrawing problems in the image preview bit of the window, eg. when the file browser window gets closed you get bits of it "getting stuck" on the preview image.
* When stopping the palette animation it doesn't revert back to the palette colour, it just stops the animation. I think it would be neater behaviour to reset to the palette-encoded colour.

Great work though, a very useful tool.
User avatar
FooBar
Tycoon
Tycoon
Posts: 6553
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: New Tool: TTDViewer

Post by FooBar »

Looks like a very nice tool indeed. Too bad it's in Java though, as that is something I cannot use on my computer...
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: New Tool: TTDViewer

Post by frosch »

lol, so I picked Java to juggle all those nasty platforms, and then 20% users report it does not work due to Java :p

Anyway, andy, you might try checking out the source and run "make run". The jar however is created using some "newer" feature to create a Manifest on the fly.

@Zephyris: Thanks for testing. And yes, the GUI is somewhat minimal :)
I guess the non-palettized .png might even print something to the console :p
About the palette animation: The TODO list contains some play/pause, stop buttons, maybe also some speed control. However, currently you can get the effect by unchecking all the animation checkboxes.

About the drawing: Confirmed, I do not draw any background. Did not notice yet :s
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: New Tool: TTDViewer

Post by DaleStan »

frosch wrote:lol, so I picked Java to juggle all those nasty platforms, and then 20% users report it does not work due to Java :p
Write Once, Debug Everywhere.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: New Tool: TTDViewer

Post by Zephyris »

I am getting a "Palette not detected." error whenever I try to open the attached file. According to two programs (GIMP and ImageJ) it is an 8bit (paletted) .png and the palette seems to load correctly, what could be going wrong?
Attachments
1467-1468.png
1467-1468.png (7.56 KiB) Viewed 9186 times
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: New Tool: TTDViewer

Post by frosch »

Well, TTDViewer tries to detect DOS or WIN palette. But the palette of the image is far from those.

That would need some "import true colour" image function, which would pick the nearest colours while ignoring any animation colours. But that is currently out of the scope of the tool :)
Attachments
1467-1468_palette.png
1467-1468_palette.png (10.01 KiB) Viewed 9141 times
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: New Tool: TTDViewer

Post by Zephyris »

Ah, I had missed the "remove unused colours from colourmap" option on the gimp convert to indexed dialog; all works as expected now.
Attachments
donotdiscardcolours.PNG
donotdiscardcolours.PNG (23.93 KiB) Viewed 9136 times
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: New Tool: TTDViewer

Post by frosch »

New version in first post :)

Most noticable features are auto-reloading of files after modification on disk, and mouse panning + wheel zooming.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
Emperor Jake
Tycoon
Tycoon
Posts: 3427
Joined: 24 Apr 2007 09:37
Skype: Discord: Emperor Jake #4106
Location: Not Actually Japan
Contact:

Re: TTDViewer [2010-03-14]

Post by Emperor Jake »

Hi,

This would be a very useful tool, but no matter what I try, it says "Palette not detected"
What exactly do I need to do to make it work? (I have GIMP)

Thanks,
Jake

EDIT: Never mind, I figured it out. I was using the wrong palette file.

Thanks for the useful tool!
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: TTDViewer [2010-03-14]

Post by Transportman »

Bit of a bump, I know, but I have a problem. I have a graphics file that cannot be opened in TTDViewer because of a "No indexed image" error, but if that same file is used in the compilation of a NewGRF, compilation just runs fine and includes the image. Is there a problem with the image, or is the problem in TTDViewer itself?

I attached one of the images that I have problems with ( contained in the archive in this post ).
Attachments
Image with problems
Image with problems
Gen4_Hopper_Type1_Gray.png (31.99 KiB) Viewed 5848 times
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: TTDViewer [2010-03-14]

Post by Alberth »

My magic 'file' comand says:
file wrote:Gen4_Hopper_Type1_Gray.png: PNG image data, 714 x 257, 8-bit/color RGBA, non-interlaced
In other words, a 32bpp image.
TTD viewer seems to expect a 8bpp image ("indexed image" being the clue here, as that's another name for 8bpp images).
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Voyager One
Tycoon
Tycoon
Posts: 11204
Joined: 28 Dec 2009 09:47
Location: Rijeka, Croatia

Re: TTDViewer [2010-03-14]

Post by Voyager One »

My file so... what did I do wrong here?
Leon

Image Image Image Image
"... all I ask is a tall ship and a star to steer her by..." - John Masefield
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: TTDViewer [2010-03-14]

Post by Alberth »

Either you used the wrong file format, or TTDviewer is obsolete in not understanding 32bpp images.
Given that the program was written before adding 32bpp images, the latter is not a surprise.
Let's wait what its author has to say about it (maybe there is a project somewhere, where you can look at open issues?)
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Voyager One
Tycoon
Tycoon
Posts: 11204
Joined: 28 Dec 2009 09:47
Location: Rijeka, Croatia

Re: TTDViewer [2010-03-14]

Post by Voyager One »

Alberth wrote:wrong file format
Simple .png, never anything else. All drawings made in the lowly MsPaint, no other editing or corrections... :?
Alberth wrote:32bpp images
But these are supposed to be 8bpp sprites, I don't understand did they get converted to "32bpp"... :?
Leon

Image Image Image Image
"... all I ask is a tall ship and a star to steer her by..." - John Masefield
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: TTDViewer [2010-03-14]

Post by Alberth »

Voyager One wrote:
Alberth wrote:wrong file format
Simple .png, never anything else. All drawings made in the lowly MsPaint, no other editing or corrections... :?
.png supports a whole range of formats, from black/white 1bpp black/white images downto 32bpp RGBA. I haven't read the PNG standard, but probably the file format supports even more exotic images.
As such ".png" is ambiguous as indication of what you have.
Voyager One wrote:
Alberth wrote:32bpp images
But these are supposed to be 8bpp sprites, I don't understand did they get converted to "32bpp"... :?
Easy, you saved the picture as full-colour image, or whatever nice name MS gave to it.

Many people think that 8bpp == old-school hand-drawn pixels, and 32bpp == full-colour blendered pixels, and in many cases that's actually true.
However what most do not realize is that these are upper limits only. You cannot have 257 different colours or 53% transparency in 8bpp, because that format cannot store that information.
For this reason, you never find full-colour blendered pixels in 8bpp. The format just isn't capable of storing the information associated with each pixel.
It's like trying to put a very big box into a small van. It won't work, you need a big van instead.

However, the reverse is not true. I can take a big van and put a very small package in it. It's overkill, but it works. In the same way, you can use a full-colour 32bpp file format, and store a pure black/white image in it (ie a 1bpp image). In your case, you can store the information of 256 colour pixels in a 32bpp format.
Obviously, in your case, using an 8bpp format would reduce storage requirements, just like using a small van for small boxes reduces costs.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Voyager One
Tycoon
Tycoon
Posts: 11204
Joined: 28 Dec 2009 09:47
Location: Rijeka, Croatia

Re: TTDViewer [2010-03-14]

Post by Voyager One »

Hmmm... if this is true then I must have done this on thousands of files... Geeeeeee... :(

One more thing is that I don't see any of this "full-color"/"old-school" options in MsPaint and when I use "Save as .png" there are no options there either. Is it possible that it also depends on the palette that I use? I've realized that I've used one (I think DOS) version during my early drawings while I've switched to the more-colored Windows version in the later works. Is it possible that affects the issue too? :?
Leon

Image Image Image Image
"... all I ask is a tall ship and a star to steer her by..." - John Masefield
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: TTDViewer [2010-03-14]

Post by frosch »

TTDViewer is meant to display palette animated and recoloured 8bpp sprites
32bpp sprite do not have such things, you can just look at them using your drawing program.

Why would anyone want to use TTDViewer for 32bpp images? ?(
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 5 guests