STEREO2.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 2.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 - 2007 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <float.h>
00027 #include <math.h>
00028 #include <windows.h>
00029 #include <commctrl.h>
00030 #include "struct.h"           /* general structures    */
00031 #include "..\common\postprocess\ximage.h"
00032 #include "local.h"
00033 
00034 #include "stereo2.h"
00035 
00036 static long version=0;
00037 
00038 #if __X__MIPS__
00039 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00040 #endif
00041 
00042 static HINSTANCE hDLLinstance=NULL; /* use to pick up resources from DLL  */
00043 
00044 #include "utils.h"
00045 
00046 unsigned char *LoadMAP(char *name, int *x, int *y);
00047 
00048 #if __WATCOMC__
00049 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00050 #elif __BC__
00051 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00052 #else
00053 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00054 #endif
00055   switch (dwReason) {
00056     case DLL_PROCESS_ATTACH:
00057 #if __X__MIPS__
00058       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00059 #endif
00060       hDLLinstance = hDLL;  /* handle to DLL file */
00061       break;
00062     case DLL_PROCESS_DETACH:
00063 #if __X__MIPS__
00064       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00065 #endif
00066       break;
00067   }
00068 return (int)TRUE;
00069 }
00070 
00071 #if __SC__
00072 #pragma startaddress(DllMain)
00073 #endif
00074 
00075 #define VECCOPY(a,b)    { b[0] = a[0]; b[1] = a[1]; b[2] = a[2]; }
00076 #define INVERT(a)       { a[0] = -a[0]; a[1] = -a[1]; a[2] = -a[2]; }
00077 #define VECSUB(a,b,c)   { c[0]=a[0]-b[0]; c[1]=a[1]-b[1]; c[2]=a[2]-b[2];}
00078 #define VECSUM(a,b,c)   { c[0]=a[0]+b[0]; c[1]=a[1]+b[1]; c[2]=a[2]+b[2];}
00079 #define VECSCALE(a,b,c) { c[0]=(a)*b[0]; c[1]=(a)*b[1]; c[2]=(a)*b[2];}
00080 #define DOT(a,b)        ( (a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]) )
00081 #define CROSS(v1,v2,r)  { \
00082                           r[0] = (v1[1]*v2[2]) - (v2[1]*v1[2]);  \
00083                           r[1] = (v1[2]*v2[0]) - (v1[0]*v2[2]);  \
00084                           r[2] = (v1[0]*v2[1]) - (v2[0]*v1[1]);  \
00085                         }
00086 #define TOL 0.1
00087 
00088 double hitpoint(vector n, vector x, vector y, vector pb, vector pf,
00089                 double * a, double * b){
00090 vector v1,p;
00091 double mu,det,ve1,ve2,ve3,vp1,vp2,vp3,p1,p2,p3;
00092 VECSUB(pb,pf,v1)
00093 mu=DOT(n,v1);
00094 VECSCALE(mu,n,v1)
00095 VECSUM(pf,v1,p)
00096 ve1=x[0]; ve2=x[1]; ve3=x[2];
00097 vp1=y[0]; vp2=y[1]; vp3=y[2];
00098 p1=p[0]-pb[0];
00099 p2=p[1]-pb[1];
00100 p3=p[2]-pb[2];
00101 det=ve1*vp2-vp1*ve2 ;
00102 if(det > TOL || det < -TOL)  /* e-10 appears not to work */
00103   {  *a=( vp2*p1-vp1*p2)/det;
00104      *b=(-ve2*p1+ve1*p2)/det;
00105      goto HIT;
00106   }
00107 det=ve1*vp3-vp1*ve3 ;
00108 if(det > TOL || det < -TOL)
00109   {  *a=( vp3*p1-vp1*p3)/det;
00110      *b=(-ve3*p1+ve1*p3)/det;
00111      goto HIT;
00112   }
00113 det=ve2*vp3-vp2*ve3 ;
00114 if(det > TOL || det < -TOL)
00115   {  *a=( vp3*p2-vp2*p3)/det;
00116      *b=(-ve3*p2+ve2*p3)/det;
00117      goto HIT;
00118   }
00119 *a = *b = 0.0;
00120 HIT:
00121 return mu;
00122 }
00123 
00124 long MapFrom(vector p,
00125              vector Mp, vector Mdx, vector Mdy, vector Mn,
00126              fullscreenbuffer *S,
00127              long Xmax, long Ymax,
00128              double *red,double *green,double *blue){
00129  long  ialpha,ibeta,i,j,k,kl,kr,kt,kb,pixel;
00130  double alpha,beta,a,b,cc0,cc1,cc2,cl0,cl1,cl2,
00131            cr0,cr1,cr2,ct0,ct1,ct2,cb0,cb1,cb2;
00132  unsigned char *pP,*pR,*pG,*pB;
00133  j=Xmax;
00134  hitpoint(Mn,Mdx,Mdy,Mp,p,&alpha,&beta);
00135  if(alpha < -0.01 || alpha > 1.01)return -1;
00136  if(beta  < -0.02 || beta  > 1.02)return -1;
00137  alpha=Xmax*alpha;
00138  beta =Ymax*beta;
00139  ialpha = (long)alpha; alpha -= (double)ialpha;
00140  ibeta  = (long)beta;  beta  -= (double)ibeta;
00141  if(ialpha < 0 || ialpha >= Xmax)return 0;
00142  if(ibeta  < 0 || ibeta  >= Ymax)return 0;
00143  k =ibeta*j+ialpha;
00144  if(ialpha <   1)kl=k; else kl=k-1;
00145  if(ialpha > j-2)kr=k; else kr=k+1;
00146  if(ibeta  <   1)kb=k; else kb=k-j;
00147  if(ibeta  > Ymax-2)kt=k; else kt=k+j;
00148  cc0 = (double)S[k].R;  cc1 = (double)S[k].G;  cc2 = (double)S[k].B;
00149  cl0 = (double)S[kl].R; cl1 = (double)S[kl].G; cl2 = (double)S[kl].B;
00150  cr0 = (double)S[kr].R; cr1 = (double)S[kr].G; cr2 = (double)S[kr].B;
00151  ct0 = (double)S[kt].R; ct1 = (double)S[kt].G; ct2 = (double)S[kt].B;
00152  cb0 = (double)S[kb].R; cb1 = (double)S[kb].G; cb2 = (double)S[kb].B;
00153  if(alpha > 0.5){
00154    alpha = alpha-0.5;
00155    if(beta > 0.5){
00156      beta = beta-0.5;
00157      *red   = (cr0-cc0)*alpha+(ct0-cc0)*beta+cc0;
00158      *green = (cr1-cc1)*alpha+(ct1-cc1)*beta+cc1;
00159      *blue  = (cr2-cc2)*alpha+(ct2-cc2)*beta+cc2;
00160    }
00161    else{
00162      beta = 0.5-beta;
00163      *red   = (cr0-cc0)*alpha+(cb0-cc0)*beta+cc0;
00164      *green = (cr1-cc1)*alpha+(cb1-cc1)*beta+cc1;
00165      *blue  = (cr2-cc2)*alpha+(cb2-cc2)*beta+cc2;
00166    }
00167  }
00168  else{
00169    alpha = 0.5-alpha;
00170    if(beta > 0.5){
00171      beta = beta-0.5;
00172      *red   = (cl0-cc0)*alpha+(ct0-cc0)*beta+cc0;
00173      *green = (cl1-cc1)*alpha+(ct1-cc1)*beta+cc1;
00174      *blue  = (cl2-cc2)*alpha+(ct2-cc2)*beta+cc2;
00175    }
00176    else{
00177      beta = 0.5-beta;
00178      *red   = (cl0-cc0)*alpha+(cb0-cc0)*beta+cc0;
00179      *green = (cl1-cc1)*alpha+(cb1-cc1)*beta+cc1;
00180      *blue  = (cl2-cc2)*alpha+(cb2-cc2)*beta+cc2;
00181    }
00182  }
00183  return 1;
00184 }
00185 
00186 fullscreenbuffer *ScaleImageMap(unsigned char *ImagePixels, int x, int y,
00187                              long X, long Y){
00188  vector p,Mn={0.0,0.0,1.0},Mx,My,Mp;
00189  double r,g,b;
00190  fullscreenbuffer *S,*s,*T,*t;
00191  unsigned char *px;
00192  long i,j;
00193  if((T=(fullscreenbuffer *)X__Malloc(x*y*sizeof(fullscreenbuffer))) == NULL){
00194    MessageBeep(MB_OK);
00195    return NULL;
00196  }
00197  px=ImagePixels; t=T;
00198  for(j=0;j<y;j++)for(i=0;i<x;i++){
00199    t->R = *px++;
00200    t->G = *px++;
00201    t->B = *px++;
00202    t++;
00203  }
00204  if((S=(fullscreenbuffer *)X__Malloc(X*Y*sizeof(fullscreenbuffer))) == NULL){
00205    MessageBeep(MB_OK);
00206    X__Free(T);
00207    return NULL;
00208  }
00209  memset(S,0,X*Y*sizeof(fullscreenbuffer));
00210  Mp[0]=Mp[1]=Mp[2]=Mx[2]=My[2]=p[2]=0.0;
00211  Mx[1]=0.0; My[0]=0.0;
00212  Mx[0]=(double)X;
00213  My[1]=(double)Y;
00214  s=S;
00215  for(i=0;i<Y;i++)for(j=0;j<X;j++){
00216    p[0]=(double)j;
00217    p[1]=(double)i;
00218    if(MapFrom(p,Mp,Mx,My,Mn,T,x,y,&r,&g,&b) > 0){
00219      s->R=(unsigned char)r;
00220      s->G=(unsigned char)g;
00221      s->B=(unsigned char)b;
00222    }
00223    s++;
00224  }
00225  X__Free(T);
00226  return S;
00227 }
00228 
00229 static void GetAnimFileName(char *fsurf, char *tempstr, long frame,
00230                        long firstframe, long lastframe, long framestep){
00231  long thisframe;
00232  char *cp1,*cp2;
00233  cp1=strchr(fsurf,'0');
00234  cp2=strchr(fsurf,'.');
00235  if(cp1 == NULL || cp2 == NULL){
00236    sprintf(tempstr,"dummy.evi");
00237  }
00238  else{
00239    int ln;
00240    char *cp,extn[16],fmat[16];
00241    strcpy(extn,cp2);
00242    ln=0; cp=cp1; while(cp != cp2){ln++; cp++; if(ln > 8)break;}
00243    *cp1='\0';
00244    framestep=min(1,framestep);
00245    thisframe=firstframe-1+frame/framestep;
00246    while(thisframe > lastframe)thisframe -= lastframe;
00247    sprintf(fmat,"%%s%%0%ldld%%s",ln);
00248    sprintf(tempstr,fmat,fsurf,thisframe,extn);
00249  }
00250  strcpy(fsurf,tempstr);
00251 }
00252 
00253 
00254 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00255  double mr;
00256  int i,j;
00257  char name_path[256],imagefile[256],conback[255];
00258  long version,type,hold,nx,ny,cR,cG,cB,back,lframe,Xmax,Ymax;
00259  fullscreenbuffer *BackBuffer=NULL,*Front;
00260  
00261  sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %s",name_path,
00262         &version,&type,&hold,
00263         &nx,&ny,&cR,&cG,&cB,&back,&lframe,imagefile);
00264  //MessageBox(NULL,PrmList,"Debug",MB_OK);
00265  back=2;
00266  sprintf(conback,"%ld",back);
00267  //MessageBox(NULL,conback,"Debug",MB_OK);
00268  if(back > 0){
00269    unsigned char *ImagePixels;
00270    int ImageXsize,ImageYsize;
00271    if(back == 2)GetAnimFileName(imagefile,name_path,
00272                      lpXimage->this_frame - lpXimage->first_frame + 1,
00273                      1,lframe,1);
00274    //MessageBox(NULL,imagefile,"Imagefile",MB_OK);
00275    if((ImagePixels=LoadMAP(imagefile,&ImageXsize,&ImageYsize)) != NULL){
00276      BackBuffer=ScaleImageMap(ImagePixels,ImageXsize,ImageYsize,lpXimage->Xmax,lpXimage->Ymax);
00277      X__Free(ImagePixels);
00278    }
00279  }
00280  else{
00281          MessageBox(NULL,"Bad Pointer",NULL,MB_OK);
00282          return 1;
00283  }
00284  Front=lpXimage->Screen;
00285  for(i=0;i<lpXimage->Ymax;i++)
00286  for(j=0;j<lpXimage->Xmax;j++){
00287    Front->R = Front->R + BackBuffer->R;
00288    Front->G = 0;
00289    Front->B = Front->B + BackBuffer->B;
00290    Front++;
00291    BackBuffer++;
00292  }
00293  return 1;
00294 }
00295 
00296 /*************** Function that renders any of the OpenGL Functionality ************/
00297 
00298 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00299 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
00300  return 1;
00301 }
00302 /**********************************************************************************/
00303 
00304 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00305 
00306 static long colour[3]={255,255,255};
00307 static long type=0,hold=0,back=0,lframe=9999,nx=10,ny=10;
00308 static char iname[256];
00309 static X__MEMORY_MANAGER *lpLocalEVI;
00310 
00311 char * _SetExternalParameters(
00312   char *Op,                 /* string for the parameters                  */
00313   HWND hWnd,                /* parent window                              */
00314   long ruler,               /* ruler scale value to facilitate scaling    */
00315   char *name,               /* name of DLL file with the effect           */
00316   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00317                                     ){
00318  char buffer[1024];
00319  long id1,id2;   /* integer scaled radius value */
00320  strcpy(iname,"-none-");
00321  if(Op != NULL){  /* parameters exist so read them off the list */
00322    sscanf(Op,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %s",buffer,&version,
00323           &type,&hold,&nx,&ny,&colour[0],&colour[1],&colour[2],
00324           &back,&lframe,iname);
00325  }
00326  lpLocalEVI=lpEVI;
00327  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_SUPER),hWnd,
00328               (DLGPROC)DlgProc) == FALSE)return Op;
00329  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00330  sprintf(buffer,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %s",
00331            name,version,type,hold,
00332            nx,ny,colour[0],colour[1],colour[2],back,lframe,iname);
00333  if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00334   MessageBox (GetFocus(),"External effect: Out of memory","Error",
00335                 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00336    return NULL;
00337  }
00338  strcpy(Op,buffer);
00339  return Op;
00340 }
00341 
00342 
00343 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00344  BOOL err;
00345  int i;
00346  char lname[255],text[512],str[255],filmname[255],*c;
00347  switch( msg ) {
00348    case WM_INITDIALOG:
00349      CentreDialogOnScreen(hwnd);
00350          GetModuleFileName(hDLLinstance,filmname,255);
00351          if((c=strrchr(filmname,'.')) != NULL){
00352            strcpy(c,".avi");
00353            Animate_Open(GetDlgItem(hwnd,IDC_ANIMATE1),filmname);
00354            Animate_Play(GetDlgItem(hwnd,IDC_ANIMATE1),0,-1,-1);
00355          }
00356          //MessageBox(NULL,iname,"Iname",MB_OK);
00357      SetDlgItemText(hwnd,DLG_VIDEO_IMAGENAME,iname);
00358          return TRUE;
00359    case WM_COMMAND:
00360      switch(LOWORD(wparam)){
00361         case DLG_VIDEO_SETIMAGENAME:{
00362             strcpy(lname,iname);
00363             if(XimageFileName(lpLocalEVI->lpAni,lname,"render",
00364                               "Choose First/Only Image File",
00365                               "Targa TGAs|*.tga|",
00366                               hwnd)){
00367 
00368               SetDlgItemText(hwnd,DLG_VIDEO_IMAGENAME,lname);
00369               strcpy(iname,lname);
00370             }
00371           }
00372           break;
00373         case IDCANCEL:
00374           EndDialog(hwnd,FALSE);
00375           return(TRUE);
00376         case IDOK:
00377           EndDialog(hwnd,TRUE);
00378           return(TRUE);
00379         default:
00380           break;
00381       }
00382       break;
00383     default: break;
00384  }
00385  return FALSE;
00386 }
00387 
00388 
00389 int colourmap_size,x_size,y_size,gif_iLace;
00390 //unsigned  char p_red[256],p_green[256],p_blue[256],*decoderline;
00391 
00392 static int rowcount;
00393 static unsigned char *pixels = NULL;
00394 
00395 static void tga_display_line(unsigned char *prgb,
00396                              long wide, long line,
00397                              long upsidedown, long hi){
00398  register long l,x,k;
00399  if(!upsidedown)l = 3L*(long)(line)*(long)(x_size);
00400  else           l = 3L*(long)(hi - 1 - line)*(long)(x_size);
00401  memcpy(pixels + l, prgb, (int)(wide*3));
00402 }
00403 
00404 static short R_getvariword(long n, FILE *f, long *vw){
00405  long c;
00406  if((c=(long)getc(f)) == EOF)return 0;
00407  *vw = c;          if(n == 1)return 1;
00408  if((c=(long)getc(f)) == EOF)return 0;
00409  *vw |= (c << 8);  if(n == 2)return 1;
00410  if((c=(long)getc(f)) == EOF)return 0;
00411  *vw |= (c << 16); if(n == 3)return 1;
00412  if((c=(long)getc(f)) == EOF)return 0;
00413  *vw |= (c << 24);
00414  return 1;
00415 }
00416 
00417 static short read_tga_image(char *filename, short info_only){
00418  char c0,c1,c2;
00419  long i,j,k,l,m,n,cmo,cml,xor,yor,wi,hi,iok=0,idsize,cm_type,vw,
00420       image_type,cmes,pixel_size,image_descriptor,n_attr,upsidedown,b_size,
00421       s1,s2,s,pat,wi3;
00422  FILE *t24;
00423  unsigned char *prgb;
00424  prgb=NULL;
00425  if((t24=fopen(filename,"rb")) != NULL){
00426    if(! R_getvariword(1,t24,&idsize))goto CLOSEOUT;
00427    if(! R_getvariword(1,t24,&cm_type))goto CLOSEOUT; /* 0 for non mapped */
00428    if(! R_getvariword(1,t24,&image_type))goto CLOSEOUT; /* image type */
00429    if(image_type != 2 && image_type != 10)goto CLOSEOUT;
00430    if(! R_getvariword(2,t24,&cmo))goto CLOSEOUT;  /* color map 5 bytes */
00431    if(! R_getvariword(2,t24,&cml))goto CLOSEOUT;
00432    if(! R_getvariword(1,t24,&cmes))goto CLOSEOUT;
00433    if(! R_getvariword(2,t24,&xor))goto CLOSEOUT;  /* Image spec 10 bytes */
00434    if(! R_getvariword(2,t24,&yor))goto CLOSEOUT;
00435    if(! R_getvariword(2,t24,&wi))goto CLOSEOUT;
00436    if(! R_getvariword(2,t24,&hi))goto CLOSEOUT;
00437    if(! R_getvariword(1,t24,&pixel_size))goto CLOSEOUT;
00438    if(! R_getvariword(1,t24,&image_descriptor))goto CLOSEOUT;
00439    if(idsize > 0)for(i=0;i<idsize;i++)if(getc(t24) == EOF)goto CLOSEOUT;
00440    if(cm_type == 1 && cml > 0){
00441      for(i=cmo;i<cml;i++)if(! R_getvariword(cmes/8,t24,&j))goto CLOSEOUT;
00442    }
00443    n_attr = image_descriptor & 0xf;
00444    upsidedown = (image_descriptor & 0x20) > 0 ? 0 : 1 ;
00445    if(info_only){
00446      x_size=(int)wi;
00447      y_size=(int)hi;
00448      fclose(t24);
00449      return 1;
00450    }
00451    if((prgb=(unsigned char *)X__Malloc((size_t)wi*3)) == NULL)goto CLOSEOUT;
00452    if((image_descriptor & 0xc0) > 0)goto CLOSEOUT; /* interlaced */
00453    b_size=i=wi*hi;
00454    if     (pixel_size == 16){n=2;s1=5;s2=10;s=3;pat=0x1f;}
00455    else if(pixel_size == 24){n=3;s1=8;s2=16;s=0;pat=0xff;}
00456    else                     {n=4;s1=8;s2=16;s=0;pat=0xff;}
00457    wi3=wi*3;
00458    if(image_type == 2){ /* uncompressed */
00459      m=0; k=0; for(i=0;i<hi;i++)for(j=0;j<wi;j++){
00460        if(! R_getvariword(n,t24,&vw))goto CLOSEOUT;
00461        prgb[m+2] = (char)( vw        & pat) << s;
00462        prgb[m+1] = (char)((vw >> s1) & pat) << s;
00463        prgb[m  ] = (char)((vw >> s2) & pat) << s;
00464        k++; m+=3;
00465        if(m == wi3){
00466          tga_display_line(prgb,wi,i,upsidedown,hi); m=0;
00467        }
00468      }
00469    }
00470    else{  /* compressed */
00471      m=0; l=0; k=0; while(k < b_size){
00472        i=getc(t24); if(feof(t24))goto CLOSEOUT;
00473         if(i < 128){
00474          for(j=0;j<i+1;j++){
00475            if(! R_getvariword(n,t24,&vw))goto CLOSEOUT;
00476            prgb[m+2] = (char)( vw        & pat) << s;
00477            prgb[m+1] = (char)((vw >> s1) & pat) << s;
00478            prgb[m  ] = (char)((vw >> s2) & pat) << s;
00479            k++; m+=3;
00480            if(m == wi3){
00481              tga_display_line(prgb,wi,l,upsidedown,hi); m=0; l++;
00482            }
00483          }
00484        }
00485        else{
00486          if(! R_getvariword(n,t24,&vw))goto CLOSEOUT;
00487          c0 = (char)( vw        & pat) << s;
00488          c1 = (char)((vw >> s1) & pat) << s;
00489          c2 = (char)((vw >> s2) & pat) << s;
00490          i -= 128;
00491          for(j=0;j<i+1;j++){
00492            prgb[m+2] = c0;
00493            prgb[m+1] = c1;
00494            prgb[m  ] = c2;
00495            k++;  m+=3;
00496            if(m == wi3){
00497              tga_display_line(prgb,wi,l,upsidedown,hi); m=0; l++;
00498            }
00499          }
00500        }
00501      }
00502    }
00503    iok=1;
00504    CLOSEOUT:
00505    fclose(t24);
00506    if(prgb != NULL)X__Free((char *)prgb);
00507  }
00508  return (short)iok;
00509 }
00510 
00511 static unsigned char *LoadTGA(char *TGAfile, int *xx, int *yy){
00512  long imagesize;
00513  char consize[255];
00514  rowcount=0;
00515  //MessageBox(NULL,TGAfile,"Reading TGA",MB_OK);
00516  if(read_tga_image(TGAfile,1) < 0)return 0;
00517  imagesize=x_size*y_size*3;
00518  //sprintf(consize,"%ld",imagesize);
00519  //MessageBox(NULL,consize,"Imagesize",MB_OK);
00520  if((pixels=(unsigned char*)X__Malloc(imagesize)) == NULL)return NULL;
00521  if(read_tga_image(TGAfile,0) < 0){
00522    X__Free(pixels);
00523    return NULL;
00524  }
00525  *xx=x_size; *yy=y_size;
00526  return pixels;
00527 }
00528 
00529 unsigned char *LoadMAP(char *CurrentFile, int *xx, int *yy){
00530  int ff;
00531  if(strstr(CurrentFile,".TGA") || strstr(CurrentFile,".tga"))
00532    return LoadTGA(CurrentFile,xx,yy);
00533  return NULL;
00534 }

Generated on Sun Apr 27 14:20:12 2014 for OpenFX by  doxygen 1.5.6