00001
00002
00003
00004
00005
00006
00007 #include <stdlib.h>
00008 #include <stdio.h>
00009 #include <float.h>
00010 #include <math.h>
00011 #include <windows.h>
00012 #include <commctrl.h>
00013 #include "struct.h"
00014 #include "..\common\postprocess\ximage.h"
00015 #include "local.h"
00016
00017 #include "xvideo.h"
00018
00019 static long version=0;
00020
00021 #if __X__MIPS__
00022 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00023 #endif
00024
00025 static HINSTANCE hDLLinstance=NULL;
00026
00027 #include "utils.h"
00028 #include "paint.c"
00029
00030 #include "..\animate\wspaces.c"
00031
00032 #include "video1.c"
00033
00034 #define imod(z,a) ((z) - ((z)/(a))*(a))
00035
00036 unsigned char *LoadMAP(char *name, int *x, int *y);
00037
00038 #if __WATCOMC__
00039 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00040 #elif __BC__
00041 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00042 #else
00043 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00044 #endif
00045 switch (dwReason) {
00046 case DLL_PROCESS_ATTACH:
00047 #if __X__MIPS__
00048 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00049 #endif
00050 hDLLinstance = hDLL;
00051 break;
00052 case DLL_PROCESS_DETACH:
00053 #if __X__MIPS__
00054 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00055 #endif
00056 break;
00057 }
00058 return (int)TRUE;
00059 }
00060
00061 #if __SC__
00062 #pragma startaddress(DllMain)
00063 #endif
00064
00065 static void TwoByTwo(double mr, fullscreenbuffer *Screen, long Xmax, long Ymax,
00066 long nx, long ny, long R, long G, long B, long type,
00067 fullscreenbuffer *Bb){
00068 vector p,Mn={0.0,0.0,1.0},Mx,My,Mp[50];
00069 double r,g,b;
00070 long i,j,k,w,border,dx,dy,x,y;
00071 fullscreenbuffer *S,*T,*Tcreen, *bb;
00072 if((Tcreen=(fullscreenbuffer *)X__Malloc(Xmax*Ymax*sizeof(fullscreenbuffer))) == NULL){
00073 MessageBeep(MB_OK);
00074 return;
00075 }
00076 nx = min(10,nx);
00077 ny = min(5,ny);
00078 nx = 1+(nx-1)*mr;
00079 ny = 1+(ny-1)*mr;
00080 T=Tcreen; S=Screen;
00081 memset(T,0,Xmax*Ymax*sizeof(fullscreenbuffer));
00082 for(k=0;k<nx*ny;k++)Mp[k][2]=0.0;
00083 Mx[2]=My[2]=p[2]=Mx[1]=My[0]=0.0;
00084 border=(2*Xmax)/320;
00085 dx=(Xmax-(nx+1)*border)/nx;
00086 dy=(Ymax-(ny+1)*border)/ny;
00087 Mx[0]=dx; My[1]=dy;
00088 y=border; k=0;for(j=0;j<ny;j++){
00089 x=border;
00090 for(i=0;i<nx;i++){
00091 Mp[k][0]=x;
00092 Mp[k][1]=y;
00093 x += (dx+border);
00094 k++;
00095 }
00096 y += (dy+border);
00097 }
00098 for(i=0;i<Ymax;i++)for(j=0;j<Xmax;j++){
00099 p[0]=(double)j;
00100 p[1]=(double)i;
00101 for(k=0;k<nx*ny;k++){
00102 if((w=MapFrom(p,Mp[k],Mx,My,Mn,Screen,Xmax,Ymax,&r,&g,&b)) > 0){
00103 T->R=(unsigned char)r;
00104 T->G=(unsigned char)g;
00105 T->B=(unsigned char)b;
00106 goto NEXTPIXEL;
00107 }
00108 }
00109 if(Bb != NULL){
00110 bb=(Bb+i*Xmax+j);
00111 T->R=(unsigned char)bb->R;
00112 T->G=(unsigned char)bb->G;
00113 T->B=(unsigned char)bb->B;
00114 }
00115 else{
00116 T->R=(unsigned char)R;
00117 T->G=(unsigned char)G;
00118 T->B=(unsigned char)B;
00119 }
00120 NEXTPIXEL:
00121 T->A=S->A;
00122 S++;
00123 T++;
00124 }
00125 memcpy(Screen,Tcreen,Xmax*Ymax*sizeof(fullscreenbuffer));
00126 X__Free(Tcreen);
00127 }
00128
00129 static void WipeRandomBlocks(double mr, fullscreenbuffer *S,
00130 long Xmax, long Ymax,
00131 long nnx, long nny, long R, long G, long B,
00132 fullscreenbuffer *Bb){
00133 long i,j,k,l,nx,ny,n,nb,ii,jj,id,*blockid;
00134 fullscreenbuffer *s,*bb;
00135 if(nnx < 1 || nny < 1 || nnx > Xmax || nny > Ymax || nnx > 64 || nny > 64)return;
00136 nx = Xmax/nnx; ny=Ymax/nny;
00137 if(nx*nnx < Xmax)nx++;
00138 if(ny*nny < Ymax)ny++;
00139 ii=0; for(i=0;i<Ymax;i+=ny){jj=0;for(j=0;j<Xmax;j+=nx){jj++;}ii++;}nb=ii*jj;
00140 if((blockid = (long *)X__Malloc(nb*sizeof(long))) == NULL)return;
00141 for(i=0;i<nb;i++)blockid[i]=i;
00142 n=(long)((double)nnx*(double)nny*mr);
00143 ii=nb-1; for(i=0;i<n;i++){
00144 id=(long)(((double)rand()*(double)ii)/32767.0);
00145 for(j=0;j<nb;j++){
00146 if(blockid[j] == id)blockid[j]= -1;
00147 else if(blockid[j] > id)blockid[j]=blockid[j]-1;
00148 }
00149 ii--;
00150 }
00151 ii=0;
00152 for(i=0;i<Ymax;i+=ny){
00153 jj=0;
00154 for(j=0;j<Xmax;j+=nx){
00155 id=ii*nnx+jj;
00156 for(k=i;k<i+ny;k++)for(l=j;l<j+nx;l++){
00157 if(id < nb && blockid[id] < 0 && l < Xmax && k < Ymax){
00158 s=(S+k*Xmax+l);
00159 if(Bb != NULL){
00160 bb=(Bb+k*Xmax+l);
00161 s->R=(unsigned char)bb->R;
00162 s->G=(unsigned char)bb->G;
00163 s->B=(unsigned char)bb->B;
00164 }
00165 else{
00166 s->R = (unsigned char)R;
00167 s->G = (unsigned char)G;
00168 s->B = (unsigned char)B;
00169 }
00170 }
00171 }
00172 jj++;
00173 }
00174 ii++;
00175 }
00176 X__Free(blockid);
00177 return;
00178 }
00179
00180
00181 static void GetP(vector pc, vector d, vector Mp, vector Mn, vector p){
00182 double mu;
00183 vector dp;
00184 VECSUB(Mp,pc,dp)
00185 mu=DOT(Mn,dp)/DOT(Mn,d);
00186 VECSCALE(mu,d,d)
00187 VECSUM(pc,d,p)
00188 }
00189
00190 static void FoldPiP(double mr, fullscreenbuffer *Screen, long Xmax, long Ymax,
00191 long nx, long ny, long R, long G, long B, long type,
00192 fullscreenbuffer *Bb){
00193 vector p,pc,d,Mn={0.0,0.0,1.0},Mx,My,Mp,x,y,n,wt,Mw={1.0,0.0,0.0};
00194 double r,g,b;
00195 long i,j,w;
00196 double Tx[4][4],Ta[4][4],Tb[4][4],Ts[4][4],angle,ss;
00197 vector Mxx;
00198 fullscreenbuffer *T,*Tcreen,*bb;
00199 if((Tcreen=(fullscreenbuffer *)X__Malloc(Xmax*Ymax*sizeof(fullscreenbuffer))) == NULL){
00200 MessageBeep(MB_OK);
00201 return;
00202 }
00203 memset(Tcreen,0,Xmax*Ymax*sizeof(fullscreenbuffer));
00204 Mp[2]=Mx[2]=My[2]=p[2]=0.0;
00205 Mx[1]=0.0; My[0]=0.0;
00206 nx = max(nx,0);
00207 angle = nx*mr;
00208 angle *= PI/180.0;
00209 if(type > 0){
00210 Mx[0]=(double)Xmax;
00211 My[1]=(double)Ymax;
00212 Mp[0]=0.0;
00213 Mp[1]=0.0;
00214 tram(Ta,-(double)Xmax*0.5,-(double)Ymax*0.5,0.0);
00215 if(type == 1)roty(Tx,angle);
00216 if(type == 2)rotz(Tx,angle);
00217 if(type == 3)rotx(Tx,-angle);
00218 if(type == 4){
00219 rotz(Tx,angle);
00220 m4by1(Tx,Mw,wt);
00221 rotate_round_vector(angle*180.0/PI,wt,Tx);
00222 }
00223 m4by4(Tx,Ta,Tb);
00224 ny=min(ny,100);
00225 ss=(double)ny * 0.01;
00226 ss=1.0-mr*(1.0-ss);
00227 scal(Ts,ss,ss,ss);
00228 m4by4(Ts,Tb,Ta);
00229 tram(Tx,(double)Xmax*0.5,(double)Ymax*0.5,0.0);
00230 m4by4(Tx,Ta,Tb);
00231 m4by1(Tb,Mx,x);
00232 m4by1(Tb,My,y);
00233 VECCOPY(Mp,Mxx)
00234 m4by1(Tb,Mxx,Mp);
00235 VECSUB(x,Mp,Mx)
00236 VECSUB(y,Mp,My)
00237 m4by1(Tb,Mn,n);
00238 VECSUB(n,Mp,Mn);
00239 }
00240 T=Tcreen;
00241 for(i=0;i<Ymax;i++)for(j=0;j<Xmax;j++){
00242 pc[0] = (double)(Xmax/2);
00243 pc[1] = (double)(Ymax/2);
00244 pc[2] = (double)(-Xmax*2);
00245 d[0] = (double)(j-Xmax/2);
00246 d[1] = (double)(i-Ymax/2);
00247 d[2] = -pc[2];
00248 GetP(pc,d,Mp,Mn,p);
00249 if((w=MapFrom(p,Mp,Mx,My,Mn,Screen,Xmax,Ymax,&r,&g,&b)) > 0){
00250 T->R=(unsigned char)r;
00251 T->G=(unsigned char)g;
00252 T->B=(unsigned char)b;
00253 }
00254 else if(Bb != NULL){
00255 bb=(Bb+i*Xmax+j);
00256 T->R=(unsigned char)bb->R;
00257 T->G=(unsigned char)bb->G;
00258 T->B=(unsigned char)bb->B;
00259 }
00260 else{
00261 T->R=(unsigned char)R;
00262 T->G=(unsigned char)G;
00263 T->B=(unsigned char)B;
00264 }
00265 T++;
00266 }
00267 memcpy(Screen,Tcreen,Xmax*Ymax*sizeof(fullscreenbuffer));
00268 X__Free(Tcreen);
00269 }
00270
00271 static void Inlay(double mr, fullscreenbuffer *S, long Xmax, long Ymax,
00272 long R, long G, long B, fullscreenbuffer *Bb){
00273 long i,j;
00274 double mix;
00275 for(i=0;i<Ymax;i++)for(j=0;j<Xmax;j++){
00276 if(S->A > 0){
00277 mix = (double)S->A*3.921568e-3*mr;
00278 if(Bb != NULL){
00279 S->R = (unsigned char)((double)(S->R)*(1.0-mix)+(double)Bb->R*mix);
00280 S->G = (unsigned char)((double)(S->G)*(1.0-mix)+(double)Bb->G*mix);
00281 S->B = (unsigned char)((double)(S->B)*(1.0-mix)+(double)Bb->B*mix);
00282 }
00283 else{
00284 S->R = (unsigned char)((double)(S->R)*(1.0-mix)+(double)R*mix);
00285 S->G = (unsigned char)((double)(S->G)*(1.0-mix)+(double)G*mix);
00286 S->B = (unsigned char)((double)(S->B)*(1.0-mix)+(double)B*mix);
00287 }
00288 }
00289 S++;
00290 if(Bb != NULL)Bb++;
00291 }
00292 return;
00293 }
00294
00295 static void Slice(double mr, long ny,
00296 fullscreenbuffer *S, long Xmax, long Ymax,
00297 long R, long G, long B, fullscreenbuffer *Bb){
00298 BOOL right;
00299 long i,j,k,dy,dx;
00300 fullscreenbuffer *s,*b;
00301 fullscreenbuffer *T,*t;
00302 dy=Ymax/max(1,ny);
00303 dx=(long)((double)Xmax*mr);
00304 if((T=(fullscreenbuffer *)X__Malloc(Xmax*Ymax*sizeof(fullscreenbuffer))) == NULL){
00305 MessageBeep(MB_OK);
00306 return;
00307 }
00308 right=TRUE;
00309 for(k=0;k<Ymax;k+=dy){
00310 for(i=k;i<k+dy;i++)for(j=0;j<Xmax;j++){
00311 if(i >= Ymax)continue;
00312 t=(T+i*Xmax+j);
00313 if(Bb != NULL)b=(Bb+i*Xmax+j);
00314 if(right){
00315 if(j > dx){
00316 if(j-dx < Xmax){
00317 s=(S+i*Xmax+j-dx);
00318 t->R = s->R;
00319 t->G = s->G;
00320 t->B = s->B;
00321 }
00322 }
00323 else if(Bb != NULL){
00324 t->R = b->R;
00325 t->G = b->G;
00326 t->B = b->B;
00327 }
00328 else{
00329 t->R = (unsigned char)R;
00330 t->G = (unsigned char)G;
00331 t->B = (unsigned char)B;
00332 }
00333 }
00334 else{
00335 if(j < Xmax-dx){
00336 if(j+dx < Xmax && j+dx >= 0){
00337 s=(S+i*Xmax+j+dx);
00338 t->R = s->R;
00339 t->G = s->G;
00340 t->B = s->B;
00341 }
00342 }
00343 else if(Bb != NULL){
00344 t->R = b->R;
00345 t->G = b->G;
00346 t->B = b->B;
00347 }
00348 else{
00349 t->R = (unsigned char)R;
00350 t->G = (unsigned char)G;
00351 t->B = (unsigned char)B;
00352 }
00353 }
00354 }
00355 right ^= 1;
00356 }
00357 memcpy(S,T,Xmax*Ymax*sizeof(fullscreenbuffer));
00358 X__Free(T);
00359 return;
00360 }
00361
00362 static void FogIn(double mr, fullscreenbuffer *S, long Xmax, long Ymax,
00363 long R, long G, long B,
00364 fullscreenbuffer *Bb,
00365 float *Zb){
00366 float *z;
00367 long i,j;
00368 double mix,zmin = FARAWAY, zmax = -FARAWAY,dz,zi,zj,dzz;
00369 if((z=Zb) == NULL)return;
00370 for(i=0;i<Ymax;i++)for(j=0;j<Xmax;j++){
00371 if(*z < FARAWAY-1000){
00372 if(*z < zmin)zmin = *z;
00373 if(*z > zmax)zmax = *z;
00374 }
00375 z++;
00376 }
00377 if((dz=zmax-zmin) == 0.0)return;
00378 dzz=dz/5.0;
00379 dz=dz+dzz;
00380 zj=zmin+dz*mr;
00381 zi=zj-dzz;
00382 z=Zb;
00383 for(i=0;i<Ymax;i++)for(j=0;j<Xmax;j++){
00384 if(*z > zi){
00385 if(*z > zj){
00386 if(Bb != NULL){
00387 S->R = Bb->R;
00388 S->G = Bb->G;
00389 S->B = Bb->B;
00390 }
00391 else{
00392 S->R = R;
00393 S->G = G;
00394 S->B = B;
00395 }
00396 }
00397 else{
00398 mix = (*z - zi)/dzz;
00399 if(Bb != NULL){
00400 S->R = (unsigned char)((double)(S->R)*(1.0-mix)+(double)Bb->R*mix);
00401 S->G = (unsigned char)((double)(S->G)*(1.0-mix)+(double)Bb->G*mix);
00402 S->B = (unsigned char)((double)(S->B)*(1.0-mix)+(double)Bb->B*mix);
00403 }
00404 else{
00405 S->R = (unsigned char)((double)(S->R)*(1.0-mix)+(double)R*mix);
00406 S->G = (unsigned char)((double)(S->G)*(1.0-mix)+(double)G*mix);
00407 S->B = (unsigned char)((double)(S->B)*(1.0-mix)+(double)B*mix);
00408 }
00409 }
00410 }
00411 z++;
00412 S++;
00413 if(Bb != NULL)Bb++;
00414 }
00415 return;
00416 }
00417
00418 static long *GenerateRandomSelection(long nb);
00419 static void sRandom(long i);
00420
00421 static void WipeRandomBits(double mr, fullscreenbuffer *S,
00422 long Xmax, long Ymax,
00423 long nnx, long nny, long R, long G, long B,
00424 fullscreenbuffer *Bb){
00425 long i,ii,j,jj,k,l,m,nx,ny,n,nb,id,*blockid;
00426 fullscreenbuffer *s,*bb;
00427 if(nnx < 1 || nny < 1 || nnx > Xmax || nny > Ymax)return;
00428
00429
00430
00431 nx = nnx; ny=nny;
00432 nnx = Xmax/nx;
00433 nny = Ymax/ny;
00434 ii=0; for(i=0;i<Ymax;i+=ny){jj=0;for(j=0;j<Xmax;j+=nx){jj++;}ii++;}nb=ii*jj;
00435 n=(long)((double)nnx*(double)nny*mr);
00436 if((blockid=GenerateRandomSelection(nb)) == NULL){
00437 MessageBeep(MB_OK);
00438 return;
00439 }
00440 for(m=0;m<n;m++){
00441 id=blockid[m];
00442 i=id/nnx;
00443 j=(id-(i*nnx));
00444 i=i*ny;
00445 j=j*nx;
00446 for(k=i;k<i+ny;k++)for(l=j;l<j+nx;l++){
00447 if(l < Xmax && k < Ymax){
00448 s=(S+k*Xmax+l);
00449 if(Bb != NULL){
00450 bb=(Bb+k*Xmax+l);
00451 s->R=(unsigned char)bb->R;
00452 s->G=(unsigned char)bb->G;
00453 s->B=(unsigned char)bb->B;
00454 }
00455 else{
00456 s->R = (unsigned char)R;
00457 s->G = (unsigned char)G;
00458 s->B = (unsigned char)B;
00459 }
00460 }
00461 }
00462 }
00463 X__Free(blockid);
00464 return;
00465 }
00466
00467 #if 0
00468 static void OldWhiteNoiseBackground(double mr,
00469 long frame, fullscreenbuffer *S,
00470 long Xmax, long Ymax,
00471 long param,
00472 long R, long G, long B,
00473 fullscreenbuffer *Bb){
00474 double pc;
00475 long i,ii,j,jj,k,l,m,nx,ny,n,nb,id,*blockid,nny,nnx;
00476 fullscreenbuffer *s,*bb;
00477 param=min(param,100);
00478 pc = 0.005*(double)param*mr;
00479 ny = nx = (2*Xmax)/320;
00480 nnx = Xmax/nx;
00481 nny = Ymax/ny;
00482 ii=0; for(i=0;i<Ymax;i+=ny){jj=0;for(j=0;j<Xmax;j+=nx){jj++;}ii++;}nb=ii*jj;
00483 n=(long)((double)nnx*(double)nny)*pc;
00484 if(n == 0)return;
00485 n=min(n,nb);
00486 sRandom(frame);
00487 if((blockid=GenerateRandomSelection(nb)) == NULL){
00488 MessageBeep(MB_OK);
00489 return;
00490 }
00491 for(m=0;m<n;m++){
00492 id=blockid[m];
00493 i=id/nnx;
00494 j=(id-(i*nnx));
00495 i=i*ny;
00496 j=j*nx;
00497 for(k=i;k<i+ny;k++)for(l=j;l<j+nx;l++){
00498 if(l < Xmax && k < Ymax){
00499 s=(S+k*Xmax+l);
00500 if(s->A > 0)continue;
00501 if(Bb != NULL){
00502 bb=(Bb+k*Xmax+l);
00503 s->R=(unsigned char)bb->R;
00504 s->G=(unsigned char)bb->G;
00505 s->B=(unsigned char)bb->B;
00506 }
00507 else{
00508 s->R = (unsigned char)R;
00509 s->G = (unsigned char)G;
00510 s->B = (unsigned char)B;
00511 }
00512 }
00513 }
00514 }
00515 X__Free(blockid);
00516 return;
00517 }
00518 #endif
00519
00520 static void WhiteNoise(double mr,
00521 long frame, fullscreenbuffer *S,
00522 long Xmax, long Ymax,
00523 long param,
00524 long R, long G, long B,
00525 BOOL include_foreground){
00526 double pc,r;
00527 long i,j,k,l,step,d;
00528 fullscreenbuffer *s,*bb;
00529 param=min(param,100);
00530 pc = 0.01*(double)param*mr;
00531 step=max(1,Xmax/320);
00532 srand(frame);
00533 for(i=0;i<Ymax;i+=step)for(j=0;j<Xmax;j+=step){
00534 r=(double)rand()/32767.0;
00535 d=min(255,(long)((rand()*255)/32767));
00536 for(k=i;k<i+step;k++)for(l=j;l<j+step;l++){
00537 if(k >= Ymax || l >= Xmax)continue;
00538 s=(S+k*Xmax+l);
00539 if(include_foreground || s->A < 64){
00540 if(r < pc){
00541 s->R = (unsigned char)d;
00542 s->G = (unsigned char)d;
00543 s->B = (unsigned char)d;
00544 }
00545 }
00546 }
00547 }
00548 return;
00549 }
00550
00551 static void WipeLR(double mr, fullscreenbuffer *S, long Xmax, long Ymax,
00552 long R, long G, long B, fullscreenbuffer *Bb){
00553 long i,j;
00554 long w,dx;
00555 fullscreenbuffer *bb;
00556 double f;
00557 dx=Xmax/5;
00558 w = -dx + (long)((double)(Xmax+dx)*mr);
00559 for(i=0;i<Ymax;i++){
00560 for(j=0;j<Xmax;j++){
00561 if(j < w){
00562 if(Bb != NULL){
00563 bb=(Bb+i*Xmax+j);
00564 S->R=(unsigned char)bb->R;
00565 S->G=(unsigned char)bb->G;
00566 S->B=(unsigned char)bb->B;
00567 }
00568 else{
00569 S->R = (unsigned char)R;
00570 S->G = (unsigned char)G;
00571 S->B = (unsigned char)B;
00572 }
00573 }
00574 else if(j < w+dx){
00575 f = 1.0-(double)(j-w)/(double)dx;
00576 if(Bb != NULL){
00577 bb=(Bb+i*Xmax+j);
00578 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00579 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00580 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00581 }
00582 else{
00583 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00584 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00585 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00586 }
00587 }
00588 S++;
00589 }
00590 }
00591 }
00592
00593 static void WipeRL(double mr, fullscreenbuffer *S, long Xmax, long Ymax,
00594 long R, long G, long B, fullscreenbuffer *Bb){
00595 long i,j;
00596 long w,dx;
00597 fullscreenbuffer *bb;
00598 double f;
00599 dx=Xmax/5;
00600 w=Xmax-(long)((double)(Xmax+dx)*mr);
00601 for(i=0;i<Ymax;i++){
00602 for(j=0;j<Xmax;j++){
00603 if(j >= w+dx){
00604 if(Bb != NULL){
00605 bb=(Bb+i*Xmax+j);
00606 S->R=(unsigned char)bb->R;
00607 S->G=(unsigned char)bb->G;
00608 S->B=(unsigned char)bb->B;
00609 }
00610 else{
00611 S->R = (unsigned char)R;
00612 S->G = (unsigned char)G;
00613 S->B = (unsigned char)B;
00614 }
00615 }
00616 else if(j > w){
00617 f = (double)(j-w)/(double)dx;
00618 if(Bb != NULL){
00619 bb=(Bb+i*Xmax+j);
00620 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00621 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00622 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00623 }
00624 else{
00625 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00626 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00627 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00628 }
00629 }
00630 S++;
00631 }
00632 }
00633 }
00634
00635 static void xWipeToCentre(double mr, long nx,
00636 fullscreenbuffer *S,
00637 long Xmax, long Ymax,
00638 long R, long G, long B,
00639 fullscreenbuffer *Bb){
00640 long i,j;
00641 long w1,w2,dx;
00642 fullscreenbuffer *bb;
00643 double f;
00644 nx=max(1,nx);
00645 nx=min(100,nx);
00646 dx=(Xmax*nx)/100;
00647 w1 = -dx + (long)((double)(Xmax/2+dx)*mr);
00648 w2 = Xmax + dx - (long)((double)(Xmax/2+dx)*mr);
00649 for(i=0;i<Ymax;i++){
00650 for(j=0;j<Xmax;j++){
00651 if(j < w1 || j >= w2){
00652 if(Bb != NULL){
00653 bb=(Bb+i*Xmax+j);
00654 S->R=(unsigned char)bb->R;
00655 S->G=(unsigned char)bb->G;
00656 S->B=(unsigned char)bb->B;
00657 }
00658 else{
00659 S->R = (unsigned char)R;
00660 S->G = (unsigned char)G;
00661 S->B = (unsigned char)B;
00662 }
00663 }
00664 else if(j < w1+dx || j >= w2-dx){
00665 if(j < Xmax/2)f = 1.0-(double)(j-w1)/(double)dx;
00666 else f = (double)(j-(w2-dx))/(double)dx;
00667 if(Bb != NULL){
00668 bb=(Bb+i*Xmax+j);
00669 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00670 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00671 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00672 }
00673 else{
00674 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00675 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00676 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00677 }
00678 }
00679 S++;
00680 }
00681 }
00682 }
00683
00684 static void xWipeFromCentre(double mr, long nx,
00685 fullscreenbuffer *S,
00686 long Xmax, long Ymax,
00687 long R, long G, long B,
00688 fullscreenbuffer *Bb){
00689 long i,j;
00690 long w1,w2,dx;
00691 fullscreenbuffer *bb;
00692 double f;
00693 nx=max(1,nx);
00694 nx=min(100,nx);
00695 dx=(Xmax*nx)/100;
00696 w1 = Xmax/2 - (long)((double)(Xmax/2+dx)*mr);
00697 w2 = Xmax/2 + (long)((double)(Xmax/2+dx)*mr);
00698 for(i=0;i<Ymax;i++){
00699 for(j=0;j<Xmax;j++){
00700 if(j > w1+dx && j < w2-dx){
00701 if(Bb != NULL){
00702 bb=(Bb+i*Xmax+j);
00703 S->R=(unsigned char)bb->R;
00704 S->G=(unsigned char)bb->G;
00705 S->B=(unsigned char)bb->B;
00706 }
00707 else{
00708 S->R = (unsigned char)R;
00709 S->G = (unsigned char)G;
00710 S->B = (unsigned char)B;
00711 }
00712 }
00713 else if(j < w1 || j >= w2){;}
00714 else {
00715 if(j < Xmax/2)f = (double)(j-w1)/(double)dx;
00716 else f = 1.0-(double)(j-(w2-dx))/(double)dx;
00717 if(Bb != NULL){
00718 bb=(Bb+i*Xmax+j);
00719 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00720 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00721 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00722 }
00723 else{
00724 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00725 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00726 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00727 }
00728 }
00729 S++;
00730 }
00731 }
00732 }
00733
00734 static void yWipeToCentre(double mr, long ny,
00735 fullscreenbuffer *S,
00736 long Xmax, long Ymax,
00737 long R, long G, long B,
00738 fullscreenbuffer *Bb){
00739 long i,j;
00740 long w1,w2,dy;
00741 fullscreenbuffer *bb;
00742 double f;
00743 ny=max(1,ny);
00744 ny=min(100,ny);
00745 dy=(Ymax*ny)/100;
00746 w1 = -dy + (long)((double)(Ymax/2+dy)*mr);
00747 w2 = Ymax + dy - (long)((double)(Ymax/2+dy)*mr);
00748 for(i=0;i<Ymax;i++){
00749 for(j=0;j<Xmax;j++){
00750 if(i < w1 || i >= w2){
00751 if(Bb != NULL){
00752 bb=(Bb+i*Xmax+j);
00753 S->R=(unsigned char)bb->R;
00754 S->G=(unsigned char)bb->G;
00755 S->B=(unsigned char)bb->B;
00756 }
00757 else{
00758 S->R = (unsigned char)R;
00759 S->G = (unsigned char)G;
00760 S->B = (unsigned char)B;
00761 }
00762 }
00763 else if(i < w1+dy || i >= w2-dy){
00764 if(i < Ymax/2)f = 1.0-(double)(i-w1)/(double)dy;
00765 else f = (double)(i-(w2-dy))/(double)dy;
00766 if(Bb != NULL){
00767 bb=(Bb+i*Xmax+j);
00768 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00769 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00770 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00771 }
00772 else{
00773 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00774 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00775 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00776 }
00777 }
00778 S++;
00779 }
00780 }
00781 }
00782
00783 static void yWipeFromCentre(double mr, long ny,
00784 fullscreenbuffer *S,
00785 long Xmax, long Ymax,
00786 long R, long G, long B,
00787 fullscreenbuffer *Bb){
00788 long i,j;
00789 long w1,w2,dy;
00790 fullscreenbuffer *bb;
00791 double f;
00792 ny=max(1,ny);
00793 ny=min(100,ny);
00794 dy=(Ymax*ny)/100;
00795 w1 = Ymax/2 - (long)((double)(Ymax/2+dy)*mr);
00796 w2 = Ymax/2 + (long)((double)(Ymax/2+dy)*mr);
00797 for(i=0;i<Ymax;i++){
00798 for(j=0;j<Xmax;j++){
00799 if(i > w1+dy && i < w2-dy){
00800 if(Bb != NULL){
00801 bb=(Bb+i*Xmax+j);
00802 S->R=(unsigned char)bb->R;
00803 S->G=(unsigned char)bb->G;
00804 S->B=(unsigned char)bb->B;
00805 }
00806 else{
00807 S->R = (unsigned char)R;
00808 S->G = (unsigned char)G;
00809 S->B = (unsigned char)B;
00810 }
00811 }
00812 else if(i < w1 || i >= w2){;}
00813 else {
00814 if(i < Ymax/2)f = (double)(i-w1)/(double)dy;
00815 else f = 1.0-(double)(i-(w2-dy))/(double)dy;
00816 if(Bb != NULL){
00817 bb=(Bb+i*Xmax+j);
00818 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00819 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00820 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00821 }
00822 else{
00823 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00824 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00825 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00826 }
00827 }
00828 S++;
00829 }
00830 }
00831 }
00832
00833 static void CircularWipeToCentre(double mr, long nx,
00834 fullscreenbuffer *S,
00835 long X, long Y,
00836 long R, long G, long B,
00837 fullscreenbuffer *Bb){
00838 long i,j;
00839 fullscreenbuffer *bb;
00840 double r,rw,dr,f,rmax;
00841 nx=max(1,nx);
00842 nx=min(100,nx);
00843 rmax=sqrt((double)(Y/2)*(double)(Y/2)+(double)(X/2)*(double)(X/2));
00844 dr=(rmax*(double)nx)/100.0;
00845 rw = rmax+dr-(rmax+dr)*mr;
00846 for(i=0;i<Y;i++){
00847 for(j=0;j<X;j++){
00848 r=sqrt((double)(i-Y/2)*(double)(i-Y/2)+(double)(j-X/2)*(double)(j-X/2));
00849 if(r > rw){
00850 if(Bb != NULL){
00851 bb=(Bb+i*X+j);
00852 S->R=(unsigned char)bb->R;
00853 S->G=(unsigned char)bb->G;
00854 S->B=(unsigned char)bb->B;
00855 }
00856 else{
00857 S->R = (unsigned char)R;
00858 S->G = (unsigned char)G;
00859 S->B = (unsigned char)B;
00860 }
00861 }
00862 else if(r > rw-dr){
00863 f = (r-(rw-dr))/dr;
00864 if(Bb != NULL){
00865 bb=(Bb+i*X+j);
00866 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00867 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00868 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00869 }
00870 else{
00871 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00872 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00873 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00874 }
00875 }
00876 S++;
00877 }
00878 }
00879 }
00880
00881 static void CircularWipeFromCentre(double mr, long nx,
00882 fullscreenbuffer *S,
00883 long X, long Y,
00884 long R, long G, long B,
00885 fullscreenbuffer *Bb){
00886 long i,j;
00887 fullscreenbuffer *bb;
00888 double r,rw,dr,f,rmax;
00889 nx=max(1,nx);
00890 nx=min(100,nx);
00891 rmax=sqrt((double)(Y/2)*(double)(Y/2)+(double)(X/2)*(double)(X/2));
00892 dr=(rmax*(double)nx)/100.0;
00893 rw = (rmax+dr)*mr;
00894 for(i=0;i<Y;i++){
00895 for(j=0;j<X;j++){
00896 r=sqrt((double)(i-Y/2)*(double)(i-Y/2)+(double)(j-X/2)*(double)(j-X/2));
00897 if(r > rw){;}
00898 else if(r > rw-dr){
00899 f = 1.0-(r-(rw-dr))/dr;
00900 if(Bb != NULL){
00901 bb=(Bb+i*X+j);
00902 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)bb->R*f);
00903 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)bb->G*f);
00904 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)bb->B*f);
00905 }
00906 else{
00907 S->R = (unsigned char)((double)(S->R)*(1.0-f)+(double)R*f);
00908 S->G = (unsigned char)((double)(S->G)*(1.0-f)+(double)G*f);
00909 S->B = (unsigned char)((double)(S->B)*(1.0-f)+(double)B*f);
00910 }
00911 }
00912 else{
00913 if(Bb != NULL){
00914 bb=(Bb+i*X+j);
00915 S->R=(unsigned char)bb->R;
00916 S->G=(unsigned char)bb->G;
00917 S->B=(unsigned char)bb->B;
00918 }
00919 else{
00920 S->R = (unsigned char)R;
00921 S->G = (unsigned char)G;
00922 S->B = (unsigned char)B;
00923 }
00924 }
00925 S++;
00926 }
00927 }
00928 }
00929
00930 static void ScrollRight(long hold,long nx,
00931 fullscreenbuffer *S,
00932 long Xmax, long Ymax,
00933 long tf, long ff, long lf){
00934 long i,j,w;
00935 fullscreenbuffer *B,*s,*b;
00936 double mr;
00937 mr=(double)(tf-ff)/(double)(lf-ff+1);
00938 if(hold == 1 || hold == 3)mr=(1.0-mr);
00939 w=(long)((double)((Xmax*nx)/100)*mr);
00940 B=(fullscreenbuffer *)X__Malloc(Xmax*sizeof(fullscreenbuffer));
00941 if(B != NULL){
00942 for(i=0;i<Ymax;i++){
00943 s=(S+i*Xmax); b=B;
00944 memcpy(b,s,Xmax*sizeof(fullscreenbuffer));
00945 s += w;
00946 for(j=w;j<Xmax;j++){
00947 s->R = b->R;
00948 s->G = b->G;
00949 s->B = b->B;
00950 s->A = b->A;
00951 b++; s++;
00952 }
00953 s=(S+i*Xmax);
00954 if(w > 0)for(j=0;j<w;j++){
00955 s->R = b->R;
00956 s->G = b->G;
00957 s->B = b->B;
00958 s->A = b->A;
00959 b++; s++;
00960 }
00961 }
00962 X__Free(B);
00963 }
00964 }
00965
00966 static void ScrollDown(long hold,long ny,
00967 fullscreenbuffer *S,
00968 long Xmax, long Ymax,
00969 long tf, long ff, long lf){
00970 long i,j,w;
00971 fullscreenbuffer *B,*s,*b;
00972 double mr;
00973 mr=(double)(tf-ff)/(double)(lf-ff+1);
00974 if(hold == 1 || hold == 3)mr=(1.0-mr);
00975 w=(long)((double)((Ymax*ny)/100)*mr);
00976 B=(fullscreenbuffer *)X__Malloc(Ymax*sizeof(fullscreenbuffer));
00977 if(B != NULL){
00978 for(i=0;i<Xmax;i++){
00979 for(j=0;j<Ymax;j++){
00980 b=(B+j); s=(S+j*Xmax+i);
00981 memcpy(b,s,sizeof(fullscreenbuffer));
00982 }
00983 for(j=w;j<Ymax;j++){
00984 b=(B+(j-w)); s=(S+j*Xmax+i);
00985 s->R = b->R;
00986 s->G = b->G;
00987 s->B = b->B;
00988 s->A = b->A;
00989 }
00990 if(w > 0)for(j=0;j<w;j++){
00991 b=(B+(Ymax-w+j)); s=(S+j*Xmax+i);
00992 s->R = b->R;
00993 s->G = b->G;
00994 s->B = b->B;
00995 s->A = b->A;
00996 }
00997 }
00998 X__Free(B);
00999 }
01000 }
01001
01002 static void StirRound(double mr, long nx, BOOL linear,
01003 fullscreenbuffer *S,
01004 long X, long Y){
01005 long i,j,k,l,X2,Y2,X1,Y1;
01006 fullscreenbuffer *T,*t,*s;
01007 double r,rmax,anglemax,angle,dx,dy,as,ac,dxx,dyy,R,G,B;
01008 if((T=(fullscreenbuffer *)X__Malloc(X*Y*sizeof(fullscreenbuffer))) == NULL){
01009 MessageBeep(MB_OK);
01010 return;
01011 }
01012 rmax=min((double)(Y/2),(double)(X/2));
01013 anglemax=(double)nx*mr*PI/180.0;
01014 X1=X-1; Y1=Y-1; X2=X/2; Y2=Y/2;
01015 t=T;
01016 for(i=0;i<Y;i++){
01017 for(j=0;j<X;j++){
01018 dy=(double)(i-Y2);
01019 dx=(double)(j-X2);
01020 r=sqrt(dy*dy+dx*dx);
01021 if(r < rmax){
01022 if(linear)angle = anglemax*(1.0-r/rmax);
01023 else angle = anglemax*((rmax-r)/rmax)*((rmax-r)/rmax);
01024 as=sin(angle); ac=cos(angle);
01025 dxx=dx*ac-dy*as;
01026 dyy=dx*as+dy*ac;
01027 if(!Bilinear((double)X2+dxx,(double)Y2+dyy,S,X,Y,&R,&G,&B)){
01028 R=G=B=0.0;
01029 }
01030 t->R=(unsigned char)R;
01031 t->G=(unsigned char)G;
01032 t->B=(unsigned char)B;
01033 t->A=0;
01034 #if 0
01035 k=Y2+(long)dyy;
01036 l=X2+(long)dxx;
01037 k=max(0,min(k,Y1));
01038 l=max(0,min(l,X1));
01039 s=(S+k*X+l);
01040 t->R=s->R;
01041 t->G=s->G;
01042 t->B=s->B;
01043 t->A=s->A;
01044 #endif
01045 }
01046 else{
01047 s=(S+i*X+j);
01048 t->R=s->R;
01049 t->G=s->G;
01050 t->B=s->B;
01051 t->A=s->A;
01052 }
01053 t++;
01054 }
01055 }
01056 memcpy(S,T,X*Y*sizeof(fullscreenbuffer));
01057 X__Free(T);
01058 }
01059
01060 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
01061 double mr;
01062 char name_path[256],imagefile[256];
01063 fullscreenbuffer *Screen,*BackBuffer;
01064 BOOL bMorph=FALSE;
01065 long cR,cG,cB,mcR,mcG,mcB,dummy,type,hold,back,lframe,nx,ny,Xmax,Ymax,frame;
01066 #include "pro_key.c"
01067 sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %s",name_path,
01068 &version,&type,&hold,
01069 &nx,&ny,&cR,&cG,&cB,&back,&lframe,imagefile);
01070 if(lpXimage->Morph && lpXimage->mParameters != NULL){
01071 bMorph=TRUE; mr=lpXimage->MorphRatio;
01072 sscanf(lpXimage->mParameters,
01073 "%s %ld %ld %ld %ld %ld %ld %ld %ld",
01074 name_path,&version,&dummy,&dummy,&dummy,&dummy,&dummy,
01075 &mcR,&mcG,&mcB);
01076 }
01077 if(!bMorph){
01078 mr=(double)(lpXimage->last_frame - lpXimage->first_frame);
01079 if(mr < 1.0)return 1;
01080 mr=(double)(lpXimage->this_frame - lpXimage->first_frame)/mr;
01081 }
01082 frame=lpXimage->this_frame - lpXimage->first_frame + 1;
01083 if (hold == 1)mr=(1.0-mr);
01084 else if(hold == 2)mr=1.0;
01085 else if(hold == 3)mr=0.0;
01086 BackBuffer=NULL;
01087 Xmax=lpXimage->Xmax; Ymax=lpXimage->Ymax;
01088 if(back > 0){
01089 unsigned char *ImagePixels;
01090 int ImageXsize,ImageYsize;
01091 if(back == 2)GetAnimFileName(imagefile,name_path,
01092 lpXimage->this_frame - lpXimage->first_frame + 1,
01093 1,lframe,1);
01094 RestoreWhiteSpaces(imagefile);
01095 if((ImagePixels=LoadMAP(imagefile,&ImageXsize,&ImageYsize)) != NULL){
01096 BackBuffer=ScaleImageMap(ImagePixels,ImageXsize,ImageYsize,Xmax,Ymax);
01097 X__Free(ImagePixels);
01098 }
01099 }
01100 Screen=lpXimage->Screen;
01101 if(type == 0)TwoByTwo(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,0,NULL);
01102 if(type == 1)WipeRandomBlocks(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,BackBuffer);
01103 if(type == 2)FoldPiP(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,2,BackBuffer);
01104 if(type == 3)FoldPiP(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,1,BackBuffer);
01105 if(type == 4)FoldPiP(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,3,BackBuffer);
01106 if(type == 5)FoldPiP(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,4,BackBuffer);
01107 if(type == 6)Inlay(mr,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01108 if(type == 7)FogIn(mr,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer,lpXimage->Zbuffer);
01109 if(type == 8)WipeRandomBits(mr,Screen,Xmax,Ymax,nx,ny,cR,cG,cB,BackBuffer);
01110 if(type == 9)WhiteNoise(mr,frame,Screen,Xmax,Ymax,nx,cR,cG,cB,TRUE);
01111 if(type == 10)WhiteNoise(mr,frame,Screen,Xmax,Ymax,nx,cR,cG,cB,FALSE);
01112 if(type == 11)Slice(mr,ny,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01113 if(type == 12)WipeLR(mr,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01114 if(type == 13)WipeRL(mr,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01115 if(type == 14)xWipeToCentre(mr,nx,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01116 if(type == 15)xWipeFromCentre(mr,nx,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01117 if(type == 16)yWipeToCentre(mr,ny,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01118 if(type == 17)yWipeFromCentre(mr,ny,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01119 if(type == 18)CircularWipeToCentre(mr,nx,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01120 if(type == 19)CircularWipeFromCentre(mr,nx,Screen,Xmax,Ymax,cR,cG,cB,BackBuffer);
01121 if(type == 20)ScrollRight(hold,nx,Screen,Xmax,Ymax,lpXimage->this_frame,
01122 lpXimage->first_frame,lpXimage->last_frame);
01123 if(type == 21)ScrollDown(hold,ny,Screen,Xmax,Ymax,lpXimage->this_frame,
01124 lpXimage->first_frame,lpXimage->last_frame);
01125 if(BackBuffer != NULL)X__Free(BackBuffer);
01126 if(type == 22)StirRound(mr,nx,FALSE,Screen,Xmax,Ymax);
01127 if(type == 23)StirRound(mr,-nx,FALSE,Screen,Xmax,Ymax);
01128 if(type == 24)StirRound(mr,nx,TRUE,Screen,Xmax,Ymax);
01129 if(type == 25)StirRound(mr,-nx,TRUE,Screen,Xmax,Ymax);
01130 return 1;
01131 }
01132
01133
01134
01135 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
01136 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
01137 return 1;
01138 }
01139
01140
01141 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
01142
01143 static long colour[3]={255,255,255};
01144 static long type=0,hold=0,back=0,lframe=9999,nx=10,ny=10;
01145 static char iname[256];
01146 static X__MEMORY_MANAGER *lpLocalEVI;
01147
01148 char * _SetExternalParameters(
01149 char *Op,
01150 HWND hWnd,
01151 long ruler,
01152 char *name,
01153 X__MEMORY_MANAGER *lpEVI
01154 ){
01155 char buffer[1024];
01156 long id1,id2;
01157 strcpy(iname," ");
01158 if(Op != NULL){
01159 sscanf(Op,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %s",buffer,&version,
01160 &type,&hold,&nx,&ny,&colour[0],&colour[1],&colour[2],
01161 &back,&lframe,iname);
01162 }
01163 lpLocalEVI=lpEVI;
01164 if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_VIDEO),hWnd,
01165 (DLGPROC)DlgProc) == FALSE)return Op;
01166 if(Op != NULL)CALL_FREE(Op);
01167 sprintf(buffer,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %s",
01168 name,version,type,hold,
01169 nx,ny,colour[0],colour[1],colour[2],back,lframe,iname);
01170 if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
01171 MessageBox (GetFocus(),"External effect: Out of memory","Error",
01172 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
01173 return NULL;
01174 }
01175 strcpy(Op,buffer);
01176 return Op;
01177 }
01178
01179 #define NVIDEO 26
01180
01181 static void LoadAnimatedClip(HWND hDlg,long id){
01182 char *c,str[32],modname[256];
01183 GetModuleFileName(hDLLinstance,modname,255);
01184 if((c=strrchr(modname,'.')) != NULL){
01185 sprintf(str,"%ld",id+1);
01186 strcpy(c,str);
01187 strcat(modname,".avi");
01188 Animate_Open(GetDlgItem(hDlg,DLG_IMAGE),modname);
01189 Animate_Play(GetDlgItem(hDlg,DLG_IMAGE),0, -1, -1);
01190 }
01191 }
01192
01193 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
01194 BOOL err;
01195 int i;
01196 char lname[256],text[512];
01197 static long type_list[NVIDEO]={
01198 DLG_VIDEO_1,
01199 DLG_VIDEO_2,
01200 DLG_VIDEO_3,
01201 DLG_VIDEO_4,
01202 DLG_VIDEO_5,
01203 DLG_VIDEO_6,
01204 DLG_VIDEO_7,
01205 DLG_VIDEO_8,
01206 DLG_VIDEO_9,
01207 DLG_VIDEO_10,
01208 DLG_VIDEO_11,
01209 DLG_VIDEO_12,
01210 DLG_VIDEO_13,
01211 DLG_VIDEO_14,
01212 DLG_VIDEO_15,
01213 DLG_VIDEO_16,
01214 DLG_VIDEO_17,
01215 DLG_VIDEO_18,
01216 DLG_VIDEO_19,
01217 DLG_VIDEO_20,
01218 DLG_VIDEO_21,
01219 DLG_VIDEO_22,
01220 DLG_VIDEO_23,
01221 DLG_VIDEO_24,
01222 DLG_VIDEO_25,
01223 DLG_VIDEO_26
01224 };
01225 static long text_list[NVIDEO]={
01226 IDX_VIDEO_1,
01227 IDX_VIDEO_2,
01228 IDX_VIDEO_3,
01229 IDX_VIDEO_4,
01230 IDX_VIDEO_5,
01231 IDX_VIDEO_6,
01232 IDX_VIDEO_7,
01233 IDX_VIDEO_8,
01234 IDX_VIDEO_9,
01235 IDX_VIDEO_10,
01236 IDX_VIDEO_11,
01237 IDX_VIDEO_12,
01238 IDX_VIDEO_13,
01239 IDX_VIDEO_14,
01240 IDX_VIDEO_15,
01241 IDX_VIDEO_16,
01242 IDX_VIDEO_17,
01243 IDX_VIDEO_18,
01244 IDX_VIDEO_19,
01245 IDX_VIDEO_20,
01246 IDX_VIDEO_21,
01247 IDX_VIDEO_22,
01248 IDX_VIDEO_23,
01249 IDX_VIDEO_24,
01250 IDX_VIDEO_25,
01251 IDX_VIDEO_26
01252 };
01253 switch( msg ) {
01254 case WM_INITDIALOG:
01255 if (hold == 0)
01256 SendDlgItemMessage(hwnd,DLG_VIDEO_FADE_IN,BM_SETCHECK,TRUE,0);
01257 else if(hold == 1)
01258 SendDlgItemMessage(hwnd,DLG_VIDEO_FADE_OUT,BM_SETCHECK,TRUE,0);
01259 else if(hold == 2)
01260 SendDlgItemMessage(hwnd,DLG_VIDEO_HOLD_IN,BM_SETCHECK,TRUE,0);
01261 else if(hold == 3)
01262 SendDlgItemMessage(hwnd,DLG_VIDEO_HOLD_OUT,BM_SETCHECK,TRUE,0);
01263 for(i=0;i<NVIDEO;i++){
01264 LoadString(hDLLinstance,type_list[i],lname,256);
01265 SendDlgItemMessage(hwnd,DLG_VIDEO_LIST,LB_ADDSTRING,0,
01266 (LPARAM)(LPCTSTR)lname);
01267 }
01268 SendDlgItemMessage(hwnd,DLG_VIDEO_LIST,LB_SETCURSEL,(WPARAM)type,0);
01269 if (back == 0)
01270 SendDlgItemMessage(hwnd,DLG_VIDEO_PLAIN,BM_SETCHECK,TRUE,0);
01271 if (back == 1)
01272 SendDlgItemMessage(hwnd,DLG_VIDEO_IMAGE,BM_SETCHECK,TRUE,0);
01273 if (back == 2)
01274 SendDlgItemMessage(hwnd,DLG_VIDEO_ANIIMAGE,BM_SETCHECK,TRUE,0);
01275 strcpy(lname,iname);
01276 RestoreWhiteSpaces(lname);
01277 SetDlgItemText(hwnd,DLG_VIDEO_IMAGENAME,lname);
01278 SetDlgItemInt(hwnd,DLG_VIDEO_NX,nx,TRUE);
01279 SetDlgItemInt(hwnd,DLG_VIDEO_NY,ny,TRUE);
01280 SetDlgItemInt(hwnd,DLG_VIDEO_LASTFRAME,lframe,TRUE);
01281 LoadAnimatedClip(hwnd,type);
01282 LoadString(hDLLinstance,text_list[type],text,256);
01283 SendDlgItemMessage(hwnd,DLG_VIDEO_HELP,WM_SETTEXT,0,(LPARAM)text);
01284 CentreDialogOnScreen(hwnd);
01285 case WM_PAINT:
01286 PaintBackground(hwnd);
01287 break;
01288 return TRUE;
01289 case WM_DRAWITEM:{
01290 LPDRAWITEMSTRUCT lpdis;
01291 HBRUSH hbr,hbrold;
01292 BYTE r,g,b;
01293 lpdis=(LPDRAWITEMSTRUCT)lparam;
01294 if(lpdis->CtlID == DLG_VIDEO_COLOUR){
01295 r=(BYTE)colour[0]; g=(BYTE)colour[1]; b=(BYTE)colour[2];
01296 if(lpdis->itemState & ODS_SELECTED)
01297 InvertRect(lpdis->hDC,&(lpdis->rcItem));
01298 else{
01299 hbr=CreateSolidBrush(RGB(r,g,b));
01300 hbrold=SelectObject(lpdis->hDC,hbr);
01301 Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
01302 lpdis->rcItem.right,lpdis->rcItem.bottom);
01303 SelectObject(lpdis->hDC,hbrold);
01304 DeleteObject(hbr);
01305 }
01306 }
01307 }
01308 break;
01309 case WM_COMMAND:
01310 switch(LOWORD(wparam)){
01311 case DLG_VIDEO_LIST:
01312 switch(HIWORD(wparam)){
01313 case LBN_SELCHANGE:{
01314 HWND hctl;
01315 hctl=GetDlgItem(hwnd,DLG_VIDEO_LIST);
01316 i=SendMessage(hctl,LB_GETCURSEL,0,0);
01317 LoadAnimatedClip(hwnd,i);
01318 LoadString(hDLLinstance,text_list[i],text,256);
01319 SendDlgItemMessage(hwnd,DLG_VIDEO_HELP,WM_SETTEXT,0,(LPARAM)text);
01320 }
01321 break;
01322 default: break;
01323 }
01324 break;
01325 case DLG_VIDEO_SETIMAGENAME:{
01326 strcpy(lname,iname);
01327 RestoreWhiteSpaces(lname);
01328 if(XimageFileName(lpLocalEVI->lpAni,lname,"gif",
01329 "Choose First/Only Image File",
01330 "All file formats|*.gif;*.tga|"
01331 "Compuserve GIFs|*.gif|"
01332 "Targa TGAs|*.tga|",
01333 hwnd)){
01334
01335 SetDlgItemText(hwnd,DLG_VIDEO_IMAGENAME,lname);
01336 HideWhiteSpaces(lname);
01337 strcpy(iname,lname);
01338 }
01339 }
01340 break;
01341 case DLG_VIDEO_COLOUR:
01342 SetColour(colour,hwnd);
01343 InvalidateRect(GetDlgItem(hwnd,DLG_VIDEO_COLOUR),NULL,FALSE);
01344 break;
01345 case IDCANCEL:
01346 EndDialog(hwnd,FALSE);
01347 return(TRUE);
01348 case IDOK:
01349 nx=GetDlgItemInt(hwnd,DLG_VIDEO_NX,&err,FALSE);
01350 ny=GetDlgItemInt(hwnd,DLG_VIDEO_NY,&err,FALSE);
01351 lframe=GetDlgItemInt(hwnd,DLG_VIDEO_LASTFRAME,&err,FALSE);
01352 if(SendDlgItemMessage(hwnd,DLG_VIDEO_FADE_IN,BM_GETCHECK,0,0))
01353 hold=0;
01354 if(SendDlgItemMessage(hwnd,DLG_VIDEO_FADE_OUT,BM_GETCHECK,0,0))
01355 hold=1;
01356 if(SendDlgItemMessage(hwnd,DLG_VIDEO_HOLD_IN,BM_GETCHECK,0,0))
01357 hold=2;
01358 if(SendDlgItemMessage(hwnd,DLG_VIDEO_HOLD_OUT,BM_GETCHECK,0,0))
01359 hold=3;
01360 if(SendDlgItemMessage(hwnd,DLG_VIDEO_ANIIMAGE,BM_GETCHECK,0,0))
01361 back=2;
01362 if(SendDlgItemMessage(hwnd,DLG_VIDEO_IMAGE,BM_GETCHECK,0,0))
01363 back=1;
01364 if(SendDlgItemMessage(hwnd,DLG_VIDEO_PLAIN,BM_GETCHECK,0,0))
01365 back=0;
01366 type=SendDlgItemMessage(hwnd,DLG_VIDEO_LIST,LB_GETCURSEL,0,0);
01367 EndDialog(hwnd,TRUE);
01368 return(TRUE);
01369 default:
01370 break;
01371 }
01372 break;
01373 default: break;
01374 }
01375 return FALSE;
01376 }
01377
01378 #include "video2.c"
01379
01380 #undef double
01381
01382
01383 static long IX=9123,IY=8844,IZ=20846;
01384
01385 static void sRandom(long i){
01386 srand(i); IX=rand(); IY=rand(); IZ=rand();
01387 }
01388
01389 static double Random(void){
01390 IX=imod(171*IX,30269);
01391 IY=imod(172*IY,20207);
01392 IZ=imod(170*IZ,30323);
01393 return (double)fmod((double)IX/30269.0+
01394 (double)IY/30307.0+
01395 (double)IZ/30323.0,1.0);
01396 }
01397
01398 static void SortArray(long n, long *id, double *r){
01399 long i,j,gap,itemp;
01400 double rtemp;
01401 for (gap = n; gap > 0; gap /=2) {
01402 for (i = gap; i < n; i++) {
01403 for (j = i-gap; j >= 0 && *(r+j) < *(r+j+gap); j -= gap){
01404 rtemp = *(r+j);
01405 *(r+j) = *(r+j+gap);
01406 *(r+j+gap) = rtemp;
01407 itemp = *(id+j);
01408 *(id+j) = *(id+j+gap);
01409 *(id+j+gap) = itemp;
01410 }
01411 }
01412 }
01413 }
01414
01415 static long *GenerateRandomSelection(long nb){
01416
01417
01418 long i,*blockid;
01419 double *blockV;
01420 if((blockid = (long *)X__Malloc(nb*sizeof(long))) == NULL)return NULL;
01421 if((blockV = (double *)X__Malloc(nb*sizeof(double))) == NULL){
01422 X__Free(blockid); return NULL;
01423 }
01424 for(i=0;i<nb;i++){
01425 blockid[i]=i;
01426 blockV[i]=Random();
01427 }
01428 SortArray(nb,blockid,blockV);
01429 X__Free(blockV);
01430 return blockid;
01431 }