Dear PowerVR,
your texture tool is amazing, but i have found a bug. When u export a KTX file, in certain cases, it has wrong imageSize. The export image bytes are correct, but the imageSize parameter is not. This is a serious problem, couz my ktx loader implementation relie on this parameter (also severel others like PicoPixel). But good news, it is easy to fix.
KTX File Format Specification says:
imageSize is the number of bytes of pixel data in the current LOD level. This includes all z slices, all faces, all rows (or rows of blocks) and all pixels (or blocks) in each row for the mipmap levelalso says:
Uncompressed texture data matches a GL_UNPACK_ALIGNMENT of 4.
So let count together: I have an 2x2 GL_RGB GL_UNSIGNED_BYTE image (mipmap level). Your implementation returns 12 for imageSize. This is wrong! U have to include the padding on scanline. Becouse the first row of byte are (RGBRGB) 6bytes long, but u shold round that up to 8 bytes (UNPACK_ALIGNMENT). Correct way to calculate imageSize is (SOLUTION):
uint bpp=8; //the size of the pixel in bits;
uint width=2; //the width of the image (or mipmap level)
uint height=2; //the height of the image (or mipmap level)
uint scanlineSize=bppwidth/8; //its 6
scanlineSize+=3-(scanlineSize+3)%4; //round up to 4 byte boundary! so its 8
uint imageSize=scanlineSizeheight;
Plz fix your code, i woud like to avoid crashes and recalculation of this parameter. (Even picopixel crashes)
Thank You:
collerblade