LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-15-2013, 04:47 AM   #1
vectrum
Member
 
Registered: Jul 2011
Posts: 59

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 08:26 AM.
 
Old 06-16-2013, 04:46 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,116

Rep: Reputation: 218Reputation: 218Reputation: 218
http://aa-project.sourceforge.net/
 
Old 06-17-2013, 08:27 AM   #3
vectrum
Member
 
Registered: Jul 2011
Posts: 59

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 08:30 AM.
 
Old 06-17-2013, 11:10 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,116

Rep: Reputation: 218Reputation: 218Reputation: 218
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:

http://aa-project.sourceforge.net/aalib/aalib_toc.html

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:

Quote:
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, 03:41 PM   #5
vectrum
Member
 
Registered: Jul 2011
Posts: 59

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.

Quote:
#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");
exit(1);
}
aa_close(context);
}
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
Quote:
#include <aalib.h>
#include <stdlib.h>
int
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.
 
  


Reply


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 07:27 PM
How to use AALIB Exeis Linux - Software 1 12-20-2006 12:59 PM
aalib/mplayer/pretty Ctawp Linux - Software 1 08-27-2004 03:55 AM
aalib and mplayer dtheorem Linux - Software 1 12-16-2003 12:37 PM
seting up aalib for mplayer SlashDebian Linux - Software 2 01-18-2003 05:50 AM


All times are GMT -5. The time now is 01:20 AM.

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