Tutorial step 1: creating the main routines |
|
The main routine of any VirtualDub filter is the run function, which has this prototype: function runProc(const fa: PFilterActivation; const ff: PFilterFunctions): Integer; cdecl; The main items of interest are in the fa parameter:
Both structures are of type PCObj_VFBitmap. The main fields are:
Creating a dummy functionHere is a skeletal runProc function that simply runs source and destination pointers over the bitmap:
Function tutorialRunProc(const fa: PFilterActivation; const ff: PFilterFunctions): Integer; cdecl; Note that because VirtualDub bitmaps are inverted like Windows DIBs, this routine scans from bottom to top. Scanlines are still left-to-right, though. Implementing our color shiftWe want to emphasize green, and deemphasize blue. The easiest way to do this is to halve both blue and green, and to add 50% to green. 32-bit RGB format defines 8-bits for each pixel in $RRGGBB format, so we'll use this as our pixel alteration formula: new_pixel := (old_pixel AND $FF0000) + ((old_pixel AND $00FEFE) shr 1) + $008000; This breaks down as follows:
Now we can write this into our inner loop:
Function tutorialRunProc(const fa: PFilterActivation; const ff: PFilterFunctions): Integer; cdecl; That's it! We're done with the main processing routine, for now. |
© 2005 Fernando Reis < >Adapted from VirtualDub external filter SDK 1.05 documentation © 1999-2001 Avery Lee |