docs: private BufferedImage resample(BufferedImage pSource, BufferedImage pDest, InterpolationFilter pFilter) {
          final int dstWidth = pDest.getWidth();
          final int dstHeight = pDest.getHeight();
  
          final int srcWidth = pSource.getWidth();
          final int srcHeight = pSource.getHeight();
  
          /* create intermediate column to hold horizontal dst column zoom */
          final ColorModel cm = pSource.getColorModel();
  //        final WritableRaster work = cm.createCompatibleWritableRaster(1, srcHeight);
          final WritableRaster work = ImageUtil.createCompatibleWritableRaster(pSource, cm, 1, srcHeight);
  
          double xscale = (double) dstWidth / (double) srcWidth;
          double yscale = (double) dstHeight / (double) srcHeight;
  
          ContributorList[] contribY = new ContributorList[dstHeight];
          for (int i = 0; i < contribY.length; i++) {
              contribY[i] = new ContributorList();
          }
  
          // TODO: What to do when fwidth > srcHeight or dstHeight
          double fwidth = pFilter.support();
          if (yscale < 1.0) {
              double width = fwidth / yscale;
              double fscale = 1.0 / yscale;
  
              if (width <= .5) {
                  // Reduce to point sampling.
                  width = .5 + 1.0e-6;
                  fscale = 1.0;
              }
  
              for (int i = 0; i < dstHeight; i++) {
                  //contribY[i].n = 0;
                  contribY[i].p = new Contributor[(int) (width * 2.0 + 1 + 0.5)];
  
                  double center = (double) i / yscale;
                  int left = (int) Math.ceil(center - width);
                  int right = (int) Math.floor(center + width);
  
                  double density = 0.0;
  
                  for (int j = left; j <= right; j++) {
                      double weight = center - (double) j;
                      weight = pFilter.filter(weight / fscale) / fscale;
                      int n;
                      if (j < 0) {
                          n = -j;
                      }
                      else if (j >= srcHeight) {
                          n = (srcHeight - j) + srcHeight - 1;
                      }
                      else {
                          n = j;
                      }
  
                      /**/
                      if (n >= srcHeight) {
                          n = n % srcHeight;
                      }
                      else if (n < 0) {
                          n = srcHeight - 1;
                      }
                      /**/
  
                      int k = contribY[i].n++;
                      contribY[i].p[k] = new Contributor();
                      contribY[i].p[k].pixel = n;
                      contribY[i].p[k].weight = weight;
  
                      density += weight;
                  }
  
                  if ((density != 0.0) && (density != 1.0)) {
                      //Normalize.
                      density = 1.0 / density;
                      for (int k = 0; k < contribY[i].n; k++) {
                          contribY[i].p[k].weight *= density;
                      }
                  }
              }
          }
          else {
              for (int i = 0; i < dstHeight; ++i) {
                  //contribY[i].n = 0;
                  contribY[i].p = new Contributor[(int) (fwidth * 2 + 1 + 0.5)];
  
                  double center = (double) i / yscale;
                  double left = Math.ceil(center - fwidth);
                  double right = Math.floor(center + fwidth);
                  for (int j = (int) left; j <= right; ++j) {
                      double weight = center - (double) j;
                      weight = pFilter.filter(weight);
                      int n;
                      if (j < 0) {
                          n = -j;
                      }
                      else if (j >= srcHeight) {
                          n = (srcHeight - j) + srcHeight - 1;
                      }
                      else {
                          n = j;
                      }
  
                      /**/
                      if (n >= srcHeight) {
                          n = n % srcHeight;
                      }
                      else if (n < 0) {
                          n = srcHeight - 1;
                      }
                      /**/
  
                      int k = contribY[i].n++;
                      contribY[i].p[k] = new Contributor();
                      contribY[i].p[k].pixel = n;
                      contribY[i].p[k].weight = weight;
                  }
              }
          }
  
          final Raster raster = pSource.getRaster();
          final WritableRaster out = pDest.getRaster();
  
          // TODO: This is not optimal for non-byte-packed rasters...
          // (What? Maybe I implemented the fix, but forgot to remove the TODO?)
          final int numChannels = raster.getNumBands();
          final int[] channelMax = new int[numChannels];
          for (int k = 0; k < numChannels; k++) {
              channelMax[k] = (1 << pSource.getColorModel().getComponentSize(k)) - 1;
          }
  
          for (int xx = 0; xx < dstWidth; xx++) {
              ContributorList contribX = calcXContrib(xscale, fwidth, srcWidth, pFilter, xx);
              /* Apply horiz filter to make dst column in tmp. */
              for (int k = 0; k < srcHeight; k++) {
                  for (int channel = 0; channel < numChannels; channel++) {
  
                      double weight = 0.0;
                      boolean bPelDelta = false;
                      // TODO: This line throws index out of bounds, if the image
                      // is smaller than filter.support()
                      double pel = raster.getSample(contribX.p[0].pixel, k, channel);
                      for (int j = 0; j < contribX.n; j++) {
                          double pel2 = j == 0 ? pel : raster.getSample(contribX.p[j].pixel, k, channel);
                          if (pel2 != pel) {
                              bPelDelta = true;
                          }
                          weight += pel2 * contribX.p[j].weight;
                      }
                      weight = bPelDelta ? round(weight) : pel;
  
                      if (weight < 0) {
                          weight = 0;
                      }
                      else if (weight > channelMax[channel]) {
                          weight = channelMax[channel];
                      }
  
                      work.setSample(0, k, channel, weight);
  
                  }
              }/* next row in temp column */
  
              /* The temp column has been built. Now stretch it vertically into dst column. */
              for (int i = 0; i < dstHeight; i++) {
                  for (int channel = 0; channel < numChannels; channel++) {
  
                      double weight = 0.0;
                      boolean bPelDelta = false;
                      double pel = work.getSample(0, contribY[i].p[0].pixel, channel);
  
                      for (int j = 0; j < contribY[i].n; j++) {
                          // TODO: This line throws index out of bounds, if the image
                          // is smaller than filter.support()
                          double pel2 = j == 0 ? pel : work.getSample(0, contribY[i].p[j].pixel, channel);
                          if (pel2 != pel) {
                              bPelDelta = true;
                          }
                          weight += pel2 * contribY[i].p[j].weight;
                      }
                      weight = bPelDelta ? round(weight) : pel;
                      if (weight < 0) {
                          weight = 0;
                      }
                      else if (weight > channelMax[channel]) {
                          weight = channelMax[channel];
                      }
  
                      out.setSample(xx, i, channel, weight);
                  }
              }/* next dst row */
          }/* next dst column */
          return pDest;
      }