Package VASSAL.tools.image
Class GeneralFilter
java.lang.Object
VASSAL.tools.image.GeneralFilter
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
Modifier and TypeClassDescriptionstatic final class
A Bell filter.static final class
A box filter.static final class
A B-spline filter.static class
The abstract base class for filters.static final class
A Hermite filter.static final class
A Lanczos filter with radius 3.static final class
A Mitchell filter.static final class
A triangle, or bilinear, filter. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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) static void
zoom
(WritableRaster dstR, Rectangle dst_fr, BufferedImage srcI, GeneralFilter.Filter filter) Filters a portion of the source image.static BufferedImage
zoom
(Rectangle dst, BufferedImage src, GeneralFilter.Filter filter) Filters the entire source image.
-
Field Details
-
OPAQUE
public static final int OPAQUE- See Also:
-
TRANS_PREMULT
public static final int TRANS_PREMULT- See Also:
-
TRANS_UNPREMULT
public static final int TRANS_UNPREMULT- See Also:
-
-
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 source imagefilter
- the filter to apply- Throws:
ClassCastException
- ifsrc
does 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
- ifsrcI
does 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)
-