⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filters.h

📁 hl2 source code. Do not use it illegal.
💻 H
📖 第 1 页 / 共 2 页
字号:

//-- Class ID's for various DLL's

#define NEGATIVECLASSID 0x4655434A
#define ALPHACLASSID    0x655434A4
#define ADDCLASSID      0x55434A46
#define BLURCLASSID     0x5434A465
#define CROSFADECLASSID 0x434A4655
#define GLOWCLASSID     0x35A46554
#define COOKIECLASSID   0x4A465543
#define WIPECLASSID     0xA4655434
#define FADECLASSID     0x4655434B
#define PDALPHACLASSID  0x655434B4

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   Image   Filter Class
//

class ImageFilter {
	
	protected:

		BOOL	interactive;
		HWND	vpSetuphWnd,vphWnd,dlghWnd;

		//-- Bitmap Pointers --------------------------------------------------
		//
		// All filters will have at least a pointer to "srcmap". This is VP's
		// (or any other process') main image pipeline.
		//
		// Composition filters will also receive a second [frgmap] bitmap
		// which should be composited above the main [srcmap] bitmap.
		//
		// If "mskmap" is not NULL, it will contain a pointer to a grayscale
		// image to be used as a mask for the process.
		//
		// 12/06/95 - GG
		//
		// The srcmap (Background) is the Video Post queue bitmap. Use its
		// methods to find out dimmensions (width, height, aspect ratio, etc.)
		// If the queue is using Alpha channel, it will be noted in the bitmap
		// flags (srcmap). The same is true for Z and G buffers. Again, simply
		// use the bitmap methods to access these.
		//
		
		Bitmap                      *srcmap;         //--   Source (Background)
		Bitmap                      *mskmap;         //--   Mask (Grayscale Masking)
		Bitmap                      *frgmap;         //--   Foreground (for layering/transitions)
		
		//-- Set    by  Host ----------------------------------
		
		ImageFilterInfo         *ifi;
		
	public:
	
		FLTExport	ImageFilter     ( );
		dVirtual	~ImageFilter	( );
		
		//-- Filter Info    ---------------------------------
		
		dVirtual     const TCHAR    *Description      ( ) = 0; // ASCII description (i.e. "Convolution Filter")
		dVirtual     const TCHAR    *AuthorName       ( ) = 0; // ASCII Author name
		dVirtual     const TCHAR    *CopyrightMessage ( ) = 0; // ASCII Copyright message
		dVirtual     UINT            Version          ( ) = 0; // Version number * 100 (i.e. v3.01 = 301)
		dVirtual     DWORD           Capability       ( ) = 0; // Returns capability flags (see above)

		//-- Dialogs ----------------------------------------------------------
		//
		//    An About Box  is  mandatory. The  Control panel is optional and   its 
		//    existence should be flagged   by  the Capability  flag above.
		//

		dVirtual     void            ShowAbout         ( HWND    hWnd ) =    0;
		dVirtual     BOOL            ShowControl       ( HWND    hWnd ) {    return FALSE; }

		//-- Parameter  Setting (Host's Responsability) ----

		dVirtual     void            SetSource         ( Bitmap *map )     {srcmap = map;}
		dVirtual     void            SetForeground     ( Bitmap *map )     {frgmap = map;}
		dVirtual     void            SetMask           ( Bitmap *map )     {mskmap = map;}
		dVirtual     void            SetFilterInfo     ( ImageFilterInfo *i ) {ifi   = i;}

		//-- Execution  ------------------------------------
		//
		//    The   "hWnd" argument is a    window handler  to  which
		//    the   plug-in will be sending messages.

		dVirtual     BOOL            Render            ( HWND    hWnd ) =    0;

		//-- Max    Interface ----------------------------------------------------
		//
		//    Some of Max's core functions exported through the Interface class.
		//

		dVirtual  Interface *Max  ( );

		//-- Helpers --------------------------------------

		dVirtual  int     Lerp    (int a, int b, int l);
		dVirtual  int     Lerp    (int a, int b, float f);
		
		//-- Parameter  Block   Load and    Save ------------------------------------
		//
		//   The host will  call EvaluateConfigure() to determine the   buffer size
		//   required by the plug-in.
		//
		//   SaveConfigure() will be called so the  plug-in can transfer    its
		//   parameter block to the host ( ptr is a pre-allocated   buffer).
		//
		//   LoadConfigure() will be called so the  plug-in can load its    
		//   parameter block back.
		//   
		//   Memory management is performed by the  host using standard
		//   LocalAlloc() and   LocalFree().
		//   
		
