AreaAveragingScalingFilter
Jeremy Wood
mickleness at gmail.com
Mon Apr 17 08:53:51 UTC 2023
I could be mistaken, but it looks like AreaAveragingFilter has a typo in
it. This method looks suspicious to me:
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20230417/64404475/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AreaAveragingScaleFilterTest.java.zip
Type: application/zip
Size: 2283 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/client-libs-dev/attachments/20230417/64404475/AreaAveragingScaleFilterTest.java.zip>
More information about the client-libs-dev
mailing list