From ccddec68116fc6403858ebfa13d4a7b1aa3d5278 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Sun, 18 Oct 2009 20:01:19 +0000 Subject: hi gridflow 0.9.5 svn path=/trunk/; revision=12611 --- externals/gridflow/format/netpbm.c | 119 +++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 externals/gridflow/format/netpbm.c (limited to 'externals/gridflow/format/netpbm.c') diff --git a/externals/gridflow/format/netpbm.c b/externals/gridflow/format/netpbm.c new file mode 100644 index 00000000..dcf8e97e --- /dev/null +++ b/externals/gridflow/format/netpbm.c @@ -0,0 +1,119 @@ +/* + $Id$ + + GridFlow + Copyright (c) 2001-2008 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.h.fcs" +extern "C" { +#include +}; + +\class FormatNetPBM : Format { + struct pam inpam, outpam; + \grin 0 + \constructor (t_symbol *mode, string filename) { + Format::_0_open(0,0,mode,filename); + memset(& inpam,sizeof(pam),0); + memset(&outpam,sizeof(pam),0); + } + \decl 0 bang (); +}; +\def 0 bang () { + //inpam.allocation_depth = 3; + pnm_readpaminit(f, &inpam, /*PAM_STRUCT_SIZE(tuple_type)*/ sizeof(struct pam)); + tuple *tuplerow = pnm_allocpamrow(&inpam); + if (inpam.depth!=3) RAISE("image has %d channels instead of 3 channels",inpam.depth); + GridOutlet out(this,0,new Dim(inpam.height,inpam.width,inpam.depth),cast); + uint8 buf[inpam.width*3]; + for (int i=0; idim->n!=3) RAISE("need 3 dimensions"); + if (in->dim->v[2]!=3) RAISE("need 3 channels"); + outpam.size = sizeof(struct pam); + outpam.len = sizeof(struct pam); + outpam.file = f; + outpam.format = PPM_FORMAT; + outpam.height = in->dim->v[0]; + outpam.width = in->dim->v[1]; + outpam.depth = in->dim->v[2]; + outpam.plainformat = false; + outpam.maxval = 255; + //outpam.allocation_depth = 3; + strcpy(outpam.tuple_type,PAM_PPM_TUPLETYPE); + pnm_writepaminit(&outpam); + in->set_chunk(1); +} GRID_FLOW { + tuple *tuplerow = pnm_allocpamrow(&outpam); + int m = in->dim->v[1]; + for (int i=0; idim->prod(1)) { + for (int j=0; j