• Advertisement
Sign in to follow this  

How to do a color reduction calculation?

This topic is 891 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let's say I had a color whose value is 130 and is a unsigned char (BYTE) value

I want to convert it into a float value within the range of 0...1

How do I go about doing that?

I tried to cast directly, but it is no working

like

SrMaterial mat = subMesh->material;
D3DMATERIAL9 material;
material.Diffuse.r = mat.diffuse.r;

 

Here the SrMaterial consists of color values whose type is srbyte which is in turn defined as unsigned char.

But their values are incredibly large. I don't believe that they are supposed to be rendered in Direct3D environment..

 

Thanks in advance

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement

I want to convert it into a float value within the range of 0...1
How do I go about doing that?

 

as i recall, dx9 uses rgb bytes, not floats internally. one of the first things i figured out when deciding whether to use bytes or floats for colors. so needless to say, bytes won.

 

there are APIs and macros for both.

 

FYI, that's a format conversion, not color reduction. 

Edited by Norman Barrows

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement