STEREO1.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 /* FILTER.C  image post-processing external DLL                         */
00025 /*                                                                      */
00026 /* This image processor gives the user the opportunity to alter the     */
00027 /* colour balance in an image once it has been rendered. The proportion */
00028 /* of red, green and blue in each pixel is adjusted by multiplying      */
00029 /* the R,G,B values held in the ScreenBuffer after they have been       */
00030 /* calculated but before they are written to disk or built into an      */
00031 /* animation.                                                           */
00032 /*                                                                      */
00033 /* This example servers to illustrate the design of the Dialog Box      */
00034 /* called by the Animator to set up the process and how pixels in the   */
00035 /* screen buffer are addressed and modified.                            */
00036 /*                                                                      */
00037 
00038 #include "resource.h"
00039 #include <stdlib.h>
00040 #include <stdio.h>
00041 #include <float.h>
00042 #include <math.h>
00043 #include <windows.h>
00044 #include "struct.h"           /* general structures    */
00045 #include "..\common\postprocess\ximage.h"
00046 #include "local.h"
00047 #include <commctrl.h>
00048 #include "stereo1.h"
00049 
00050 #if __X__MIPS__
00051 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00052 #endif
00053 
00054 static HINSTANCE hDLLinstance=NULL; /* use to pick up resources from DLL   */
00055 
00056 /************************** Local Utility Functions ***********************/
00057 
00058 #include "utils.h"
00059 
00060 /************************** DLL entry point ********************************/
00061 
00062 #if __WATCOMC__
00063 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00064 #elif __BC__
00065 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00066 #else
00067 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00068 #endif
00069   switch (dwReason) {
00070     case DLL_PROCESS_ATTACH:
00071 #if __X__MIPS__
00072       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00073 #endif
00074 //MessageBox(NULL,"Attaching",NULL,MB_OK);
00075       hDLLinstance = hDLL;  /* handle to DLL file */
00076       break;
00077     case DLL_PROCESS_DETACH:
00078 #if __X__MIPS__
00079       if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00080 #endif
00081 //MessageBox(NULL,"Detaching",NULL,MB_OK);
00082       break;
00083   }
00084 return (int)TRUE;
00085 }
00086 
00087 #if __SC__
00088 #pragma startaddress(DllMain)
00089 #endif
00090 
00091 /*******************************************************************\
00092 |                Code that executes the process                     |
00093 \*******************************************************************/
00094 
00095 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00096  int i,j;
00097  BOOL LR,RL;
00098  char dummy[255];
00099  fullscreenbuffer *S;
00100  /* read the parameters from the parameter list */
00101  sscanf(PrmList,"%s %d %d",dummy,&LR,&RL);
00102  
00103  //MessageBox(NULL,PrmList,"Debug",MB_OK);
00104  /* set local pointer to start of screen buffer */
00105  S=lpXimage->Screen;
00106  for(j=0;j<lpXimage->Ymax;j++)   /* do rows in screen buffer */
00107  for(i=0;i<lpXimage->Xmax;i++){  /* do all pixies in row j   */
00108    /* scale the R,G,B values for pixel i,j */
00109    S->R = min(255,(unsigned char)((double)S->R * LR));
00110    S->G = min(255,(unsigned char)((double)S->G * 0));
00111    S->B = min(255,(unsigned char)((double)S->B * RL));
00112    S++;             /* point to next pixels in screen buffer */
00113  }
00114  return 1;          /* all done OK                           */
00115 }
00116 
00117 /*************** Function that renders any of the OpenGL Functionality ************/
00118 
00119 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00120 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
00121  return 1;
00122 }
00123 /**********************************************************************************/
00124 
00125 
00126 /*************** Functions used for set up  ***************/
00127 
00128 
00129 /* local variable for communication between dialog box and Setup function */
00130 BOOL LorR=1,RorL=0;
00131 
00132 /* Dialog box callback prototype */
00133 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00134 
00135 char * _SetExternalParameters(
00136   char *Op,                 /* string for the parameters                  */
00137   HWND hWnd,                /* parent window                              */
00138   long ruler,               /* ruler scale value to facilitate scaling    */
00139   char *name,               /* name of DLL file with the effect           */
00140   X__MEMORY_MANAGER *lpEVI /* pointer to structure with memory functions */
00141                                     ){
00142  /* output buffer should be as long as necessary to hold full string        */
00143  char buffer[256];
00144  if(Op != NULL){  /* parameters exist so read them off the list */
00145    sscanf(Op,"%s %d %d",buffer,&LorR,&RorL);
00146  }
00147  /*   Do the user interface as required to set up the effect, may use a     */
00148  /*   dialog box etc. Return old string if effect is cancelled (no change)  */
00149  if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_FILTER),hWnd,
00150               (DLGPROC)DlgProc) == FALSE)return Op;
00151  /* Free space occupied by old parameter string */
00152  if(Op != NULL)CALL_FREE(Op);  /* free the old string */
00153  /* print the parameters into the buffer */
00154  sprintf(buffer,"%s %d %d",name,LorR,RorL);
00155  /* Prepare the output buffer to take copy of parameter list */
00156  if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00157   MessageBox (GetFocus(),"External effect: Out of memory","Error",
00158                 MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00159    return NULL;
00160  }
00161  /* Copy the parameter string to the output buffer */
00162  strcpy(Op,buffer);
00163  return Op;
00164 }
00165 
00166 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00167  int str[32];
00168  char filmname[255],*c;
00169  switch( msg ) {
00170    case WM_INITDIALOG:
00171      /* prime dialog box controls          */
00172      GetModuleFileName(hDLLinstance,filmname,255);
00173          if((c=strrchr(filmname,'.')) != NULL){
00174            strcpy(c,".avi");
00175            Animate_Open(GetDlgItem(hwnd,IDR_ANIMATION1),filmname);
00176            Animate_Play(GetDlgItem(hwnd,IDR_ANIMATION1),0,-1,-1);
00177          }
00178            if(LorR == 1)
00179                  SendDlgItemMessage(hwnd,IDC_RADIO_LEFT,BM_SETCHECK,1,0);
00180            else{
00181                  SendDlgItemMessage(hwnd,IDC_RADIO_RIGHT,BM_SETCHECK,1,0);
00182            }
00183      CentreDialogOnScreen(hwnd);
00184      return TRUE;
00185    case WM_COMMAND:
00186      switch(LOWORD(wparam)){
00187             case IDC_RADIO_LEFT:
00188           MessageBox(NULL,"Activate Left Camera","Don't Forget!",MB_OK);
00189                   return(TRUE);
00190                 case IDC_RADIO_RIGHT:
00191           MessageBox(NULL,"Activate Right Camera","Don't Forget!",MB_OK);
00192                   return(TRUE);
00193             case IDCANCEL:    /* user clicked cancel                            */
00194           EndDialog(hwnd,FALSE);
00195           return(TRUE);
00196         case IDOK:        /* OK so get numbers from the Dailog Box controls */
00197                   if (SendDlgItemMessage(hwnd,IDC_RADIO_LEFT,BM_GETCHECK,0,0) == 1)
00198                     LorR=1,RorL=0;
00199                   else {
00200                         LorR=0,RorL=1;
00201           }
00202                         EndDialog(hwnd,TRUE);
00203           return(TRUE);
00204                 
00205         default:
00206           break;
00207       }
00208       break;
00209     default: break;
00210  }
00211  return FALSE;
00212 }
00213 

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