|
|
|
@ -3269,77 +3269,79 @@ CRGBAF CBitmap::getColor (float x, float y) const
|
|
|
|
|
|
|
|
|
|
uint32 i;
|
|
|
|
|
|
|
|
|
|
bool isValid = true;
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
{
|
|
|
|
|
nlassert (nX[i] >= 0);
|
|
|
|
|
nlassert (nY[i] >= 0 );
|
|
|
|
|
nlassert (nX[i] < nWidth);
|
|
|
|
|
nlassert (nY[i] < nHeight);
|
|
|
|
|
if (nX[i] < 0 || nY[i] < 0 || nX[i] >= nWidth || nY[i] >= nHeight)
|
|
|
|
|
isValid = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Decimal part of (x,y)
|
|
|
|
|
x = x - (float)nX[0];
|
|
|
|
|
y = y - (float)nY[0];
|
|
|
|
|
|
|
|
|
|
switch (this->PixelFormat)
|
|
|
|
|
if (isValid)
|
|
|
|
|
{
|
|
|
|
|
case RGBA:
|
|
|
|
|
case DXTC1:
|
|
|
|
|
case DXTC1Alpha:
|
|
|
|
|
case DXTC3:
|
|
|
|
|
case DXTC5:
|
|
|
|
|
{
|
|
|
|
|
CRGBAF finalVal;
|
|
|
|
|
CRGBA val[4];
|
|
|
|
|
// Decimal part of (x,y)
|
|
|
|
|
x = x - (float)nX[0];
|
|
|
|
|
y = y - (float)nY[0];
|
|
|
|
|
|
|
|
|
|
if (this->PixelFormat == RGBA)
|
|
|
|
|
switch (this->PixelFormat)
|
|
|
|
|
{
|
|
|
|
|
case RGBA:
|
|
|
|
|
case DXTC1:
|
|
|
|
|
case DXTC1Alpha:
|
|
|
|
|
case DXTC3:
|
|
|
|
|
case DXTC5:
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
CRGBAF finalVal;
|
|
|
|
|
CRGBA val[4];
|
|
|
|
|
|
|
|
|
|
if (this->PixelFormat == RGBA)
|
|
|
|
|
{
|
|
|
|
|
val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0],
|
|
|
|
|
rBitmap[(nX[i]+nY[i]*nWidth)*4+1],
|
|
|
|
|
rBitmap[(nX[i]+nY[i]*nWidth)*4+2],
|
|
|
|
|
rBitmap[(nX[i]+nY[i]*nWidth)*4+3]);
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
{
|
|
|
|
|
val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0],
|
|
|
|
|
rBitmap[(nX[i]+nY[i]*nWidth)*4+1],
|
|
|
|
|
rBitmap[(nX[i]+nY[i]*nWidth)*4+2],
|
|
|
|
|
rBitmap[(nX[i]+nY[i]*nWidth)*4+3]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// slower version : get from DXT
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
val[i] = getPixelColor(nX[i], nY[i]);
|
|
|
|
|
// slower version : get from DXT
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
{
|
|
|
|
|
val[i] = getPixelColor(nX[i], nY[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R);
|
|
|
|
|
finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G);
|
|
|
|
|
finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B);
|
|
|
|
|
finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A);
|
|
|
|
|
finalVal /= 255.f;
|
|
|
|
|
finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R);
|
|
|
|
|
finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G);
|
|
|
|
|
finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B);
|
|
|
|
|
finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A);
|
|
|
|
|
finalVal /= 255.f;
|
|
|
|
|
|
|
|
|
|
return finalVal;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Alpha:
|
|
|
|
|
case Luminance:
|
|
|
|
|
{
|
|
|
|
|
return finalVal;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Alpha:
|
|
|
|
|
case Luminance:
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
float finalVal;
|
|
|
|
|
float val[4];
|
|
|
|
|
float finalVal;
|
|
|
|
|
float val[4];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
val[i] = rBitmap[(nX[i]+nY[i]*nWidth)];
|
|
|
|
|
for (i = 0; i < 4; ++i)
|
|
|
|
|
val[i] = rBitmap[(nX[i]+nY[i]*nWidth)];
|
|
|
|
|
|
|
|
|
|
finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]);
|
|
|
|
|
finalVal /= 255.f;
|
|
|
|
|
finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]);
|
|
|
|
|
finalVal /= 255.f;
|
|
|
|
|
|
|
|
|
|
if (this->PixelFormat == Alpha)
|
|
|
|
|
return CRGBAF (1.f, 1.f, 1.f, finalVal);
|
|
|
|
|
else // Luminance
|
|
|
|
|
return CRGBAF (finalVal, finalVal, finalVal, 1.f);
|
|
|
|
|
if (this->PixelFormat == Alpha)
|
|
|
|
|
return CRGBAF (1.f, 1.f, 1.f, finalVal);
|
|
|
|
|
else // Luminance
|
|
|
|
|
return CRGBAF (finalVal, finalVal, finalVal, 1.f);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CRGBAF (0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
|