Advertisement

Has to be very newbie..

Started by February 21, 2000 11:41 AM
5 comments, last by Zombie 24 years, 7 months ago
What is this "number" (0xf81F) called and how can I change hex to this? It''s a color value used in 16-bit mode, but that''s all I know about it.
That is hex. 63519 is what I get from the standard windows calculator.
William Reiach - Human Extrodinaire

Marlene and Me


Advertisement
Ok, let''s see if I still remember this...
0xf81f is hex, 16 bits as said in the prev. post
quick convertion to binary:
F=1111
8=1000
1=0001
F=1111
so 0xF81F= 1111 1000 0001 1111 in a 565 format is full red plus full blue wich should be some violet.
Since you seem kind of confused, I thought I would give a brief blurb about what hex is.

Hex is a numbering system with the base being 16. The numbering system you are used to working with is base 10. Our numbers correspond to a base 10 numbering system, in that we have a unique symbol for 10 separate numbers:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
This doesn''t mean the base 10 system is more valid than any other base, just that it''s the way we''ve been taught to percieve numbers.

The fact that there are only 10 symbols available to us presents a problem when we have more than 10 in our base. So, to get around this, letters are used for the "extra" symbols, like so:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

The reason we use hex is the fact that it''s a really short way to represent a byte, so you don''t have to have lines and lines of 0''s and 1''s to get your point across... and because 16 is a power of 2, it makes the math easier. You can represent a byte by using 2 hex digits... one hex digit is a nibble (half a byte, or 4 bits).

HTH
-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
My real problem is that I have to set color keys in 16-bit mode, but the program doesn''t use them (i use &H and hex value copied from Paint shop pro). It works fine in 24 and 32 bit modes, but not in 16-bit (in which it the program would be faster). So how do I use these color keys in 16-bit mode?
Well your &H color formats looks like &HRRGGBB. Assuming a 565 representation for your 16 bit colors, you want the 5 most significant red bits, 6 most significant green bits and 5 most significant blue bits and combine them together.

Bitwise the reduction looks like this:
R8 R7 R6 R5 R4 R3 R2 R1 G8 G7 G6 G5 G4 G3 G2 G1 B8 B7 B6 B5 B4 B3 B2 B1
-->
R8 R7 R6 R5 R4 G8 G7 G6 G5 G4 G3 B8 B7 B6 B5 B4

In c it would look something like
char red = color24 & 0xff0000;
char green = color24 & 0x00ff00;
char blue = color24 & 0x0000ff;

red >>= 3; // red = red / 8
green >>= 2; // green = green / 4
blue >>= 3; // blue = blue / 8

color16 = (red << 11) + (green << 5) + blue;
Advertisement
if you do use DDraw for drawing in 16bpp modes, make sure you get pixel info after mode is set, because with some cards you will get 16bpp mode, and with others you will get 15bpp ... so then the code should look like red>>3, green>>3 (!), blue>>3 ... you have to support both 565 and 555 modes.


---------------------------------------------------
Ped - Peter Helcmanovsky - 7 Gods demo group
http://7gods.rulez.sk
First Sight Entertainment - http://members.xoom.com/fseteam
---------------------------------------------------
---------------------------------------------------Ped - Peter Helcmanovsky - 7 Gods demo grouphttp://7gods.rulez.skFirst Sight Entertainment - http://members.xoom.com/fseteam---------------------------------------------------

This topic is closed to new replies.

Advertisement