Hello all Christmas Crackers,
I am trying to convert some '16 bit planar RGB' data in memory into an array of 'rgba' structs, but can't figure out how to do it.
I am very inexperienced with this sort of thing.
I know that the buffer where the source image resides is made like this,
=============================
// three channels (RGB) in 16-bit (2 bytes) requires this much memory:
size_t memNeeded = width * height * 3U * 2U;
size_t adjusted = memNeeded;
// alloc this memory 16-byte aligned
unsigned char * imgbuffer = AlignedMalloc(adjusted);
=============================
I am told that when when it is written to disk with,
fwrite(imgbuffer, 1, memNeeded, fout);
it is "3 components, non-interleaved 16 bit with PC byte ordering"
I am not sure if this is a clue to how it is arranged in memory?
The closest I got was to have a loop like this and then write out the rgba struct array as an OpenEXR,
(width and height is the resolution of the image)
===========================================
int pixelCount=0;
for(i=0; i<height; i++){
for(j=0; j<width; j++){
exrPixels[j].r = imgbuffer[pixelCount];
exrPixels[j].g = imgbuffer[pixelCount+1];
exrPixels[j].b = imgbuffer[pixelCount+2];
exrPixels[j].a = 1.0;
pixelCount+=3;
}
}
=============================================
This gives me four tiled 'versions' of the image but only in the green channel. The red and blue channel has stuff that looks like noise(but of course its just mu fault).
I have tried looking for somewhere when someone explains this kind of stuff but haven't found anything online.
Does anyone know of any good websites?
Or could anyone give me a pointer to how to proceed,would be really great too?
cheers
fred
I am trying to convert some '16 bit planar RGB' data in memory into an array of 'rgba' structs, but can't figure out how to do it.
I am very inexperienced with this sort of thing.
I know that the buffer where the source image resides is made like this,
=============================
// three channels (RGB) in 16-bit (2 bytes) requires this much memory:
size_t memNeeded = width * height * 3U * 2U;
size_t adjusted = memNeeded;
// alloc this memory 16-byte aligned
unsigned char * imgbuffer = AlignedMalloc(adjusted);
=============================
I am told that when when it is written to disk with,
fwrite(imgbuffer, 1, memNeeded, fout);
it is "3 components, non-interleaved 16 bit with PC byte ordering"
I am not sure if this is a clue to how it is arranged in memory?
The closest I got was to have a loop like this and then write out the rgba struct array as an OpenEXR,
(width and height is the resolution of the image)
===========================================
int pixelCount=0;
for(i=0; i<height; i++){
for(j=0; j<width; j++){
exrPixels[j].r = imgbuffer[pixelCount];
exrPixels[j].g = imgbuffer[pixelCount+1];
exrPixels[j].b = imgbuffer[pixelCount+2];
exrPixels[j].a = 1.0;
pixelCount+=3;
}
}
=============================================
This gives me four tiled 'versions' of the image but only in the green channel. The red and blue channel has stuff that looks like noise(but of course its just mu fault).
I have tried looking for somewhere when someone explains this kind of stuff but haven't found anything online.
Does anyone know of any good websites?
Or could anyone give me a pointer to how to proceed,would be really great too?
cheers
fred