PNGImageDecoder Slow For 8-bit PNGs

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P5
    • None
    • Affects Version/s: 24
    • Component/s: client-libs
    • None
    • Environment:

      Observed on Mac M2, OS 26.2

      The sun.awt.image.PNGImageDecoder is slower than ImageIO's png decoder.

      If the PNG image is 8-bit, and non-interlaced, then the code path it follows resembles:

      ```
      while (col < width) {
          if(wPixels !=null) {
              <other code>
          } else switch(bitDepth) {
              case 8: bPixels[col+rowOffset] = rowByteBuffer[spos++];
                  break;
          }
      }
      ```

      So we're calling `bPixels[j] = rowByteBuffer[k]` individually for width-many iterations. Using System.arraycopy or passing rowByteBuffer directly to the ImageConsumers would be noticeably faster

            Assignee:
            Jeremy Wood
            Reporter:
            Jeremy Wood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: