scaleY = filterResolutionY / (float)devRect.height;
}
// Only resample if either scaleX or scaleY is
// smaller than 1
RenderableImage localSource = getSource();
RenderContext localRenderContext = renderContext;
if((scaleX < 1) || (scaleY < 1)){
// System.out.println("filterRes X " + filterResolutionX +
// " Y : " + filterResolutionY);
scaleX = scaleX < scaleY ? scaleX : scaleY;
scaleY = scaleX;
//
// Create a rendering that will be less than
// or equal to filterResolutionX by filterResolutionY.
//
AffineTransform newUsr2Dev
= AffineTransform.getScaleInstance(scaleX, scaleY);
newUsr2Dev.concatenate(usr2dev);
//
// Create a new RenderingContext
//
RenderContext newRenderContext
= (RenderContext)renderContext.clone();
newRenderContext.setTransform(newUsr2Dev);
Shape aoi = renderContext.getAreaOfInterest();
if (aoi == null)
aoi = getBounds2D();
//
// We need to grow the area of interest by a few
// pixels in device space so the AffineRed can
// interpolate at the edges..
//
Rectangle2D newAOI = aoi.getBounds2D();
newAOI = new Rectangle2D.Double
(newAOI.getX()-1/scaleX,
newAOI.getY()-1/scaleY,
newAOI.getWidth()+2/scaleX,
newAOI.getHeight()+2/scaleY);
newRenderContext.setAreaOfInterest(newAOI);
//
// Now, use an AffineRable that will apply the
// resampling
//
AffineTransform resampleTxf
= AffineTransform.getScaleInstance(1/scaleX, 1/scaleY);
RenderedImage result = null;
result = localSource.createRendering(newRenderContext);
if (result != null)
result = new AffineRed
(GraphicsUtil.wrap(result),
resampleTxf, renderContext.getRenderingHints());
return result;
}
return localSource.createRendering(localRenderContext);
}
}
return null;
}