		dVirtual  DWORD   EvaluateConfigure  ( )           { return 0; }
		dVirtual  BOOL    LoadConfigure      ( void *ptr ) { return (FALSE); }
		dVirtual  BOOL    SaveConfigure      ( void *ptr ) { return (FALSE); }

		//-- Preview Facility -------------------------------------------------
		//
		//    This is used  by  plug-ins    that want to have   a preview bitmap while
		//    displaying its control dialogue.
		//
		//    The   flag controls how   much of the queue   to  run:
		//
		//    PREVIEW_BEFORE - The queue is run up  to  the event before the    filter
		//    calling it.
		//
		//    PREVIEW_UP ----- The queue is run up  to  the event (filter) calling
		//    this function.
		//
		//    PREVIEW_WHOLE -- The whole queue is run   including events after
		//    this filter.
		//
		//    The   given   frame   is  the Video Post  Queue   frame   number and not  Max's
		//    frame number.
		//
		//
		//    Parameters:
		//
		//    hWnd -    WIndow handle to send messages to. These are    the progress,
		//    check for abort, text messages    etc. If the plug in wants to support
		//    a cancel button   and progress bars   etc, it must handle these messages.
		//    It is Ok to send a    NULL window handle in which case    nothing is checked.
		//
		//    back -    Pointer to a Bitmap pointer. If the Bitmap pointer  is  NULL,   a
		//    new   bitmap is created   using   the given dimmensions. This pointer must be
		//    NULL the first time this  function    is  called as the bitmap    must be
		//    created by Video Post. Once   this function is called and a   bitmap is
		//    returned, it  is  ok  to  call it again using this map.   In  this case, Video
		//    Post will simply use it instead of creating a new one.    You must    delete
		//    the   bitmap when done.
		//
		//    fore -    For layer plug-ins, this points to the  foreground image.   This is
		//    only valid if flag    is  set to PREVIEW_BEFORE. In this case back will hold  
		//    Video Post main   queue   and fore    will have the foreground image to be 
		//    composited. This is usefull   if  you, a layer plug-in, want  to  collect the 
		//    images    and run a real  time preview. If flag is not PREVIEW_BEFORE,    fore
		//    will be a NULL pointer indicating there   is  no  bitmap.
		//
		//    frame - The desired frame. Make sure  you request a frame within  the
		//    range your plug-in    is  active.
		//
		//    width & height - Self explanatory.
		//
		//    flag -    Explained above.
		//

		#ifndef PREVIEW_BEFORE
		#define PREVIEW_BEFORE  1
		#define PREVIEW_UP      2
		#define PREVIEW_WHOLE   3
		#endif

		dVirtual    BOOL CreatePreview  ( 
				HWND hWnd,                      //-- Window handle to send  messages    to
				Bitmap **back,                  //-- Pointer to Bitmap Pointer (Background)
				int frame,                      //-- Desired Frame
				int width,                      //-- Desired Width
				int height,                     //-- Desired Height
				float   aspect,                 //-- Desired Aspect Ratio
				Bitmap **fore   = NULL,         //-- Pointer to Bitmap Pointer (Foreground)
				DWORD   flag    = PREVIEW_UP );

		//----------------------------------------------------------------------
		//-- Channels Required
		//
		//    By setting this   flag,   the plug-in can request the host    to  generate
		//    the   given   channels. Prior to Rendering,   the host    will scan the
		//    plug-ins in the   chain   of  events and list all types of channels
		//    being requested. The plug-in, at the  time of the Render()    call,   
		//    will have access to these channels through    the channel interface
		//    described in  Bitmap.h    - BitmapStorage.
		//
		//    The   generation of these channels should not, normally,  be  a 
		//    default setting   for a   plug-in.    These   channels    are memory hungry   and
		//    if the    plug-in won't use   it, it should not   ask for it. Normally
		//    the   plug-in would ask   the user    which   channels    to  use and set only
		//    the   proper flags.
		//
		
		dVirtual     DWORD   ChannelsRequired       ( ) {   return BMM_CHAN_NONE; }
		

		//----------------------------------------------------------------------
		//-- R2 Stuff Below ----------------------------------------------------
		//----------------------------------------------------------------------
	
		TimeChange	timeChange;
		UndoNotify*	undonotify;

		dVirtual HWND	DlgHandle			( void ) { return dlghWnd; }

