Capsim Block Documentation
Read a binary image.
| Num | Type | Name | Initial Value | Description |
|---|---|---|---|---|
| 0 | int | obufs | ||
| 1 | int | fd | ||
| 2 | int | numberRowsRead | 0 | |
| 3 | char* | buff |
int i,j,k; float x; int n; |
|---|
if((fd = open(file_name,0)) == -1) {
fprintf(stderr,"rdbinimage: cannot open file\n");
return(1); /* file cannot be opened */
}
if( (obufs = NO_OUTPUT_BUFFERS()) < 1 ) {
fprintf(stderr,"rdbinimage: no output buffers\n");
return(2);
}
fprintf(stderr,"Image width= %d, height = %d \n",width,height);
numberRowsRead =0;
buff = (char *) calloc(width,sizeof(char));
if(buff == NULL) {
fprintf(stderr,"rdbinimage: can't allocate space\n");
return(3);
}
for(i=0; i |
|---|
if(numberRowsRead >= height) return(0); /* * output a row */ n= read(fd,buff,width); /* * * increment time on output buffer(s) * and output a sample */ for(j=0; j |
|---|
close(fd);
free(buff);
return(0);
|
|---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
Copyright (C) 1989-2002 XCAD Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/************************************************************* rdbinimg() *************************************************************** Description: Read a binary image. On each visit a row is read from file and output. Auto fan-out. |
|---|