Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Memblocks and 16 bit graphics

Author
Message
wargamer
23
Years of Service
User Offline
Joined: 7th Jan 2003
Location: United Kingdom
Posted: 6th Jun 2004 22:45
When programming with DBPro on my laptop I have it on 16 bit mode (looks horrible but less slow!). I need to do some fast image manipulation so I'm using memblocks. When I do this and

MAKE MEMBLOCK FROM BITMAP, it stores the memblock as 16 bits per pixel, not the usual 32. Doing the reverse (ie MAKE BITMAP FROM MEMBLOCK) is fine, but I want to draw to the bitmap while stored in the bitmap.

My question is: does anyone know how the RGB values are encoded in those 16 bits? Presumably it's 4 bits for each colour and four left over, but which four do what??

I have worked out that the first 12 bits do what they do in 32 bit bitmaps - store the x and y size and the no. of bit per pixel.

AMD Athlon 1600+, 512MB, GeForce 3
wargamer
23
Years of Service
User Offline
Joined: 7th Jan 2003
Location: United Kingdom
Posted: 6th Jun 2004 22:47
Sorry, I meant "draw to the bitmap while stored in the memblock... "

AMD Athlon 1600+, 512MB, GeForce 3
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Jun 2004 22:51
The bits are arranged like this:

ARRRRRGGGGGBBBBB

Where A=Alpha, R=Red, G=Green and B=Blue

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Jun 2004 23:56
So each color is 5 bits? That sounds odd, since you can only extract byte(4 bits?) leaving a misc. bit left.

"eureka" - Archimedes
wargamer
23
Years of Service
User Offline
Joined: 7th Jan 2003
Location: United Kingdom
Posted: 11th Jun 2004 00:42
SOLUTION!!

Thanks Ian M,

But your solution didn't quite work. After much trial and error, it seems to be:

RRRRRGGG GGGBBBBB

In other words, lucky ol' green gets six bits while R&B get only 5.

I'll post my code on the code snippets board.

AMD Athlon 1600+, 512MB, GeForce 3
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Jun 2004 21:22 Edited at: 11th Jun 2004 21:23
[EDIT]Silly comment deleted[/EDIT]

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Mentor
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 11th Jun 2004 22:46 Edited at: 11th Jun 2004 22:50
there are two "official" ways of storing RGB in 16 bits, normaly (at least AFAIK) it will be arrrrrgggggbbbbb where the a indicates a single alpha channel bit, the other way is indeed rrrrrggggggbbbbb, the extra bit for green is supposed to be because the human eye is more sensitive to green than any other colour, but when I did some research into 16 bit format I got arrrrrrgggggbbbbb on my machine, so a question for RGT, does Pro store 16 bit RGB according to what format the card on the pc uses? or does it convert it internaly to one or other of the formats? and if it stores the data according to what the card manufacturer decided was the "right" way to store 16 bit colour, then how can we tell in code if those 16 bits are rgb or argb?, that could make quite a difference in practice, or are we best avoiding low level operations in 16 bit or even avoiding 16 bit altogether?.

Mentor.

edit: moved alphas to correct end of bytes

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Jun 2004 16:45
If wargamer is getting a 16 bit colour and I'm getting a 15 bit colour with alpha and there is no quick and easy way of telling what type you have then I say avoid the whole mess altogether and work in 32 bit.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2026-06-09 13:56:13
Your offset time is: 2026-06-09 13:56:13