What Is Plug-In Hosting and What Is It For?
With the release of Adobe's Photoshop 2.5, Adobe developed the ability for Photoshop to make use of add-on modules called plug-in filters, the best known of which are Kai's Power Tools and Power Goo. Since then, several thousand filters have been created allowing users to create an unlimited number of special imaging effects. The ImageMan DLL includes support for these filters so you can allow your users access to these thousands of filters.
Using the Plug-In Host
ImageMan's plug-in hosting is performed by a completely separate module that ImageMan's core library makes use of. The plug-in host was developed by us in such a way that it is totally optional. Therefore, it stands completely separate from the ImageMan core library. ImageMan does not depend on the host, but the host does depend on the ImageMan core. If your application developed with the ImageMan libraries is not going to use plug-ins, then you don't need to package the Plug-In support dll with your applications.
Your application drives the plug-in host through a set of nine high- and low-level ImageMan functions. Through the high-level functions, you can programmatically determine whether or not the plug-in host is present and whether or not it is currently loaded and enabled. You can also unload the host from memory, thus keeping your run-time memory requirements to a minimum. When you load the host, you must also tell what directory it can expect to find the plug-ins that will be available to it for processing.
With use of the high- and low-level ImageMan functions for plug-in hosting, you - the programmer - have complete control over loading and unloading the host as well as the plug-ins themselves.
Enumerating the Plug-Ins and Populating a Plug-In Selection
Although most of us now use either Windows 95 or Windows NT which both support long file names, most plug-ins are named in the 8.3 file naming convention. Because of this, it's hard to tell just exactly what a particular plug-in is going to do. Also, contained in internal information within the plug-in is a field called the category. The category that a filter belongs to is specified by the plug-in developer. Some of the more common category types are things such as Distortion , Noise and Gradient .
For each filter the host finds in the plug-in directory, it extracts this helpful information and sends it back to your application's enumeration callback function. It's through use of this function that you can build your own dialog box using something like a drop-down combo box which is populated with the different plug-ins titles (this is given in the lname parameter show below) and organized by their given categories. Of course, to actually invoke the plug-in selected, you need to use the actual plug-in's file name also supplied to you in the callback function.
The enumeration callback type:
typedef BOOL (IMAPI * PIIMENUMCALLBACKPROC)(LPSTR lname, LPSTR fname, LPSTR cat, LONG dwUserInfo) ;
The function details on ImgPlugInEnumerate show a coding example of how to use the enumeration function in conjunction with the associated enumeration callback function.
Plug-In Host Status Callbacks
Because the plug-ins are generally quite processor intensive, once they are invoked it may take a long time to fully process a large image. This is why we implemented a plug-in status callback. The host make callbacks into your application once you have registered an ImageMan STATUSPROC with the host. This is almost identical in functionality to ImageMan's regular image load/save status callback. The difference is that although you can specify a callback interval it serves no use. The plug-ins make callbacks to the host when they want. The plug-in author made the decision on the frequency of the plug-in's call back to the host based on what they felt is necessary.
Typically, you would use this function to display a progress bar while the plug-in is doing its thing. This gives feedback to the user of your application that the plug-in is still processing the image so your application doesn't look like it is hung up.
The status function typedef is:
typedef int (WINAPI *STATUSPROC)(HANDLE hImage, UINT lInterval, DWORD dwUserInfo);
See the function details on ImgPlugInSetStatusProc for an example of using the status callback function.
Where Did You Get These Plug-Ins?
There are many thousands of plug-ins that have been developed over the years that are available as freeware and/or shareware as well as many other 3rd party commercially available plug-in packages.
Be sure to check the DTI website for more Plug-Ins and links to additional Plug-In resources.
Building Your Own Plug-Ins
The information needed to develop your own plug-ins is published by Adobe and an SDK is also available with sample plug-ins at the Adobe web site. Go to www.adobe.com to get this information and the free SDK. The samples are all written in C and are complete with Microsoft VC++ project files for immediate compiling of the plug-in DLLs.
There are also other tools freely available on the Internet. One of the most popular tools that has been around a while is the Filter Factory. It is its own little plug-in development environment and requires no knowledge of the C language to build your own plug-ins in a very short period of time.
Plug-In Tools and Utilities
PiCO - the Plug-In Commander is a nice little tool that can convert plug-ins requiring the plugin.dll packaged with Photoshop to plug-ins that do not have this dependency.
The Filter Factory - available on many websites and from the FilterFactory CD which you can purchase directly off of many of those same sites.
There are many well populated web sites containing many of these and links to other sites with plug-in development resources. Be sure to check out the DTI website for links to these sites and more.
Will Any Plug-In Filter Work With ImageMan?
Since many plug-ins were written and expected only to run in the Adobe Photoshop environment, the answer is no. The reason is that there is a DLL that is packaged with Photoshop that many filter have been statically linked to. This DLL is called plugin.dll. If you own a copy of Photoshop you can move or copy that DLL to your system directory and then those statically linked filters will work. When you write your own filters based on Adobe's SDK they will not be linked to this library and will work just fine. Filters developed with the more recent version of Filter Factory will not work until you recompile them with the PiCO software mentioned above. Earlier versions of the Filter Factory do not link to plugin.dll but they produce a slightly larger file image.
© 1995-2004 Data Techniques, Inc. All rights reserved.