/** * Turn a color int into a premultiplied device color */ private static int premultiplyColor(int c) { int r = Color.red(c); int g = Color.green(c); int b = Color.blue(c); int a = Color.alpha(c); // now apply the alpha to r, g, b r = mul255(r, a); g = mul255(g, a); b = mul255(b, a); // now pack it in the correct order return pack8888(r, g, b, a); }
/** * Turn a color int into a premultiplied device color */ private static int premultiplyColor(int c) { int r = Color.red(c); int g = Color.green(c); int b = Color.blue(c); int a = Color.alpha(c); // now apply the alpha to r, g, b r = mul255(r, a); g = mul255(g, a); b = mul255(b, a); // now pack it in the correct order return pack8888(r, g, b, a); }
private static void makeRamp(int from, int to, int n, int[] ramp8888, short[] ramp565, short[] ramp4444) { int r = getR32(from) << 23; int g = getG32(from) << 23; int b = getB32(from) << 23; int a = getA32(from) << 23; // now compute our step amounts per componenet (biased by 23 bits) int dr = ((getR32(to) << 23) - r) / (n - 1); int dg = ((getG32(to) << 23) - g) / (n - 1); int db = ((getB32(to) << 23) - b) / (n - 1); int da = ((getA32(to) << 23) - a) / (n - 1); for (int i = 0; i < n; i++) { ramp8888[i] = pack8888(r >> 23, g >> 23, b >> 23, a >> 23); ramp565[i] = pack565(r >> (23+3), g >> (23+2), b >> (23+3)); ramp4444[i] = pack4444(r >> (23+4), g >> (23+4), b >> (23+4), a >> (23+4)); r += dr; g += dg; b += db; a += da; } }
private static void makeRamp(int from, int to, int n, int[] ramp8888, short[] ramp565, short[] ramp4444) { int r = getR32(from) << 23; int g = getG32(from) << 23; int b = getB32(from) << 23; int a = getA32(from) << 23; // now compute our step amounts per componenet (biased by 23 bits) int dr = ((getR32(to) << 23) - r) / (n - 1); int dg = ((getG32(to) << 23) - g) / (n - 1); int db = ((getB32(to) << 23) - b) / (n - 1); int da = ((getA32(to) << 23) - a) / (n - 1); for (int i = 0; i < n; i++) { ramp8888[i] = pack8888(r >> 23, g >> 23, b >> 23, a >> 23); ramp565[i] = pack565(r >> (23+3), g >> (23+2), b >> (23+3)); ramp4444[i] = pack4444(r >> (23+4), g >> (23+4), b >> (23+4), a >> (23+4)); r += dr; g += dg; b += db; a += da; } }