| From | Sent On | Attachments |
|---|---|---|
| Chris McCormick | Jul 3, 2011 8:49 am | |
| Mario Mey | Jul 3, 2011 8:55 am | |
| John Harrison | Jul 3, 2011 8:59 am | |
| Mario Mey | Jul 3, 2011 9:18 am | |
| batinste | Jul 3, 2011 10:07 am | |
| Mathieu Bouchard | Jul 3, 2011 10:36 am | |
| Chris McCormick | Jul 3, 2011 5:55 pm | |
| Hans-Christoph Steiner | Jul 3, 2011 9:24 pm | |
| Mathieu Bouchard | Jul 4, 2011 10:43 am | |
| batinste | Jul 4, 2011 2:04 pm | |
| batinste | Jul 4, 2011 11:57 pm | |
| batinste | Jul 5, 2011 7:05 am | |
| Hans-Christoph Steiner | Jul 5, 2011 9:04 am | |
| batinste | Jul 5, 2011 10:43 am |
| Subject: | Re: [PD] Extracting RGB components of iemgui's | |
|---|---|---|
| From: | Mathieu Bouchard (mat...@artengine.ca) | |
| Date: | Jul 3, 2011 10:36:27 am | |
| List: | at.iem.pd-list | |
On Sun, 3 Jul 2011, Chris McCormick wrote:
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.
as a reference, [#to_iem] supports both iem colour formats, the 18-bit format for files, and the 24-bit format for messages. Such a patch is very simple :
http://gridflow.ca/svn/trunk/abstractions/%23to_iem.pd http://gridflow.ca/help/%23to_iem-help.html
But it does the opposite conversion of what you are trying to do.
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;
this is the 18 bit iem format that you are trying to convert to a 3*8 bit component format. You are correctly extracting blue and green, where the shift is 0*6-2 for blue, 1*6-2 for green, but it has to be 2*6-2 for red.
For the 24 bit iem format, instead, you have to shift by 0*8, 1*8, 2*8.
-2 is the difference between 6 bits per component and 8 bits per component.
Note that those conversions scale in a crude way, such that 63 is scaled to 252, instead of the maximum 255. If you want to scale more appropriately to fill the whole range, you need to post-process those components a little bit(s) :
r = r | (r>>6) g = g | (g>>6) b = b | (b>>6)
_______________________________________________________________________ | Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
_______________________________________________
Pd-l...@iem.at mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list





