32,24,16 and 8 bit.....that should explain it all........at least,.....most of it.
------------------
Dance with me......
http://members.xoom.com/CJdeVos/index.htm
32,24,16 and 8 bit.....that should explain it all........at least,.....most of it.
------------------
Dance with me......
http://members.xoom.com/CJdeVos/index.htm
unsigned short rgb_index[256][3];
Then fill the structure with colour information. The first array index points to the colour amount, the second to the colour itself (R G or B, I use R = 0 G = 1 B = 2, but you could change that if you wanted to). Now, when you want to get a finished colour, you simply say:
color = rgb_index[r_color][0] | rgb_index[g_color][1] | rgb_index[b_color][2];
As I said, there will be situations where you won't want to use this because of the way it works. However, it is one way of doing things that you might want to take a look at.
Good luck
Starfall
Thanks again,
James
Look at
code:DWORD* Create16bppLUT(DWORD bitMask){DWORD * p_lut = new DWORD[256];if (p_lut == NULL) return NULL;for (__int64 i = 0; i < 256; i++){p_lut = DWORD((( i * __int64(bitMask)) / 255) & bitMask);<P>}<BR>return p_lut;<P>}</pre><HR></BLOCKQUOTE><P>And call this function like:<P>DWORD *Red;<BR>Red = Create16bppLUT(ddsd.ddpfPixelFormat.dwRBitMask); <P>after that you can use what you said<P><P>——————<BR>Dance with me……<P>http://members.xoom.com/CJdeVos/index.htm
Thanks for the extra code... a couple of things I don't get however Could you explain why you use '__int64' variable type (not sure what this is exactly). Also, why do you malloc the memory at runtime, is this faster than using a play array of say:
WORD r_LUT[256];
?
Anyway, thanks for your help,
James
And about the memory allocation on run-time. I always do that. It's kinda my behavior. And I find it easier to use a pointer to something instead......
More questions?
------------------
Dance with me......
http://members.xoom.com/CJdeVos/index.htm
Come again? How's an array like he suggested any different? It's still a pointer, just preallocated for you. In fact, for all intents and purposes exactly the same as using malloc, but with less hassle. I find it far easier to allocate fixed size memory like that, anyway.
Regards
Starfall
int MyArray[256];
and this:
int *MyArray = (int *)malloc(256 * sizeof(int));
ORint *MyArray = new int[256];
The last two do exactly the same thing. They are just different versions of each other. However, a pre-allocated array only uses the stack to store the array. Once it's out of scope, the array no longer exists. Using malloc() or new dynamically allocates it, and the memory is available until you call free() or delete[]. Therefore, they are not the same thing.
I will always use new and delete functions. Everybody his liking. And......you are right about the __int64 thingy.....just an int works just fine too...........
------------------
Dance with me......
http://members.xoom.com/CJdeVos/index.htm