16 Bit Mode - RGB?
Blitz3D Forums/Blitz3D Beginners Area/16 Bit Mode - RGB?
| ||
In 32 bit graphic modes, RGB is:rgb = ((r shl 16) + (g shl 8) + b) And $FFFFFF alpha = (a shl 24) and $FF000000 but how does this work with only 16 bits???? Thanks, MK |
| ||
r g b use different bits%1111 1111 1111 1111 (a 16 bit number) rrrr r--- ---- ---- red part ---- -ggg ggg- ---- green part ---- ---- ---b bbbb blue part Due to there being less bits per a color gun (red, green and blue) there are less colors that can be made in 16bit. |
| ||
What about 24 bit? |
| ||
In 24 bit, there are 8 bits each for red, green, and blue. In 32 bit, there are 8 bits each for red, green, and blue, plus one at the start for 'alpha'. Never really understood quite what that first byte means / is for, but effectively a 'brightness' thing maybe? In 16 bit, there are TWO options, dependent on graphics mode, graphics card, probably O/S and many other things. Either you have 5 bits each for red, green, and blue, with the bit at the start left unused. OR you have 5 for red, 6 for green, and 5 for blue. And if you're using BlitzPlus, you can determine all this using the LockedFormat command once you've locked the buffer, allowing you to perform snazzy fast effects by peeking and poking data. Instead of the annoyingly slow read/writepixel'fast'. |
| ||
Here is a link explaining RGB Formats I have gathered the most relevant info into this table. Hope it's right! RGB Formats *********** 16 Bit RGB555 ==================== %1111 1111 1111 1111 rrr rrgg gggb bbbb 16 Bit RGB565 ==================== %1111 1111 1111 1111 rrrr rggg gggb bbbb 24 Bit RGB888 ============================== %1111 1111 1111 1111 1111 1111 rrrr rrrr gggg gggg bbbb bbbb 32Bit ARGB8888 ======================================== %1111 1111 1111 1111 1111 1111 1111 1111 aaaa aaaa rrrr rrrr gggg gggg bbbb bbbb There is an example in Blitz+ by Mark called lock_graphics.bb (in the samples\mak folder). Worth a look. |
| ||
Thanks for all the replies! That clears some things up. :) MK |