Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: HELP: Superfast Color Conversion?



The conversion is per-vertex, not per-pixel. The source calls are in
3rd-party applications and the destination is D3D, which has no provision
for float colors. So we have no control over either end, just the middle.

Thanks,
Rob

"Eyal Teler" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Rob Targosz wrote:
> > I'm trying to implement an algorithm to convert floating point colors in
the
> > range 0.0 to 1.0 to integer colors in the range 0x0-0xff. The first
attempt
> > was something like this (please ignore any typos, I'm paraphrasing...):
> >
> > unsigned int R = G = B = A = 0;
> > void SetColor(float r, float g, float b, float a)
> > {
> >     R = (float)(r * 255.f);
> >     if(R > 255) R = 255;
> >     G = (float)(g * 255.f);
> >     if(G > 255) G = 255;
> >     B = (float)(b * 255.f);
> >     if(B > 255) B = 255;
> >     A = (float)(a * 255.f);
> >     if(A > 255) A = 255;
> > }
>
> If the numbers are in the range 0 to 1, why do you need to check each
> component for the result being over 255?
>
> I'd still suggest trying to get what's outside your control into your
> control. Sounds like you're doing a float to int RGBA for a full
> buffer each frame, which would be a bit of work any way you look at it.
>
> Eyal
>





<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.