docs: public static void resample(int[] source, int[] dest, int length, int offset, int stride, float[] out) {
  		int i, j;
  		float sizfac;
  		float inSegment;
  		float outSegment;
  		int a, r, g, b, nextA, nextR, nextG, nextB;
  		float aSum, rSum, gSum, bSum;
  		float[] in;
  		int srcIndex = offset;
  		int destIndex = offset;
  		int lastIndex = source.length;
  		int rgb;
  
  		in = new float[length+2];
  		i = 0;
  		for (j = 0; j < length; j++) {
  			while (out[i+1] < j)
  				i++;
  			in[j] = i + (float) (j - out[i]) / (out[i + 1] - out[i]);
  //			in[j] = ImageMath.clamp( in[j], 0, length-1 );
  		}
  		in[length] = length;
  		in[length+1] = length;
  
  		inSegment  = 1.0f;
  		outSegment = in[1];
  		sizfac = outSegment;
  		aSum = rSum = gSum = bSum = 0.0f;
  		rgb = source[srcIndex];
  		a = (rgb >> 24) & 0xff;
  		r = (rgb >> 16) & 0xff;
  		g = (rgb >> 8) & 0xff;
  		b = rgb & 0xff;
  		srcIndex += stride;
  		rgb = source[srcIndex];
  		nextA = (rgb >> 24) & 0xff;
  		nextR = (rgb >> 16) & 0xff;
  		nextG = (rgb >> 8) & 0xff;
  		nextB = rgb & 0xff;
  		srcIndex += stride;
  		i = 1;
  
  		while (i <= length) {
  			float aIntensity = inSegment * a + (1.0f - inSegment) * nextA;
  			float rIntensity = inSegment * r + (1.0f - inSegment) * nextR;
  			float gIntensity = inSegment * g + (1.0f - inSegment) * nextG;
  			float bIntensity = inSegment * b + (1.0f - inSegment) * nextB;
  			if (inSegment < outSegment) {
  				aSum += (aIntensity * inSegment);
  				rSum += (rIntensity * inSegment);
  				gSum += (gIntensity * inSegment);
  				bSum += (bIntensity * inSegment);
  				outSegment -= inSegment;
  				inSegment = 1.0f;
  				a = nextA;
  				r = nextR;
  				g = nextG;
  				b = nextB;
  				if (srcIndex < lastIndex)
  					rgb = source[srcIndex];
  				nextA = (rgb >> 24) & 0xff;
  				nextR = (rgb >> 16) & 0xff;
  				nextG = (rgb >> 8) & 0xff;
  				nextB = rgb & 0xff;
  				srcIndex += stride;
  			} else {
  				aSum += (aIntensity * outSegment);
  				rSum += (rIntensity * outSegment);
  				gSum += (gIntensity * outSegment);
  				bSum += (bIntensity * outSegment);
  				dest[destIndex] = 
  					((int)Math.min(aSum/sizfac, 255) << 24) |
  					((int)Math.min(rSum/sizfac, 255) << 16) |
  					((int)Math.min(gSum/sizfac, 255) << 8) |
  					(int)Math.min(bSum/sizfac, 255);
  				destIndex += stride;
  				aSum = rSum = gSum = bSum = 0.0f;
  				inSegment -= outSegment;
  				outSegment = in[i+1] - in[i];
  				sizfac = outSegment;
  				i++;
  			}
  		}
  	}