static int GetBilinear(double x, double y, int[] colors) { int[] px0 = new int[3]; px0[0] = (colors[0] & 0xFF0000) >> 16; px0[1] = (colors[0] & 0x00FF00) >> 8; px0[2] = colors[0] & 0x0000FF; int[] px1 = new int[3]; px1[0] = (colors[1] & 0xFF0000) >> 16; px1[1] = (colors[1] & 0x00FF00) >> 8; px1[2] = colors[1] & 0x0000FF; int[] px2 = new int[3]; px2[0] = (colors[2] & 0xFF0000) >> 16; px2[1] = (colors[2] & 0x00FF00) >> 8; px2[2] = colors[2] & 0x0000FF; int[] px3 = new int[3]; px3[0] = (colors[3] & 0xFF0000) >> 16; px3[1] = (colors[3] & 0x00FF00) >> 8; px3[2] = colors[3] & 0x0000FF; int[] crRet = new int[3]; for (int i = 0; i < 3; i++) { double m0 = px0[i] + x * (px1[i] - px0[i]); double m1 = px2[i] + x * (px3[i] - px2[i]); double my = m0 + y * (m1 - m0); crRet[i] = Image.SAFECOLOR((int)my); } return(Image.rgb(crRet[0], crRet[1], crRet[2])); }
static int fixpix(int color, double procent, FloatRGB colpro) { int colorR = (color & 0xFF0000) >> 16; int colorG = (color & 0x00FF00) >> 8; int colorB = color & 0x0000FF; colorR = colorR + (int)((255 - colorR) * procent * colpro.r); colorG = colorG + (int)((255 - colorG) * procent * colpro.g); colorB = colorB + (int)((255 - colorB) * procent * colpro.b); return(Image.rgb(colorR, colorG, colorB)); }
public ColorToneFilter(int tone, int saturation) { double l = 0.0f; double[] result = RGBtoHLS(tone, _hue, l, _saturation); _hue = result[0]; l = result[1]; _saturation = result[2]; _saturation = _saturation * (saturation / 255.0) * (saturation / 255.0); _saturation = ((_saturation < 1) ? _saturation : 1); for (int i = 0; i < 256; i++) { int cr = Image.rgb(i, i, i); double h = 0.0f, ll = 0.0f, s = 0.0f; result = RGBtoHLS(cr, h, ll, s); h = result[0]; ll = result[1]; s = result[2]; ll = ll * (1 + (128 - Math.Abs(saturation - 128)) / 128.0 / 9.0); _lum_tab[i] = ((ll < 1) ? ll : 1); } }
static int DoubleRGB_to_RGB(double r, double g, double b) { return(Image.rgb(Image.SAFECOLOR((int)(r * 255)), Image.SAFECOLOR((int)(g * 255)), Image.SAFECOLOR((int)(b * 255)))); }