code: @Override
  	public void applyAdaptiveFiltering(PngByteArrayOutputStream inflatedImageData, List<byte[]> scanlines, Map<PngFilterType, List<byte[]>> filteredScanLines, int sampleSize) throws IOException {
  		for (int s = 0; s < scanlines.size(); s++) {
  			long bestSum = Long.MAX_VALUE;
  			PngFilterType bestFilterType = null;
  			for (Map.Entry<PngFilterType, List<byte[]>> entry : filteredScanLines.entrySet()) {
  				long sum = 0;
  				byte[] scanline = entry.getValue().get(s);
  				for (int i = 1; i < scanline.length; i++) {
  					sum += Math.abs(scanline[i]);
  				}
  
  				if (sum < bestSum) {
  					bestFilterType = entry.getKey();
  					bestSum = sum;
  				}
  			}
  			if (bestFilterType != null) {
  				scanlines.get(s)[0] = bestFilterType.getValue();
  			}
  		}
  
  		applyFiltering(null, scanlines, sampleSize);
  	}
docs: {@inheritDoc}