Page 1 of 2

TTDViewer [2010-03-14]

Posted: 24 Jan 2010 16:54
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.
TTDViewer.png
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/

Re: New Tool: TTDViewer

Posted: 24 Jan 2010 22:45
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) 

Re: New Tool: TTDViewer

Posted: 24 Jan 2010 22:53
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.

Re: New Tool: TTDViewer

Posted: 24 Jan 2010 23:46
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.

Re: New Tool: TTDViewer

Posted: 25 Jan 2010 00:58
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...

Re: New Tool: TTDViewer

Posted: 25 Jan 2010 19:23
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

Re: New Tool: TTDViewer

Posted: 26 Jan 2010 17:30
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.

Re: New Tool: TTDViewer

Posted: 09 Mar 2010 15:13
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?

Re: New Tool: TTDViewer

Posted: 09 Mar 2010 19:54
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 :)

Re: New Tool: TTDViewer

Posted: 09 Mar 2010 20:03
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.

Re: New Tool: TTDViewer

Posted: 14 Mar 2010 17:32
by frosch
New version in first post :)

Most noticable features are auto-reloading of files after modification on disk, and mouse panning + wheel zooming.

Re: TTDViewer [2010-03-14]

Posted: 31 Dec 2010 06:55
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!

Re: TTDViewer [2010-03-14]

Posted: 15 Mar 2015 17:50
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 ).

Re: TTDViewer [2010-03-14]

Posted: 15 Mar 2015 18:04
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).

Re: TTDViewer [2010-03-14]

Posted: 15 Mar 2015 18:31
by Voyager One
My file so... what did I do wrong here?

Re: TTDViewer [2010-03-14]

Posted: 15 Mar 2015 18:36
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?)

Re: TTDViewer [2010-03-14]

Posted: 16 Mar 2015 10:27
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"... :?

Re: TTDViewer [2010-03-14]

Posted: 16 Mar 2015 11:37
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.

Re: TTDViewer [2010-03-14]

Posted: 16 Mar 2015 18:52
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? :?

Re: TTDViewer [2010-03-14]

Posted: 16 Mar 2015 20:10
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? ?(