glpng for the Mac...

February 19, 2008, at 02:37 PM

A friend on IRC was having trouble getting the glpng library to build on the Mac; it's unmaintained, but reputedly solid, and it's nice if the sole reason you're using SDL or whatever is to get at its image-handling functions...

Since I've done this stuff a lot I knew that it was basically a matter of fixing include files and such. So I did that. I did not bother to get "make install" to do anything sensible, so don't use that. My darcs repository is at http://www.accela.net/~dankna/software/darcs/glpng/ and I'd appreciate feedback.

My game project!

February 17, 2008, at 04:52 PM

Some people have been asking what my game project is about. For a long time I would just summarize it every time someone asked, but today I finally got around to putting together material that I'd written in different places and editing it into a semi-coherent overall introduction. I'm probably NOT going to post regular updates about the project here, but I'm posting this, so that I can have someplace to point people when they ask. I know the text is rough; and the paragraphing is weird because this originated as a chatlog - actually several chatlogs. Just felt the need to explain that so I wouldn't be embarrassed. :) And please feel free to ask any questions you want!

Continue reading "My game project!" »

GIF, LZW, Postscript, and PDF

September 06, 2007, at 05:00 PM

Well, the other day when I wrote about this, I did a test where I used an external tool to decode the LZW payload of a GIF and feed that into my generated PDF. That worked. Then I tried decoding with PostScript's codec by using Ghostscript interactively, and comparing the data to what I expected. That worked. Then I tried telling the PDF to decode with the same filter. That did not work.

So I slept on it.

Today I looked in on it again and the problem was immediately obvious: PostScript and PDF have different versions of the LZWDecode filter, which aren't quite identical. Specifically, their parameters have the same names, but in PDF only values between 9 and 12 are valid for the initial number of bits in each code. In PostScript, any value is valid. The stream I was testing with used 3 bits. I actually had already tried generating a stream that wouldn't have that issue, since I was confused by some wording in the PDF spec, but that one used 8 bits!

So that answers that question. Yay! Now I need to decide what to do about it! Obviously I need to decode and re-encode the thing. Since I want to link against Ghostscript anyway to handle EPS conversion, maybe I should figure out how to link against it now and then have it do the recoding. That way I won't need a Haskell implementation of LZW. Not that LZW is that hard... I've implemented it before, but that's precisely why I don't really want to do it again. Boring to keep doing the same thing. And since Ghostscript already contains a well-tested implementation, as well as impls for any other codec I might possibly want...