Jun 18, 2009
AA-Lib ported to Flash via Alchemy
One of the main reasons I started playing around with Alchemy a while back was to experiment with some of my favorite textmode libraries, specifically AA-Lib, which is the most commonly used image-to-ascii-art library of the bunch (has been used with Quake, VLC Player, and many other desktop programs) . It’s a frequently requested port among ascii art fans, and I’m glad to finally release it for everybody to use.
AA-Lib is a low level gfx library written in C. Its API is designed to be similar to other graphics libraries, but its renderer outputs ascii-art. I’m not going to go into any coding detail with this post, as the source is available for download. Programmers with even limited C experience should find the routines fairly straight forward (Alchemy routines can be found in /alc-src/main.c).
The important thing to note, is that AA-Lib will pass back a text buffer ByteArray, and a text-attribute (Bold, Dim, Normal) ByteArray. A flash developer can do whatever he wants with those. For the demo, I’ve used my own AS3ANSI library to interpret those buffers. I’ve also included a “Save to Text File” option that allows you to download the raw text buffer to a file.

AA-Lib has many cool features, including the ability to control brightness, contrast, and gamma. Sometimes an image needs to be tweaked in order to achieve the desired output. Play around with the sliders I’ve hooked up. You can get some pretty crazy results.

There’s also an option to invert the image, incase you’re dealing with something on a white background or want a negative ascii.

I’ll probably evolve this demo into a more substantial app, but for now all the requested features have been added, including uploading, saving to JPG, saving to text, and size parameters. Enjoy!



Cool stuff thanks for putting up the source. It will definitely be interesting to see how it all works, even though it probably will be jibirish to me at first haha.
Let me know if you have any questions. The source is more of a reference for people who want to use aalib.swc (contained in /alc-src). It might be a pain to compile the demo since I have some dependancies. Just make sure to take a look at the bufferImage and asciify functions in the AS, and main.c for the Alchemy stuff.
That is dope. I wonder how it performs with video instead of images, or at least sequences of images?
I posted an ascii video example a while back using TextFX7 instead of AA-Lib. It wouldn’t be that different. http://www.peternitsch.net/demo/textmode/index.html
Awesome, Peter! I uploaded a few photos and the brightness adjustment worked really great… Pictures are “auto-shaded” in b&w, and become more stylish than regular ascii conversions (adds more depth to the picture).
I’ve been following all your textmode experiments, plese keep em coming!
cheers
[...] Source: http://www.peternitsch.net/blog/?p=285 [...]
[...] has an excellent weblog posting about his project, including references, source code, and example [...]
Have you thought about libcaca support?
I’ve already converted TextFX7 (http://www.peternitsch.net/blog/?p=198) which is a better color ASCII convertor, but I can try my hand at a port when there’s time.
Awesome! I’m pretty darn impressed and anxious to take a look at it. I experimenting with a Csv parser myself.