00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <float.h>
00029 #include <math.h>
00030 #include <windows.h>
00031 #include <commctrl.h>
00032 #include "struct.h"
00033 #include "..\common\postprocess\ximage.h"
00034 #include "local.h"
00035 #include "trails.h"
00036
00037 #if __X__MIPS__
00038 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00039 #endif
00040
00041 static HINSTANCE hDLLinstance=NULL;
00042 static long version=1;
00043
00044 #include "utils.h"
00045 #include "paint.c"
00046
00047 #if __WATCOMC__
00048 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00049 #elif __BC__
00050 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00051 #else
00052 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00053 #endif
00054 switch (dwReason) {
00055 case DLL_PROCESS_ATTACH:
00056 #if __X__MIPS__
00057 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00058 #endif
00059 hDLLinstance = hDLL;
00060 break;
00061 case DLL_PROCESS_DETACH:
00062 #if __X__MIPS__
00063 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00064 #endif
00065 break;
00066 }
00067 return (int)TRUE;
00068 }
00069
00070 #if __SC__
00071 #pragma startaddress(DllMain)
00072 #endif
00073
00074
00075 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00076 long i,j;
00077 char dummy[255];
00078 double z,scale,I,mr,fade;
00079 long number,type,c1,c2,c3,Xmax,Ymax,ifade;
00080 long mnumber,mtype,mc1,mc2,mc3,mifade;
00081 float *Zb;
00082 fullscreenbuffer *S,*Screen,*Blur,*B;
00083 BOOL bDraw=TRUE,bMorph=FALSE;
00084 #include "pro_key.c"
00085 sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld",dummy,&version,&c1,&c2,&c3,
00086 &number,&type,&ifade);
00087 if(lpXimage->Morph && lpXimage->mParameters != NULL){
00088 bMorph=TRUE; mr=lpXimage->MorphRatio;
00089 sscanf(lpXimage->mParameters,"%s %ld %ld %ld %ld %ld %ld %ld",dummy,
00090 &version,&mc1,&mc2,&mc3,&mnumber,&mtype,&mifade);
00091 }
00092
00093 if((Blur=lpXimage->Blur) == NULL)return 1;
00094 if((Zb=lpXimage->Zbuffer) == NULL)return 0;
00095 if((Screen=lpXimage->Screen) == NULL)return 0;
00096 Xmax=lpXimage->Xmax;
00097 Ymax=lpXimage->Ymax;
00098 S=Screen; B=Blur;
00099 if(type == 2){
00100 for(j=0;j<Ymax;j++)for(i=0;i<Xmax;i++){
00101 if(S->A < 64 && B->A > 0){
00102 S->R=B->R;
00103 S->G=B->G;
00104 S->B=B->B;
00105 S->A=B->A;
00106 }
00107 if(S->A >= 64){
00108 B->A=(unsigned char)number;
00109 B->R=S->R;
00110 B->G=S->G;
00111 B->B=S->B;
00112 }
00113 else if(B->A > 0)B->A -= 1;
00114 S++;
00115 B++;
00116 }
00117 }
00118 else{
00119 for(j=0;j<Ymax;j++)for(i=0;i<Xmax;i++){
00120 if(S->A < 64 && B->A > 64){
00121 S->R=B->R;
00122 S->G=B->G;
00123 S->B=B->B;
00124 S->A=B->A;
00125 }
00126 if(S->A >= 64){
00127 B->A=S->A;
00128 B->R=S->R;
00129 B->G=S->G;
00130 B->B=S->B;
00131 }
00132 S++;
00133 B++;
00134 }
00135 }
00136 return 1;
00137 }
00138
00139
00140
00141
00142 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00143 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
00144 return 1;
00145 }
00146
00147
00148 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00149
00150 static long number=10,type=1,c1=0,c2=255,c3=0,fade=100;
00151
00152 char * _SetExternalParameters(
00153 char *Op,
00154 HWND hWnd,
00155 long ruler,
00156 char *name,
00157 X__MEMORY_MANAGER *lpEVI
00158 ){
00159 char buffer[256];
00160 if(Op != NULL){
00161 sscanf(Op,"%s %ld %ld %ld %ld %ld %ld %ld",buffer,&version,&c1,&c2,&c3,
00162 &number,&type,&fade);
00163 }
00164 if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_TRAILS),hWnd,
00165 (DLGPROC)DlgProc) == FALSE)return Op;
00166 if(Op != NULL)CALL_FREE(Op);
00167 sprintf(buffer,"%s %ld %ld %ld %ld %ld %ld %ld",name,version,c1,c2,c3,
00168 number,type,fade);
00169 if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00170 MessageBox (GetFocus(),"Out of memory",NULL,
00171 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00172 return NULL;
00173 }
00174 strcpy(Op,buffer);
00175 return Op;
00176 }
00177
00178 static void LoadAnimatedClip(HWND hDlg){
00179 char *c,modname[256];
00180 GetModuleFileName(hDLLinstance,modname,255);
00181 if((c=strrchr(modname,'.')) != NULL){
00182 strcpy(c,".avi");
00183 Animate_Open(GetDlgItem(hDlg,DLG_IMAGE),modname);
00184 Animate_Play(GetDlgItem(hDlg,DLG_IMAGE),0, -1, -1);
00185 }
00186 }
00187
00188 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00189 BOOL err;
00190 char str[32];
00191 switch( msg ) {
00192 case WM_INITDIALOG:
00193 SetDlgItemInt(hwnd,DLG_TRAILS_NUMBER,number,FALSE);
00194 if (type == 1)
00195 SendDlgItemMessage(hwnd,DLG_TRAILS_ALL,BM_SETCHECK,TRUE,0);
00196 if (type == 2)
00197 SendDlgItemMessage(hwnd,DLG_TRAILS_SET,BM_SETCHECK,TRUE,0);
00198 LoadAnimatedClip(hwnd);
00199 CentreDialogOnScreen(hwnd);
00200 return TRUE;
00201 case WM_PAINT:
00202 PaintBackground(hwnd);
00203 break;
00204 case WM_COMMAND:
00205 switch(LOWORD(wparam)){
00206 case IDCANCEL:
00207 EndDialog(hwnd,FALSE);
00208 return(TRUE);
00209 case IDOK:
00210 if(SendDlgItemMessage(hwnd,DLG_TRAILS_SET,BM_GETCHECK,0,0))
00211 type=2;
00212 else
00213 type=1;
00214 number=GetDlgItemInt(hwnd,DLG_TRAILS_NUMBER,&err,FALSE);
00215 if(number < 0)number=0;
00216 EndDialog(hwnd,TRUE);
00217 return(TRUE);
00218 default:
00219 break;
00220 }
00221 break;
00222 default: break;
00223 }
00224 return FALSE;
00225 }
00226