reading a lfoating point bmap

Posted By: Matt_Aufderheide

reading a lfoating point bmap - 12/02/14 18:55

Can someone explain how to read float values from a floating point bmap using the finalbits pointer...?
Posted By: MasterQ32

Re: reading a lfoating point bmap - 12/02/14 21:35

Code:
// RGBA, BGRA, ...
#define CHANNEL_COUNT 4
int x, y;

// Get the scanline (starts at finalbits and goes finalpitch bytes every line)
float *scanline = (float*)(((char*)bmp->finalbits) + y * bmp->finalpitch);
float channels[CHANNEL_COUNT];
for(i = 0; i < CHANNEL_COUNT; i++) {
    // Index each channel at x
    channels[i] = scanline[CHANNEL_COUNT * x + i]; // Offset in the scanline
}

Posted By: Matt_Aufderheide

Re: reading a lfoating point bmap - 12/02/14 22:27

ok it works--thank you!
Posted By: MasterQ32

Re: reading a lfoating point bmap - 12/02/14 23:45

you're welcome!
© 2024 lite-C Forums