Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-15-2013, 05:47 AM   #1
Registered: Jul 2011
Posts: 63

Rep: Reputation: Disabled
How to use AAlib with C or C++?

How can I use the ascii art library aalib with c or c++ code.
There is no concrete example. INFO programe explains few lines of
code but I could not understand as this is not a complete example.

I want to write a c code that will open an image file and convert
it to an ascii image art. I think it is possible with aalib as it is
written specially for this purpose.

I have come to know what header file is required and what the linker flag (-laa)
but I need to know at least a simple complete example.

Thank you.

Last edited by vectrum; 06-17-2013 at 09:26 AM.
Old 06-16-2013, 05:46 AM   #2
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,265

Rep: Reputation: 298Reputation: 298Reputation: 298
Old 06-17-2013, 09:27 AM   #3
Registered: Jul 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
Where is the example/sample programme?

Please don't post anything irresponsibly only for the shake of posting something.

It would be really helpful if you pointed
out the specific example as I couldn't find
the solution.

Last edited by vectrum; 06-17-2013 at 09:30 AM.
Old 06-17-2013, 12:10 PM   #4
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,265

Rep: Reputation: 298Reputation: 298Reputation: 298
Sorry I can't understand what you can't find. That page has many examples, no? The stuff is really old, and I now see many links don't work. But, many do, and I think they're complete. And 2 clicks away, on the first link on each page, you end up here:

I can't remember exactly, but I think you asked for examples and documentation for aalib no? Now I see you have edited it, so I'm not really sure what I answered.

Also, another way is to search your distro for examples. Here's from my Ubuntu:

apt-cache search aalib
libaa1 - ASCII art library
libaa1-dbg - ASCII art library, debugging symbols
libaa1-dev - ASCII art library, development kit
bb - ASCII-art demo based on AAlib
caca-utils - text mode graphics utilities
fim - a scriptable frame buffer and ascii art image viewer
libaa-bin - sample programs using aalib
libggi-target-monotext - General Graphics Interface plain text target
python-aalib - Python interface to AAlib, an ASCII art library
ttv - television viewer - console application
Old 06-17-2013, 04:41 PM   #5
Registered: Jul 2011
Posts: 63

Original Poster
Rep: Reputation: Disabled
Thank you for your reply and please let me clear the amibiguity at my end.

I edited just one word. I changed (-laalib) to (-laa) as
-laalib is the wrong flag and I mistakenly wrote -laalib.

I wanted to say in my first message(2nd line);

"INFO programe explains few lines of code but
I could not understand... ."

The 'info aalib' contains the same material as that of the link you have given here but my problem is that I can't understand how to begin.

I successfully compiled the following code which opens a
blank window and terminates it.

#include <stdio.h>
#include <aalib.h>
aa_context *context;
int main()
context = aa_autoinit(&aa_defparams);
if(context == NULL) {
fprintf(stderr,"Cannot initialize AA-lib. Sorry\n");
and when I try to compile another aalib code
(in /usr/local/info/info.aalib-1) with
$ gcc -Wall -W -O -g3 -o aalibprog aalibprog.c -laa
#include <aalib.h>
#include <stdlib.h>
main (int argc, char **argv)
int i;
aa_context *context; /* The information about currently
initialized device. */
aa_palette palette; /* Emulatted palette (optional) */

char *framebuffer;

/* Parse command line options and output the help text. */
if (!aa_parseoptions (NULL, NULL, &argc, argv) || argc != 1)
printf ("%s", aa_help);
exit (1);

/* Initialize output driver. */
context = aa_autoinit (&aa_defparams);
if (context == NULL)
printf ("Failed to initialize aalib\n");
exit (1);

/* Pointer to the emulated videoram. */
framebuffer = aa_image (context);

/* Create palette if needed: */
for (i = 0; i < 256; i++)
aa_setpalette (palette, i /* R value 0..255 */ ,
/* G value 0..255 */ ,
/* B value 0..255 */ );

/* Draw something using: */
aa_putpixel (context /* X coord */ , /* Y coord */ , /* Color */ );

/* Render whole screen: */

aa_renderpalette (context, palette, aa_defrenderparams,
/* Top left conner of rendered area: */ 0, 0,
/* Bottom right */ aa_scrwidth (context), aa_scrheight (context));

/* If you don't use palette use following function:
aa_render (context, aa_defrenderparams,
0, 0, aa_scrwidth (context), aa_scrheight (context));

/* And make it visible: */
aa_flush (context);

/* And uninitialize the AA_lib (this probably makes the picture invisible
again) */
aa_close (context);

return 1;
getting the following error:

but getting the following error; aalibprog.c: In function 'main':
aalibprog.c:29:20: warning: pointer targets in assignment differ in signedness [-Wpointer-sign]
aalibprog.c:36:58: error: macro "aa_setpalette" requires 5 arguments, but only 4 given
aalibprog.c:34:10: error: 'aa_setpalette' undeclared (first use in this function)
aalibprog.c:34:10: note: each undeclared identifier is reported only once for each function it appears in
aalibprog.c:39:73: error: macro "aa_putpixel" requires 4 arguments, but only 3 given
aalibprog.c:39:8: warning: statement with no effect [-Wunused-value]
aalibprog.c:45:32: error: incompatible type for argument 3 of 'aa_renderpalette'
In file included from aalibprog.c:1:0:
/usr/local/include/aalib.h:647:6: note: expected 'const struct aa_renderparams *' but argument is of type 'struct aa_renderparams'
aalibprog.c:11:14: warning: variable 'framebuffer' set but not used [-Wunused-but-set-variable]

so I've asked for the help.

Thanks again.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling aview with aalib Exeis Linux - Software 1 01-05-2007 08:27 PM
How to use AALIB Exeis Linux - Software 1 12-20-2006 01:59 PM
aalib/mplayer/pretty Ctawp Linux - Software 1 08-27-2004 04:55 AM
aalib and mplayer dtheorem Linux - Software 1 12-16-2003 01:37 PM
seting up aalib for mplayer SlashDebian Linux - Software 2 01-18-2003 06:50 AM

All times are GMT -5. The time now is 09:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration