/* * aNNiMON 2011 * For more info visit http://annimon.com/ */ package Effects; import Main.L; /** * * @author aNNiMON */ public class eSmooth extends Effect { Amount getAmount() { return new Amount(1, 25, 3); } String getLabel() { return L.str[L.blur]; } void applyEffect() { int value = am.cur[0]; super.progressMax = h; int[] newPixels = new int[w*h]; for (int row = 0; row < h; ++row) { super.progress = row; for (int col = 0; col < w; ++col) { int a = 0, r = 0, g = 0, b = 0, c = 0; for (int subrow = row - value; subrow <= row + value; ++subrow) { if (subrow >= 0 && subrow < h) { for (int subcol = col - value; subcol <= col + value; ++subcol) { if (subcol >= 0 && subcol < w) { int rgb = pix[subrow*w+subcol]; a += (rgb >> 24) & 0xff; r += (rgb >> 16) & 0xff; g += (rgb >> 8) & 0xff; b += rgb & 0xff; c++; } } } } a /= c; r /= c; g /= c; b /= c; newPixels[row*w+col] = (a << 24) | (r << 16) | (g << 8) | b; } } pix = newPixels; } }