ImageMan ActiveX
Using the PlugIn Control

The PlugIn control is quite easy to use and includes only a few properties, methods and an event.

 

Prior to using the control your user must have installed PhotoShop PlugIns on their system. These are generally all installed in a single directory on the system and have a file extension of *.8BF. Your application will need to know the name of the directory since the Directory property of the control must be set to the directory containing the PlugIns before you can use the control.

 

The first step in using the PlugIns control is to set the Directory property to the directory containing the PlugIn files. If no PlugIns are found in the directory the control will generate a runtime error #33002.

 

Once the Directory property is set you can use the Title , Category , Filename and PlugInCount properties to get information on the PlugIns that are installed. The PlugInCount property is read-only and returns the number of PlugIns found in the directory specified by the Directory property. You can use this property along with the Title, Category and Filename properties, which are indexed, to get information on each PlugIn. The following code sample adds the titles of all the PlugIns found to a Listbox called List1.


' Set the PlugIn Dir

PlugIn1.Directory = "c:\plugins"

' Add the titles to the listbox

For I = 0 To PlugIn1.PlugInCount - 1

List1.AddItem PlugIn1.Title(I)

 

You can also use the SelectPlugIns method to display a dialog box containing all the PlugIns to the user. This method returns the filename of the PlugIn the user selected or an empty string if they canceled the dialog.

 

Once you know which PlugIn you wish to invoke you just need to call the InvokePlugIn method with the filename of the PlugIn as returned from the SelectPlugIns method or from the Filename property. You'll also need to pass the handle to a 24 bit DIB containing the image to be processed. When the InvokePlugIn method is called the PlugIns dialog will be invoked and the user will be able to configure the PlugIns various parameters. Once they have selected the parameters and clicked OK then the control will fire the Status event while the image is being processed. The Status event includes a parameter that is the percentage of the image that has been processed. Once this reaches one hundred percent the InvokePlugIn method will return and the image will have been processed.

 

The following code illustrates using the PlugIn control with the Image control to load an image and then process it.

 

Dim strFilename

Dim inthDIB

' Load an image into the ImageMan Image control

ImageControl1.GetFilename

' Make sure the user selected an image

If ImageControl1.Picture = "" Then

Exit Sub

End If

PlugIn1.Directory = "c:\plugins"

' Display the PlugIn selection dialog

FileName = PlugIn1.SelectPlugIns

 

' If the user selected a PlugIn then lets process the image

If FileName <> "" Then

' Make sure the ImageMan control contains a 24 bit image.

' If not then we can use the IncreaseTo method to increase the

' color depth

If ImageControl1.ImageColors <= 256 Then

ImageControl1.IncreaseTo 24

End If

hDIB = ImageControl1.hDIB

 

PlugIn1.InvokePlugIn FileName, hDIB

 

' Once the image is processed put it back in the ImageMan control

' And call Refresh to draw the new image.

ImageControl1.hDIB = hDIB

ImageControl1.Refresh

End If

 

 


© 2014 Data Techniques, Inc. All rights reserved.

Submit feedback on this topic