AreaAveragingScalingFilter
Aleksei Ivanov
alexey.ivanov at oracle.com
Mon Apr 17 11:43:06 UTC 2023
Hi Jeremy,
The intention could be /to pass through/ if the value of hints is
different from the needed ones. That is the filter activates if and only
if |hints == neededHints|, otherwise it doesn't do anything and forwards
calls to its superclass.
--
Regards,
Alexey
On 17/04/2023 09:53, Jeremy Wood wrote:
> 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 iseffectively 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/ca0b3ac3/attachment.htm>
More information about the client-libs-dev
mailing list