Diablo III Tex File Format
Posted: Sat Jan 18, 2014 11:52 pm
Hi guys, been figuring out how to convert the C++ data into c#
this is for coverting the .tex files (Diablo III Tex(tures)) to dds format.
up till the code below everything was just going well ( being not a C++ guy and all)
but now I ran into a huge problem, I don't understand what is happening in the part that starts with
In c# I have a BinaryReader object, that is used to read the bytes (and stuff) but I just can't seem to get that part of code... need help plz .
(code is originally taken from the C++ D3TEX2DDS converter)
Thnx
T.
this is for coverting the .tex files (Diablo III Tex(tures)) to dds format.
up till the code below everything was just going well ( being not a C++ guy and all)
but now I ran into a huge problem, I don't understand what is happening in the part that starts with
Code: Select all
if(nPixelSize == 8) (code is originally taken from the C++ D3TEX2DDS converter)
Code: Select all
int DecodeTexPixelData(
int nDecodeMethod, int nDecodeMethodEx,
uint8_t* pDst, uint8_t* pSrc, size_t nDstSize,
size_t nWidth, size_t nHeight, size_t nMipLevel, size_t nCalcPitch, size_t nTexPitch)
{
//DecodeTexPixelData( nFormat, nFormat, pBuffer, pStart, nSize, nWidth ,nHeight, 0, nPitch, nPitch);
//First Pass Decode
uint8_t* pBuffer = NULL;
if(nDecodeMethod <= 12 && nDecodeMethod >= 9)
{
size_t nPixels = ((nWidth >> nMipLevel) * (nHeight >> nMipLevel)) / 16;
int nPixelSize = GetDecodeSize(nDecodeMethod);
if(nPixelSize == -1)
return 0;
size_t nSize = nPixels * nPixelSize;
pBuffer = (uint8_t*)malloc(nSize);
if(nPixelSize == 8)
{
uint32_t* pDest = (uint32_t*)pBuffer;
uint32_t* r = (uint32_t*)pSrc;
uint32_t* g = (uint32_t*)(pSrc + (nPixels * 4));
for(size_t i = nPixels; i != 0; i--)
{
pDest[0] = *r++;
pDest[1] = *g++;
pDest += 2;
}
}
T.