Get pixel array of float images in XSI... 2005-01-25 - By Aloys Baillet
Back Hi all,
I'm currently trying to read the color of a floating point image clip in XSI. Unfortunately the only information I could find to retrieve the color value of each pixel was "The data is formatted as an array of pixel color values, row by row." from the SDK doc. Then I tried to read the data in that way:
<code> // ---[ Get Image properties and pixels ]-- ---- ---- ---- ---- ---- ---- ---- ---- ---- const void * pixels = image.GetPixelArray(); long i_max = image.GetResX(); long j_max = image.GetResY(); long nb_chan = image.GetChannelSize(); long pix_size = image.GetChannelSize(); long max_size = image.GetPixelArraySize(); float r, g, b; long buf_idx = 0;
if (pix_size == sizeof(float)){ for (long i=0; i<i_max; i++){ for (long j=0; j<j_max; j++){ buf_idx = (i + j*i_max)*nb_chan; memcpy(&r, (float*)pixels + buf_idx, pix_size); buf_idx += pix_size; memcpy(&g, (float*)pixels + buf_idx, pix_size); buf_idx +=pix_size; memcpy(&b, (float*)pixels + buf_idx, pix_size); k++; } } }
</code>
But I didn't get the expected values... So has anyone allready tried to read float pixels in C++ in XSI? Or maybe somebody at Soft could help on this one? Thank you!
-- Aloys Baillet - TD / R&D @ La Maison - www.alamaison.fr --- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|