Subscribe to with your favorite RSS Reader
December 2, 2016#10 Software

Example of an Image Service

Post Archive Icon

This is a follow up on yesterday's post about my thoughts on C64 graphics, and my conclusion that what would be extremely useful would be an image conversion web service. The idea being that once C64 OS provides a TCP/IP stack over one of the commercially available ethernet cartridges, then what we could really use is a set of internet accessible services that will fetch data from any URL, scale and convert to a C64 friendly format and allow us to download directly into memory exactly what can be immediately used.

One obvious first choice is for images. There are so many image formats out there. GIF, PNG and JPG, but many variants too. Sure, we've got a JPEG converter with JuddPeg, but despite being cool, it's unreasonably slow. Plus, it doesn't handle scaling images down to something reasonable that the C64 can handle. Nor does it support JPEG-2000. What about WebP and SVG and others? The point is, a web-service running on a computer that's "in the cloud" could scale and convert any of these image formats nearly instantaneously, and send to the C64 something that can be loaded directly into a chunk of memory, and displayed natively by the VIC-II chip without any extra work.

So, my examples from yesterday showed off the impressive quality of IFLI. But as a first step it may be more practical to implement a service that converts to a simpler format. I've scowered the web for various C64 image converters and been in contact with a couple of interesting people. And I've downloaded and compiled (on a Mac) a few converters to test them out. I really want to shout out to these guys, because, hey this stuff is pretty cool!

Great Find #1

I was most excited by the write up and work of Peter Wendrich about how to use genetic algorithms to "evolve" an interlaced hires mode image. Check it out on his site it's super cool! Peter was very patient and helpful as I worked my way through getting his code to compile with the requisite third-party libraries. And he was appreciative when I found and fixed a bug or two. I processed a handful of images through his GA converter, stuck them on an SD Card and loaded them up on my C64. The results are pretty impressive, considering the color limitations imposed by hires mode. One downside is that on a real C64 these images have a lot of flicker. I would consider using this converter as a service option, but there is one other pretty major downside. The nature of a GA is that you can stop it processing after any arbitrary number of generations. The more generations the better the image looks, up to a certain point of diminishing returns. The genetic algorithms are technically very interesting, but practically, they are very slow. Even on a super bitchin' fast modern Mac, it takes around 10 minutes of heavy processing before you get an image that really looks good. Still, check out the project, totally neat!

Great Find #2

The next most useful website I found was by ALeX Kazik over on his blog about retrocomputing. His post about C64 Image Conversion was by far the easiest to use. Just upload any PNG, GIF or JPG pre-scaled to 320x200 and it'll spit out 5 versions of the graphic using different C64 image mode and rendering technique combinations: FLI FS-Dithered, FLI nearest neighbor (two variations), and then KOALA (aka multi-color mode) FS-Dithered and nearest neighbor. I wrote to Alex to ask if I could get ahold of his source code. He very helpfully wrote back and pointed out that his site is making use of some open source tools. One is a suite of PPM conversion tools called netpbm. This has all sorts of tools for converting, scaling and manipulating common image formats and converting them to PPM, which stands for portable pixel map. PPM is inefficient for distributing images, but it's a great intermediate step for getting other tools to be able to work with raw pixel data. In steps the other tool Alex pointed me to. Which is C64Gfx, a suite of conversion tools written by Pasi 'Albert' Ojala in the 90s. Together these sets of tools can fairly easily be used by a web-service scripting language (like PHP) to fetch an image from a URL, convert it to PPM, scale it down to 320x200, crop it if necessary, and then convert to any of a number of common C64 image formats. Converting to Koala format isn't the highest quality that can be obtained on a C64, but, these tools are readily available, and the output can be obtained nearly instantaneously fast.

Great Find #3

Here's another little gem I found online. If you happen to be on a Mac, then you probably know about QuickLook. It's the ability to slap the long one with a file selected and a window will pop up and preview the file for you. Well, over on this fine website, you'll find a Mac OS X QuickLook plugin called C64Images that can preview a whole whack of common C64 image formats. Super useful when you want to see what the output of some of the above tools actually produces without having to first transfer to your C64 or use an emulator (god forbid.)

Compiling the C64Gfx tools were/are a breeze, they don't even depend on any third party libaries. These tools also offer a wide range of conversion parameters for contrast, brightness, dither styles and more. It would be nice if I work in some of these most common parameters into the web-service. But, the defaults are still pretty good. I haven't yet begun to work with the netpbm tools, they're next. But, since Alex Kazik has already got these tools up and running as a sort of web-service I ran a handful of images which you can see below to give an idea of what we can expect. Again, Koala isn't the highest quality, but, it's not terrible, it's super fast, it's very lightweight on the C64 to download and display, and the tools are practically falling out of the sky directly into my lap. So, here we are:

Worf and Dax

Here we showcase some traditional Star Trek nerdery. Congratulations to Worf and Dax, this is probably my favorite picture of them.

Lady Gaga Peace Sign

Next we've got a little pop culture in black and white. Lady Gaga is an example of an image I might enjoy looking at, but no C64 demo-coder will ever feature her in their artistry.

National Geographic Famous Photo

Here's an example of a close up of a face, in color. This is a famous photo taken by National Geographic a couple of decades ago.

Japan Landscape

And lastly, just to show something entirely different, here's an example of a Japanese landscape. I'm particularly fond of how this one turned out. It could practically be an image used in a C64 game, like the Last Ninja or something.

So that's all for now on this front. But it's just to give an idea that we can and will have access via our C64s with ethernet cartridges to a whole world of graphics, quickly and easily without requiring anyone to care about specifically supporting the C64, and without needing to depend on what a C64 artist happens to think is cool.