JPhotoBrush Hompage

Adding Plugins in JPhotoBrush Pro

Steps how to create plugins: All you need is a good java knowledge and idea about pixel and colors. and you can add innumerable and powerfull effects to JPhotoBrush Pro. This section contains info about how to attach your effect filters to JPhotoBrush Pro. You should know to make filters or manipulate images.

If any of you make a good plugin, mail me about it (send me the plugin, or send the link to it), so that I can put it up in this site for other users to use them(or provide a link). You will be acknowledged for your plug-ins.

1. create a package (for example, say testpackage)
2. write a public class say TestPlugin. Note that the class name must end with "Plugin" . It must have a default (No argument) constructor. It must implement interface imager.Plugin .

package imager;

public interface Plugin
public void operate(Application app);
public String getAuthorName();
public String getPluginDescription();
public String getPluginName();
public float getPluginVersion();

Note that this interface is in the imager package. Download the zip file containing both the source and class file for imager.Plugin class, unzip it and it should automatically be placed in a directory called 'imager' on unziping. Place the parent directory of the directory 'imager' in the classpath, so that your plugin class can access the Plugin class.

3. This class (TestPlugin in my example) will be loaded as the plugin class. It will be added as a menu item in the Effects -> Plug-In -> testpackage menu with the title returned by the implementation of method public String getPluginName().
It's method public void operate(imager.Application application) will be invoked in a new thread when the user selects this plugin from the menu. So no separate thread is required to be spawned inside this method. This method is the entry point to the plugin.

4. The interface imager.Application is implemented by the JPhotoBrush application. The javadoc descriptions are in the Application.html file. the class is as follows:
package imager;
public interface Application {

public void imageLoaded( imageFile,java.awt.Image image);
public void imageNotLoaded(Exception e);
public Image getImage();
public Image getSelectedImagePortion();
public java.awt.Rectangle getSelectedImageBounds();
public void setImage(Image image);
public void setImage(int[] pixels, int width, int height);
public void setSelectedImagePortion(Image image);
public int[] getImagePixels();
public void setProgress(int progress);
public void executeFilter(ImageFilter imageFilter);

Download the zip file containing the , Application.class and Application.html. When unziped, a directory 'imager' will be created and the files placed in it. Place the parent directory of 'imager' in the classpath, so that your plugin class can access the Application class.  Use any of the methods in this interface depending on the need. Some examples are given below regarding how to use this methods for different plugins.
5.  jar the package into a jar file (in my example it can be test.jar). You don't have to include any of the imager package classes in your jar, only include the classes you made. Now open JPhotoBrush Pro 1.2 and click on Tools-> Install Effects plugins menu item. This will open the 'Open File' dialog and you can choose the jar file you made and 'install' it as a plugin. Restart JPhotoBrush Pro (I know it is a pain in the neck to restart again, but I will solve this in the next version).
Note: JPhotoBrush Pro 1.2 does not allow subpackages for plugins. So you will have to have all the classes in the same plugins package. Also you cannot access any other packages. JPhotoBrush Pro will not be able to load the packages other than the plugin package ( for example you cannot use third party packages in your plugin for now). Ofcourse you can use all the jdk packages. This problem is expected to be solved in the coming versions.
6. Run JPhotoBrush now. You should see the plugin class title in the Effects-> Plug-Ins menu and the credit in Help->Plugins credit menu.


  • example 1:

public void operate( imager.Application application )
   java.awt.Image image = modifyImage( application.getSelectedImageRegion( ) ); /* this java.awt.Image modifyImage( java.awt.Image image ) is your own method that returns a
    modified image */
   application.setSelectedImageRegion( image );

  • example 2:

public void operate(imager.Application app)
  int w=app. getSelectedImageRegion().getWidth();
  int h=app. getSelectedImageRegion().getHeight();
  int[] pixels=application.getImagePixels();
  pixels=modifyImagePixels(pixels,w,h); /*  this int modifyImagePixels(int pixels,int w, int h)/ is your own method that modifies an 1D int array of ARGB pixel values and returns the modified pixel array.*/

Sample code
1. A plugin that displays a option dialog and then executes a filter operation. Click here to download the sample plugin package (source codes). Click here to download the compiled jar file . To run, add the jar file as a plugin with the Tools -> Add Effects Pluings menu in JPhotoBrush Pro.
To understand the code start with the file. The main class called TestPlugin implements the imager.Plugin interface. When it's operate method is called by JPhotoBrush Pro, it displays a Dialog box of RGBSwapDialog class. User can select option in that dialog and click 'ok'. Then in TestPlugin a filter of RGBSwapFilter class is instantiated and this filter is executed. The RGBSwapFilter extends from imager.DefaultImageFilter (which again extends from java.awt.image.ImageFilter). I suggest you write Filter classes that extends imager.DefaultImageFilter instead of extending directly from java.awt.image.ImageFilter because it contains additional methods, including the method to indicate the progress in JPhotoBrush Pro image operation progress bar.
Click here to get the source,class file and javadoc file for imager.DefaultImageFilter in zipped format.

If you need any help or face any problem, you can mail me at But please don't ask me basic java questions.