import java.awt.image.*; /*********************************************************************** * * An anti-aliasing image filter. * *
* This is an image filter class that can be used for anti-aliasing.
* The input image is scaled down by the factor ScalingFactor.
* The color value of an output pixel is computed by averaging the
* color values of the corresponding input pixels.
*
*
* Home page: www.source-code.biz
* Copyright 1997-2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.
* License: This is "Open Source" software and released under the GNU/GPL license.
* It is provided "as is" without warranty of any kind. Please contact the author for other licensing arrangements.
*
*
* Version history:
* 1997-07-01 Christian d'Heureuse (chdh): Module created.
* 2003-06-30 chdh: Revision.
*
***********************************************************************/
public class AntiAliasingFilter extends ImageFilter {
private static final ColorModel rgbModel = ColorModel.getRGBdefault();
private int scalingFactor;
private int scalingFactorSqr;
private int srcWidth;
private int srcHeight;
private int destWidth;
private int destHeight;
private int expectedSrcY;
private int accu[];
private int outLine[];
private void fatalError (String msg) {
throw new RuntimeException(getClass().getName()+": "+msg); }
private void sendOutputLine (int destY) {
consumer.setPixels (0,destY,destWidth,1,rgbModel,outLine,0,destWidth); }
private void genOutputLine() {
int p = 0;
for (int i=0; i