#include #include #include #include "pict.h" #ifdef THINK_C #include #endif #define BSPLINE 0 #define BEZIER 1 #define IW ( pict->image_W ) #define IH ( pict->image_H ) void write_file(void); float *mesh = NULL; int spl_type = BSPLINE; int u_size , v_size ; int u_order = 2; int v_order = 2; main(int argc, char** argv) { char fname[256]; Pict pict; int ni, nj, ii, jj, i, j; unsigned char pixel; float z; float *p; int maxdim; #ifdef THINK_C argc = ccommand(&argv); #endif if ( argc != 5 ) { printf("Uso: %s file w h zmax\n",argv[0]);exit(-1);} ni = atoi(argv[2]); nj = atoi(argv[3]); z = atof(argv[4]); pict = pict_read_pict( argv[1] ); u_size=ni; v_size=nj; maxdim=(IW > IH ? IW : IH); mesh= (float*)malloc(u_size*v_size*3*sizeof(float)); if ( mesh == NULL ) { fprintf(stderr,"No hay memoria, bye...\n"); exit(-1); } p=mesh; for(jj=0;jjpixels + j*IW + i); *p++ = ((float)i/(IW-1) - 0.5 )*(float)IW/maxdim; *p++ = -((float)j/(IH-1) - 0.5 )*(float)IH/maxdim; *p++ = (1.0 - (float)pixel/255.0)*z; } } write_file(); } void write_file() { FILE *f; int i,j; float *pi,*pj; f = fopen("spline.h","w"); fprintf(f,"#define\tU_BASE\t%s\n", (spl_type==BEZIER ? "Bezier" : "BSpline")); fprintf(f,"#define\tU_ORDER\t%d\n",u_order); fprintf(f,"#define\tU_SIZE\t%d\n",u_size); fprintf(f,"#define\tV_BASE\t%s\n", (spl_type==BEZIER ? "Bezier" : "BSpline")); fprintf(f,"#define\tV_ORDER\t%d\n",v_order); fprintf(f,"#define\tV_SIZE\t%d\n",v_size); fprintf(f,"float spl_data[U_SIZE][V_SIZE][3] = {\n"); pi = mesh; for (i=0; i