/*\ * This file is part of a 360 degree unwrap utility * Copyright (C) 2000 Oliver Knill * * 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. * * 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., 675 Mass Ave, Cambridge, MA 02139, USA. \*/ /*---------------------------------------------------------------------------*/ /* unwrap.c */ /*---------------------------------------------------------------------------*/ #include #include #include #include #define Pi 3.1415926535897932 #define TWO_PI_INV 0.1591549430918953 #define X_SIZE 2938 // x-dimension of output picture #define Y_SIZE 879 // y-dimension of output picture double mod(double r) { r=r-floor(r); return(r); } void unwrap(char *image, int x_size, int y_size, double lambda){ int i, j, p,q; double x,y; double xx,yy; double nx,ny; double rr; double ff; // scaling factor ff= ysize/xsize char *ptr; for(j = 0; j > -Y_SIZE; j--) // ppmimage = { (i,j) in ZxZ | for(i = 0 ; i < X_SIZE; i++){ // 0<=i -y_size && q <= 0){ ptr = image + 3 * ((-q) * x_size + p); fputc(*ptr++,stdout); fputc(*ptr++,stdout); fputc(*ptr,stdout); } else{ fputc(0,stdout); fputc(0,stdout); fputc(0,stdout); } } } int main(int argc, char *argv[]){ int i, x_size, y_size, c_size; char buffer[1025], *image, *ptr; double lambda; FILE *in; if((in = fopen(argv[1],"rb")) == NULL){ fprintf(stderr,"Can't open file %s\n", argv[1]); exit(1); } fgets(buffer,1025,in); if(strncmp(buffer,"P6",2)){ fprintf(stderr,"Unsupported file format (need PPM raw)\n"); exit(1); } do fgets(buffer,1025,in); while(*buffer == '#'); // get picture dimension x_size = atoi(strtok(buffer," ")); y_size = atoi(strtok(NULL," ")); fgets(buffer,1025,in); // get color map size c_size = atoi(buffer); // allocate memory for the input picture if((image = (char *) malloc(3*x_size*y_size*sizeof(char)))==NULL){ fprintf(stderr,"Memory allocation error while loading picture\n"); exit(1); } // actually read in the picture i = 0; ptr = image; while(!feof(in) && i<3*x_size*y_size){ *ptr++ = fgetc(in); i++;} fclose(in); if(i