		//-- Filter Control Dialogue Interactivity -----------------------------

		dVirtual void	MakeDlgInteractive	( HWND hWnd );
		dVirtual BOOL	IsInteractive		( void ) { return interactive; }

		//-- Trackview Node Functions ------------------------------------------

		dVirtual ITrackViewNode *CreateNode ( );
		dVirtual ITrackViewNode *Node ( ) { return ifi->Node(); }

		//-- FilterUpdate() ----------------------------------------------------
		//
		// Whenever a filter instance is created or updated (i.e. the user went,
		// through the Filter Edit Control dialogue) this is call is issued to 
		// the filter. The filter may use it to create/update its node controls.
		//
		// See example in negative.cpp.

		dVirtual void	FilterUpdate	( ) { }

};

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//--   Main Filter Manager Class
//
//

class FilterManager    {
	
		TCHAR                   name[MAXFILTERNAME];
		FLTInterface            *iface;
		ImageFilterInfo         *ifi;
		Interface               *max;

		//-- General Private    Methods
		
		BOOL                    SetupPlugIn                 ( HWND hWnd, WORD   item );
		void                    HandleMaskFile              ( HWND hWnd, WORD   item );
		
		//-- Image Filter   Private Methods
		
		int                     GetCurrentFilter            ( HWND hWnd, TCHAR *plugin  );
		void                    HandleFilterDialogState     ( HWND hWnd );

	public:
	
		FLTExport                   FilterManager           ( FLTInterface  *i);
		FLTExport                   FilterManager           ( FLTInterface  *i,const    TCHAR   *name);
		FLTExport                   ~FilterManager          ( );
		
		FLTExport FLTInterface  *iFace                      ( ) {   return iface;}
		
		void                        DoConstruct             ( FLTInterface  *i,const    TCHAR   *name);
		
		FLT_FilterList              fltList;
		FLTExport void              ListFilters             ( );
		
		FLTExport HINSTANCE         AppInst                 ( );
		FLTExport HWND              AppWnd                  ( );
		FLTExport DllDir            *AppDllDir              ( );
		FLTExport Interface         *Max                    ( ) {   return max; }
		
		//-- User Interface -------------------------------

		BOOL						ImageFilterControl		( HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam );
		
		//-- This function will create a    mask bitmap based
		//    on the    given   ImageFilterInfo class.
		
		Bitmap                      *ProcessMask                    ( HWND hWnd, ImageFilterInfo    *ii );
		
		//-- This function will list all    available filter 
		//    plug-ins. The "item" argument defines an id 
		//    for   a combo box to  receive the list whithin 
		//    the   hWnd context. It returns the number of  
		//    filters found.
		
		FLTExport int               GetFilterList                   ( HWND hWnd, int item );
		FLTExport int               GetLayerList                    ( HWND hWnd, int item );
		
		//-- This runs  the show. Thew  window handle is used
		//    to send progress messages back. See above the
		//    discussion about messages. The    host should
		//    check keyboard and    cancel buttons  and return
		//    FALSE to a FLT_PROGRESS or FLT_CHECKABORT
		//    message telling   the Plug-In to  cancel.
		
		FLTExport BOOL              RenderFilter     ( HWND hWnd, 
													   ImageFilterInfo *ii, 
													   Bitmap *map,
													   Bitmap *foreMap = NULL);
		
		//-- This will  bring   a full blown dialog giving  the
		//    user an interface to select   and define a plug-
		//    in filter. Returns    FALSE   if  the user    cancels.
		
		FLTExport BOOL              SelectImageFilter( HWND hWnd, ImageFilterInfo *ii    );
		
		//-- This will  fill out    the given combo box with a
		//    list of available mask options
		
		FLTExport void              ListMaskOptions  ( HWND hWnd, int item);

		//----------------------------------------------------------------------
		//-- R2 Stuff Below ----------------------------------------------------
		//----------------------------------------------------------------------
	
		//-- Internal Use

		FLTExport void              UpdateFilter		( ImageFilterInfo *ii );

		
};

//-----------------------------------------------------------------------------
//--   Forward References
//

extern FLTExport   void             OpenFLT         (  FLTInterface *i );
extern FLTExport   void             CloseFLT        (  );

//-----------------------------------------------------------------------------
//--   The Primary Filter Manager  Object
//
// TO  DO: Move    to  App data    structure?

extern FLTExport FilterManager *TheFilterManager; 

#endif

//-- EOF: filters.h -----------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -