public void setHints(int hints) {
passthrough = ((hints & neededHints) != neededHints);
super.setHints(hints);
}
Later on the passthrough field is used as:
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte pixels[], int off,
int scansize) {
if (passthrough) {
super.setPixels(x, y, w, h, model, pixels, off, scansize);
} else {
accumPixels(x, y, w, h, model, pixels, off, scansize);
}
}
This makes me think we want passthrough to be true when we match
specific hints (“neededHints”) promising to deliver the pixel data in
whole scanlines from top-to-bottom. So the “!=“ in setHints(..) should
be “==“.
If I set passthrough to true for BufferedImages (which always deliver pixels from top to bottom in entire scanlines), then the execution time of this filter reduces to less than 5% of its current time. But it introduces scaling artifacts and looks lower quality.
So if (?) my theory is correct that there is a typo, and knowing that the AreaAveragingFilter is effectively internally deprecated <https://bugs.openjdk.org/browse/JDK-6196792?jql=status = Open AND text ~ "AreaAveragingScaleFilter"> : is anyone interested in discussing this with me further? I attached my (very rough) test program that demonstrates both the performance difference and the scaling artifacts.
(My broad goal is to create thumbnails of large images. If I used a Graphics2D to scale the image more than 50%, then I also see scaling artifacts with that approach. I know “Filthy Rich Clients” outlined a solution to that problem, but it’s expensive. So I’m dusting off this filter to see if it can work.)
Regards, - Jeremy
<<attachment: AreaAveragingScaleFilterTest.java.zip>>
