Package VASSAL.tools.image
Class GeneralFilter
java.lang.Object
VASSAL.tools.image.GeneralFilter
public final class GeneralFilter extends Object
GeneralFilter is a pluggable image resampler.
GeneralFilter up- or down-samples images or parts of
images using any one of the various filters contained in it as internal
classes.
GeneralFilter is based on filter_rcg.c, which
contains modifications made by Ray Gardener to filter.c,
originally by Dale Schumacher. filter.c appeared in
Dale Schumacher. "General Filtered Image Rescaling". Graphics Gems III. David Kirk, ed. Academic Press. 1994. pp. 8–16, 414–424.and the source for
filter.c and filter_rcg.c
are available
here.
Both filter.c and filter_rcg.c are in the
Public Domain.
The filters provided here are intended for scaling, though other filters could be created which resample in other ways.
- Author:
- Joel Uckelman
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGeneralFilter.BellFilterDeprecated.class is not used anywhere and will be removedstatic classGeneralFilter.BoxFilterDeprecated.class is not used anywhere and will be removedstatic classGeneralFilter.BSplineFilterDeprecated.class is not used anywhere and will be removedstatic classGeneralFilter.FilterThe abstract base class for filters.static classGeneralFilter.HermiteFilterDeprecated.class is not used anywhere and will be removedstatic classGeneralFilter.Lanczos3FilterA Lanczos filter with radius 3.static classGeneralFilter.MitchellFilterA Mitchell filter.static classGeneralFilter.TriangleFilterDeprecated.class is not used anywhere and will be removed -
Field Summary
Fields Modifier and Type Field Description static intOPAQUEstatic intTRANS_PREMULTstatic intTRANS_UNPREMULT -
Method Summary
Modifier and Type Method Description static voidresample(int[] src_data, boolean src_data_consecutive, int sx0, int sy0, int sx1, int sy1, int sw, int sh, int src_type, int srcWidth, int srcHeight, int[] dst_data, int dx0, int dy0, int dx1, int dy1, int dw, int dh, int dstWidth, int dstHeight, float xscale, float yscale, GeneralFilter.Filter filter)static voidzoom(WritableRaster dstR, Rectangle dst_fr, BufferedImage srcI, GeneralFilter.Filter filter)Filters a portion of the source image.static BufferedImagezoom(Rectangle dst, BufferedImage src, GeneralFilter.Filter filter)Filters the entire source image.
-
Field Details
-
OPAQUE
public static final int OPAQUE- See Also:
- Constant Field Values
-
TRANS_PREMULT
public static final int TRANS_PREMULT- See Also:
- Constant Field Values
-
TRANS_UNPREMULT
public static final int TRANS_UNPREMULT- See Also:
- Constant Field Values
-
-
Method Details
-
zoom
Filters the entire source image. This is a convenience function which callszoom(WritableRaster, Rectangle, BufferedImage, Filter), setting the destination rectangle as the bounds of the destination tile.- Parameters:
dst- the destination rectanglesrc- the soure imagefilter- the filter to apply- Throws:
ClassCastException- ifsrcdoes not store its data in aDataBufferInt
-
zoom
public static void zoom(WritableRaster dstR, Rectangle dst_fr, BufferedImage srcI, GeneralFilter.Filter filter)Filters a portion of the source image.- Parameters:
dstR- the destination tile to calculatedst_fr- the bounds of the whole destination imagesrcI- the source imagefilter- the filter to apply- Throws:
ClassCastException- ifsrcIdoes not store its data in aDataBufferInt
-
resample
public static void resample(int[] src_data, boolean src_data_consecutive, int sx0, int sy0, int sx1, int sy1, int sw, int sh, int src_type, int srcWidth, int srcHeight, int[] dst_data, int dx0, int dy0, int dx1, int dy1, int dw, int dh, int dstWidth, int dstHeight, float xscale, float yscale, GeneralFilter.Filter filter)
-