[PD] Extracting RGB components of iemgui's

Chris McCormick chris at mccormick.cx
Sun Jul 3 17:50:05 CEST 2011


Hello,

Despite reading several posts in the archive and the source code in g_all_guis.c I am embarrassed to say that I am completely stumped by the problem of extracting the individual RGB components from the IEM saved color value in the .pd file, as ints between 0 and 255.

What I am doing (in the case where the saved value is negative) is:

	iemcolor = -1 - iemcolor;
	r = (iemcolor & 0x3f000) >> 14;
	g = (iemcolor & 0xfc0) >> 4;
	b = (iemcolor & 0x3f) << 2;

I would really appreciate it if someone gave me the opportunity to facepalm by illustraing the simple mistake in my approach.

Cheers!

Chris.

-------------------
http://mccormick.cx



More information about the Pd-list mailing list