public void morph(int[] srcPixels, int[] destPixels, int[] outPixels, WarpGrid srcGrid, WarpGrid destGrid, int width, int height, float t) { WarpGrid newGrid = new WarpGrid(srcGrid.rows, srcGrid.cols, width, height); srcGrid.lerp(t, destGrid, newGrid); srcGrid.warp(srcPixels, width, height, srcGrid, newGrid, outPixels); int[] destPixels2 = new int[width * height]; destGrid.warp(destPixels, width, height, destGrid, newGrid, destPixels2); crossDissolve(outPixels, destPixels2, width, height, t); }
int gridRows = sourceGrid.rows; splines = new WarpGrid(rows, gridCols, 1, 1); interpolateSpline(yrow, xrow, 0, gridRows, interpolated, 0, rows); interpolateSpline(yrow, xrow, 0, gridRows, interpolated, 0, rows); interpolateSpline(splines.xGrid, splines.yGrid, offset, gridCols, scale, 0, cols); scale[cols] = cols; ImageMath.resample(inPixels, intermediate, cols, y*cols, 1, scale); splines = new WarpGrid(gridRows, cols, 1, 1); interpolateSpline(sourceGrid.xGrid, sourceGrid.yGrid, offset, gridCols, splines.xGrid, offset2, cols); offset += gridCols; offset2 += cols; offset2 = 0; for (v = 0; v < gridRows; v++) { interpolateSpline(destGrid.xGrid, destGrid.yGrid, offset, gridCols, splines.yGrid, offset2, cols); offset += gridCols; offset2 += cols; interpolateSpline(xrow, yrow, 0, gridRows, scale, 0, rows); scale[rows] = rows; ImageMath.resample(intermediate, outPixels, rows, x, cols, scale);
protected int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace ) { int[] outPixels = new int[width * height]; if ( morphImage != null ) { int[] morphPixels = getRGB( morphImage, 0, 0, width, height, null ); morph( inPixels, morphPixels, outPixels, sourceGrid, destGrid, width, height, time ); } else if (frames <= 1) { sourceGrid.warp(inPixels, width, height, sourceGrid, destGrid, outPixels); } else { WarpGrid newGrid = new WarpGrid(sourceGrid.rows, sourceGrid.cols, width, height); for (int i = 0; i < frames; i++) { float t = (float)i/(frames-1); sourceGrid.lerp(t, destGrid, newGrid); sourceGrid.warp(inPixels, width, height, sourceGrid, newGrid, outPixels); } } return outPixels; }