From 5a6bee4fe076e06514c6e4e538590dd3a2a5cdc3 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Fri, 6 Nov 2009 18:37:00 +0000 Subject: upgrade gridflow svn path=/trunk/; revision=12728 --- externals/gridflow/src/aalib.cxx | 144 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 externals/gridflow/src/aalib.cxx (limited to 'externals/gridflow/src/aalib.cxx') diff --git a/externals/gridflow/src/aalib.cxx b/externals/gridflow/src/aalib.cxx new file mode 100644 index 00000000..771c5eab --- /dev/null +++ b/externals/gridflow/src/aalib.cxx @@ -0,0 +1,144 @@ +/* + $Id: aalib.c 4620 2009-11-01 21:16:58Z matju $ + + GridFlow + Copyright (c) 2001-2009 by Mathieu Bouchard + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + See file ../COPYING for further informations on licensing terms. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "gridflow.hxx.fcs" +#define aa_hardwareparams aa_hardware_params +#include +#include + +/* MINNOR is a typo in aalib.h, sorry */ +typedef +#if AA_LIB_MINNOR == 2 + int +#else + enum aa_attribute +#endif +AAAttr; + +static std::map drivers; + +\class FormatAALib : Format { + aa_context *context; + aa_renderparams *rparams; + \attr bool autodraw; + bool raw_mode; + /* !@#$ varargs missing here */ + \constructor (t_symbol *mode, string target) { + context=0; autodraw=1; + argc-=2; argv+=2; + char *argv2[argc]; + for (int i=0; iimgheight,context->imgwidth,1}; + post("aalib image size: %s",(new Dim(3,v))->to_s()); + } + ~FormatAALib () {if (context) aa_close(context);} + \decl 0 hidecursor (); + \decl 0 print (int y, int x, int a, string text); + \decl 0 draw (); + \decl 0 dump (); + \grin 0 int +}; + +GRID_INLET(0) { + if (!context) RAISE("boo"); + if (in->dim->n != 3) + RAISE("expecting 3 dimensions: rows,columns,channels"); + switch (in->dim->get(2)) { + case 1: raw_mode = false; break; + case 2: raw_mode = true; break; + default: + RAISE("expecting 1 greyscale channel (got %d)",in->dim->get(2)); + } + in->set_chunk(1); +} GRID_FLOW { + int f = in->dim->prod(1); + if (raw_mode) { + int sx = min(f,aa_scrwidth(context)); + int y = dex/f; + while (n) { + if (y>=aa_scrheight(context)) return; + for (int x=0; xtextbuffer[y*aa_scrwidth(context)+x]=data[x*2+0]; + context->attrbuffer[y*aa_scrwidth(context)+x]=data[x*2+1]; + } + y++; + n-=f; + data+=f; + } + } else { + int sx = min(f,context->imgwidth); + int y = dex/f; + while (n) { + if (y>=context->imgheight) return; + for (int x=0; xtextbuffer[y*aa_scrwidth(context)+x]; + data[1] = context->attrbuffer[y*aa_scrwidth(context)+x]; + out.send(2,data); + } + } +} + +\end class FormatAALib { + const aa_driver *const *p = aa_drivers; + for (; *p; p++) drivers[(*p)->shortname] = *p; + install_format("#io.aalib",2,""); +} +void startup_aalib () { + \startall +} -- cgit v1.2.1