// this math from http://www.opengl.org/registry/specs/EXT/texture_sRGB.txt
if (!image_linearfromsrgb[255])
for (i = 0;i < 256;i++)
- image_linearfromsrgb[i] = (unsigned char)(Image_LinearFloatFromsRGB(i) * 256.0f);
+ image_linearfromsrgb[i] = (unsigned char)floor(Image_LinearFloatFromsRGB(i) * 255.0f + 0.5f);
for (i = 0;i < numpixels;i++)
{
pout[i*4+0] = image_linearfromsrgb[pin[i*4+0]];
// this math from http://www.opengl.org/registry/specs/EXT/texture_sRGB.txt
if (!image_srgbfromlinear_lightmap[255])
for (i = 0;i < 256;i++)
- image_srgbfromlinear_lightmap[i] = (unsigned char)bound(0, Image_sRGBFloatFromLinear_Lightmap(i) * 256.0f, 255);
+ image_srgbfromlinear_lightmap[i] = (unsigned char)floor(bound(0.0f, Image_sRGBFloatFromLinear_Lightmap(i), 1.0f) * 255.0f + 0.5f);
for (i = 0;i < numpixels;i++)
{
pout[i*4+0] = image_srgbfromlinear_lightmap[pin[i*4+0]];
#define Image_LinearFloatFromsRGB(c) Image_LinearFloatFromsRGBFloat((c) * (1.0f / 255.0f))
#define Image_sRGBFloatFromLinear(c) Image_sRGBFloatFromLinearFloat((c) * (1.0f / 255.0f))
-#define Image_sRGBFloatFromLinear_Lightmap(c) (Image_sRGBFloatFromLinear(c*2.0f)*0.5f)
+#define Image_sRGBFloatFromLinear_Lightmap(c) Image_sRGBFloatFromLinearFloat((c) * (2.0f / 255.0f)) * 0.5f
void Image_MakeLinearColorsFromsRGB(unsigned char *pout, const unsigned char *pin, int numpixels);
void Image_MakesRGBColorsFromLinear_Lightmap(unsigned char *pout, const unsigned char *pin, int numpixels);
{
int i;
for(i = 0; i < 3*rampsize; ++i)
- ramps[i] = bound(0, (int)floor(Image_sRGBFloatFromLinear(ramps[i] / 256.0) * 65535.0 + 0.5), 65535);
+ ramps[i] = (int)floor(bound(0.0f, Image_sRGBFloatFromLinearFloat(ramps[i] / 65535.0), 1.0f) * 65535.0 + 0.5);
}
// LordHavoc: this code came from Ben Winslow and Zinx Verituse, I have