Changed: Code simplification

This commit is contained in:
kervala 2016-01-06 13:19:48 +01:00
parent 2523f78805
commit b16d060247

View file

@ -2599,7 +2599,7 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f)
case 10: case 10:
{ {
uint8 packet; uint8 packet;
uint8 pixel[4]; uint8 pixel[4] = {0};
uint32 imageSize = width*height; uint32 imageSize = width*height;
uint32 readSize = 0; uint32 readSize = 0;
uint8 upSideDown = ((desc & (1 << 5))==0); uint8 upSideDown = ((desc & (1 << 5))==0);
@ -2616,22 +2616,12 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f)
f.serial(pixel[i]); f.serial(pixel[i]);
} }
for (i=0; i < (packet & 0x7F) + 1; i++) for (i=0; i < (packet & 0x7F) + 1; i++)
{
if(imageDepth==32)
{ {
_Data[0][dstId++]= pixel[2]; _Data[0][dstId++]= pixel[2];
_Data[0][dstId++]= pixel[1]; _Data[0][dstId++]= pixel[1];
_Data[0][dstId++]= pixel[0]; _Data[0][dstId++]= pixel[0];
_Data[0][dstId++]= pixel[3]; _Data[0][dstId++]= pixel[3];
} }
if(imageDepth==24)
{
_Data[0][dstId++]= pixel[2];
_Data[0][dstId++]= pixel[1];
_Data[0][dstId++]= pixel[0];
_Data[0][dstId++]= 0;
}
}
} }
else // packet Raw else // packet Raw
{ {
@ -2641,21 +2631,11 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f)
{ {
f.serial(pixel[j]); f.serial(pixel[j]);
} }
if(imageDepth==32)
{
_Data[0][dstId++]= pixel[2]; _Data[0][dstId++]= pixel[2];
_Data[0][dstId++]= pixel[1]; _Data[0][dstId++]= pixel[1];
_Data[0][dstId++]= pixel[0]; _Data[0][dstId++]= pixel[0];
_Data[0][dstId++]= pixel[3]; _Data[0][dstId++]= pixel[3];
} }
if(imageDepth==24)
{
_Data[0][dstId++]= pixel[2];
_Data[0][dstId++]= pixel[1];
_Data[0][dstId++]= pixel[0];
_Data[0][dstId++]= 0;
}
}
} }
readSize += (packet & 0x7F) + 1; readSize += (packet & 0x7F) + 1;
} }