<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    Hi Jeremy,<br>
    <br>
    The intention could be <i>to pass through</i> if the value of hints
    is different from the needed ones. That is the filter activates if
    and only if <code>hints == neededHints</code>, otherwise it doesn't
    do anything and forwards calls to its superclass.<br>
    <br>
    -- <br>
    Regards,<br>
    Alexey<br>
    <br>
    <div class="moz-cite-prefix">On 17/04/2023 09:53, Jeremy Wood wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:em065a3875-ff7a-40c4-b4a4-0158aa90d506@d8023f25.com">
      
      <style type="text/css">#x8140bcb8a2f345e
{font-family: Helvetica; font-size: 9pt;}</style>
      <style id="css_styles" type="text/css">blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc }blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; }a img { border: 0px; }li[style='text-align: center;'], li[style='text-align: center; '], li[style='text-align: right;'], li[style='text-align: right; '] {  list-style-position: inside;}body { font-family: Helvetica; font-size: 9pt; }.quote { margin-left: 1em; margin-right: 1em; border-left: 5px #ebebeb solid; padding-left: 0.3em; }</style>
      <div><span>I could be mistaken, but it looks like
          AreaAveragingFilter has a typo in it. This method looks
          suspicious to me:</span></div>
      <div id="x8140bcb8a2f345e" style="overflow-wrap: break-word;
        -webkit-nbsp-mode: space; line-break: after-white-space;">
        <div id="xed53aded5dd341b7956b8c6700b79786">
          <div><br>
          </div>
          <div>
            <div style="color:#080808;font-family:'JetBrains
              Mono',monospace;font-size:9.8pt;">
              <pre><span style="color:#0033B3;">public void </span><span style="color:#00627A;">setHints</span>(<span style="color:#0033B3;">int </span>hints) {
    <span style="color:#871094;">passthrough </span>= ((hints & <span style="color:#871094;font-style:italic;">neededHints</span>) != <span style="color:#871094;font-style:italic;">neededHints</span>);
    <span style="color:#0033B3;">super</span>.setHints(hints);
}</pre>
            </div>
          </div>
          <div><br>
          </div>
          <div>Later on the passthrough field is used as:</div>
          <div><br>
          </div>
          <div>
            <div style="color:#080808;font-family:'JetBrains
              Mono',monospace;font-size:9.8pt;">
              <pre><span style="color:#0033B3;">public void </span><span style="color:#00627A;">setPixels</span>(<span style="color:#0033B3;">int </span>x, <span style="color:#0033B3;">int </span>y, <span style="color:#0033B3;">int </span>w, <span style="color:#0033B3;">int </span>h,
                      <span style="color:#000;">ColorModel </span>model, <span style="color:#0033B3;">byte </span>pixels[], <span style="color:#0033B3;">int </span>off,
                      <span style="color:#0033B3;">int </span>scansize) {
    <span style="color:#0033B3;">if </span>(<span style="color:#871094;">passthrough</span>) {
        <span style="color:#0033B3;">super</span>.setPixels(x, y, w, h, model, pixels, off, scansize);
    } <span style="color:#0033B3;">else </span>{
        accumPixels(x, y, w, h, model, pixels, off, scansize);
    }
}</pre>
            </div>
          </div>
          <div><br>
          </div>
          <div>This makes me think we want passthrough to be <i>true</i> 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 “==“.</div>
          <div><br>
          </div>
          <div>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.</div>
          <div><br>
          </div>
          <div>So if (?) my theory is correct that there is a typo, and
            knowing that the AreaAveragingFilter is<span> </span><a href="https://bugs.openjdk.org/browse/JDK-6196792?jql=status
              = Open AND text ~ "AreaAveragingScaleFilter"" style="font-size: 9pt;" moz-do-not-send="true">effectively
              internally deprecated</a><span> : 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.</span></div>
          <div><span><br>
            </span></div>
          <div><span>(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.)</span></div>
          <div><span><br>
            </span></div>
          <div>Regards,</div>
          <div> - Jeremy</div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>