This document contains the API specification of the image filter for Gloria.
Note: This is a tentative plan. The API may change in the future.
Gloria (version 0.30 and later) comes with a plug-in mechanism that allows you to supply image CODECs or filters for yourself. By default, you find a few CODECs in the $GLORIA/codec directory and several filters in the $GLORIA/filter directory all of which are in the JAR format, where $GLORIA is the directory in which Gloria is installed. The plug-in mechanism is a powerful way to add new functions to Gloria.
To create a new image filter for Gloria, do the following things.
GloriaFilter
interface (see the next section)
The JAR file may contain more than one class
file, but its name must coincide
with the name of the class that implements
the GloriaFilter
interface, except for the extension of the
file. For example, if ExampleFilter.class
is the class file that implements the GloriaFilter
interface, the JAR file should be ExampleFilter.jar
.
Restart Gloria to load newly added plug-ins.
GloriaFilter
interfaceAny image filters for Gloria must implement
the GloriaFilter
interface. A class that implements the GloriaFilter
interface wraps the detail of filtering.
The GloriaFilter
interface is shown in the following.
/** GloriaFilter
* Copyright (C) 1999 Satoru Muto
* All rights reserved.
*/
package gloria;
import java.awt.image.BufferedImage;
import java.util.Map;
public interface GloriaFilter {
public abstract BufferedImage filter(BufferedImage src);
public abstract Map getOption();
public abstract void setOption(Map map);
public abstract String getName();
public abstract String getDescription();
public abstract String getVersion();
public abstract String getAuthor();
public abstract String getComment();
}
The filter(BufferedImage src)
method should return a filtered image of
src
. The return value should be an instance
of BuffreredImage
.
The getOption()
method may be used to get an instance of Map
that can be used as a backing store
of options. Conversely, the setOption(Map map)
method may be used to set options. [These
two methods are only placeholders at present.
You may implemtent getOption()
to return null
or setOption(Map map)
to be NOP.]
The getName()
method should return the name of the plug-in.
The string returned by getName()
should represent the essential role of the
plug-in and be as short as possible. The
getDescription()
method should give a more detailed description
about the plug-in. The getVersion()
method should return the version. The getAuthor()
method should return the name of the author.
The getComment()
method can be used to indicate copyright
notice, e-mail address of the author, and
so on. Those methods are used to display
information about the plug-in in Gloria.
GloriaFilter
interface - BrightenFilter
Gloria comes with several default image filters,
each of which is packed in a JAR file as
a Gloria plug-in. BrightenFilter
is a class that implements the GloriaFilter
interface and, as its name suggests, can
be used to brighten an image. The BrightenFilter
class is shown in the following.
/** BrightenFilter
* Copyright (C) 1999 Satoru Muto
* All rights reserved.
*/
package gloria.filter;
import java.awt.image.*;
import java.util.Map;
public class BrightenFilter implements gloria.GloriaFilter {
public BufferedImage filter(BufferedImage src) {
RescaleOp op = new RescaleOp(1.2f, 0.0f, null);
return op.filter(src, null);
}
public Map getOption() {
return null;
}
public void setOption(Map map) {
// Do nothing!
}
public String getName() {
return "Brighten";
}
public String getDescription() {
return "A filter that brightens an image.";
}
public String getAuthor() {
return "Satoru Muto";
}
public String getVersion() {
return "1.0";
}
public String getComment() {
return "Copyright (C) 1999 Satoru Muto";
}
}
This example code is sufficient to see how
to implement the GloriaFilter
interface. Note that the real task of filtering is
done by RescaleOp.filter()
. The GloriaFilter
interface is used only as a wrapper for
Gloria.
Copyright (C) 1999 Satoru Muto