Revision as of 05:00, 23 November 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
public static java.awt.Color twoColorFromYUV(byte y, byte u, byte v) {
	return new java.awt.Color(Ts.twoColorFromYUVInt(y, u, v));
}
 
public static int twoColorFromYUVInt(byte y, byte u, byte v) {
	int red = (298 * ((y & 0xFF) - 16) + 409 * ((v & 0xFF) - 128) + 128) >> 8;
	int green = (298 * ((y & 0xFF) - 16) - 100 * ((u & 0xFF) - 128) - 208 * ((v & 0xFF) - 128) + 128) >> 8;
	int blue = (298 * ((y & 0xFF) - 16) + 516 * ((u & 0xFF) - 128) + 128) >> 8;
	red = red > 255 ? 255 : (red < 0 ? 0 : red);
	green = green > 255 ? 255 : (green < 0 ? 0 : green);
	blue = blue > 255 ? 255 : (blue < 0 ? 0 : blue);
	return ((red << 16) | (green << 8) | blue);
}


Back to Java

Alumni Liaison

Followed her dream after having raised her family.

Ruth Enoch, PhD Mathematics