/*----------------------------------------------------- Parameters: Returns value: Description ------------------------------------------------------*/ int ErrorInit(char *fname, int (*vfprint)(FILE *fp, const char *fmt, va_list args), int (*vprint)(const char *fmt, va_list args)) { FSinit() ; error_exit = (void *)exit; i_seterror(rgb_error) ; if (fname) strcpy(error_fname, fname) ; if (vfprint) error_vfprintf = vfprint ; if (vprint) error_vprintf = vprint ; unlink(error_fname) ; /* start with a fresh log file */ errno = 0 ; /* probably should be some info into log file like date/user etc... */ return(NO_ERROR) ; }
SbBool ReadSGIImage(const SoInput& in, int &w, int &h, int &nc, unsigned char *&bytes) { i_seterror(errfunc); IMAGE *image_in; int i, j, row; if ( (image_in = fiopen(fileno(in.getCurFile()), "r")) == NULL) return FALSE; w = image_in->xsize; h = image_in->ysize; nc = image_in->zsize; bytes = new unsigned char[w*h*nc]; short *rbuf = new short[w]; int readOK = TRUE; for (row = 0; row < h; row++) { for (i = 0; i < nc; i++) { if (getrow(image_in, rbuf, row, i) < 0) { row = h; // Don't read any more rows readOK = FALSE; break; } for (j = 0; j < w; j++) { bytes[row*w*nc + j*nc + i] = (unsigned char) rbuf[j]; } } } delete [] rbuf; iclose(image_in); return TRUE; }