rdbinimg

Capsim Block Documentation

Short Description

Read a binary image.

Top
Parameters
Num Description Type Name Default Value
0 Image width int width 128
1 Image height int height 128
2 File that contains binary image file file_name test.img
3 Number of bytes to skip int skip 0
Top
States
Num Type Name Initial Value Description
0 int obufs
1 int fd
2 int numberRowsRead 0
3 char* buff
Top

Declarations


 

	int i,j,k;
	float x;
	int  n;



Top

Initialization Code



 

	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
    
Top

Main Code



 


   	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
    
Top

Wrapup Code



 

        close(fd);
	free(buff);
        return(0);




Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP 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://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/*************************************************************
			rdbinimg()
***************************************************************
Description:  Read a binary image.
	On each visit a row is read from file and output.
	Auto fan-out.

rdbinimg


Read a binary image.
	On each visit a row is read from file and output.
	Auto fan-out.


Programmer: Sasan Ardalan
Date: November 4, 1990 

*/