private bool LoadTextureFormatDataFromBuffer()
        {
                        #if NATIVE_PLUGIN_LOAD
            textureData.width          = FastLoad_Texture_GetWidth();
            textureData.heght          = FastLoad_Texture_GetHeight();
            textureData.format         = FastLoad_Texture_GetFormat();
            textureData.flags          = FastLoad_Texture_GetFlags();
            textureData.compressedSize = 0;
            textureData.dataSize       = FastLoad_Texture_GetBodySize();
            textureData.rawData        = FastLoad_Texture_GetRawData();
                        #else
            if (!FastLoaderUtil.CheckHeader(this.bufferData, 0, FastLoaderUtil.FastTextureHeader))
            {
                return(false);
            }
            textureData.width          = FastLoaderUtil.GetIntFromByteArray(this.bufferData, 8);
            textureData.heght          = FastLoaderUtil.GetIntFromByteArray(this.bufferData, 12);
            textureData.format         = FastLoaderUtil.GetIntFromByteArray(this.bufferData, 16);
            textureData.flags          = FastLoaderUtil.GetIntFromByteArray(this.bufferData, 20);
            textureData.compressedSize = FastLoaderUtil.GetIntFromByteArray(this.bufferData, 24);
            textureData.dataSize       = FastLoaderUtil.GetIntFromByteArray(this.bufferData, 28);

            if (textureData.compress)
            {
                Lz4Util.Decode(this.bufferData, 32, textureData.compressedSize, this.uncompressedBuffer, 0, textureData.dataSize);
                textureData.rawData = Marshal.UnsafeAddrOfPinnedArrayElement(this.uncompressedBuffer, 0);
            }
            else
            {
                textureData.rawData = Marshal.UnsafeAddrOfPinnedArrayElement(this.bufferData, 32);
            }
                        #endif
            return(true);
        }
Esempio n. 2
0
        public static int Decode(byte [] src, int srcOffset, int srcLength, byte [] dest, int destOffset, int destLength)
        {
            int blockNum          = FastLoaderUtil.GetIntFromByteArray(src, srcOffset + 0);
            int headerSize        = 8 + blockNum * 8;
            int currentDestOffset = destOffset;
            int currentSrcOffset  = srcOffset + headerSize;

            int destLengthSum = 0;

            for (int i = 0; i < blockNum; ++i)
            {
                int originSize     = FastLoaderUtil.GetIntFromByteArray(src, srcOffset + 8 + (i * 8) + 0);
                int compressedSize = FastLoaderUtil.GetIntFromByteArray(src, srcOffset + 8 + (i * 8) + 4);


                LZ4Codec.Decode(src, currentSrcOffset, compressedSize, dest, currentDestOffset, originSize);

                currentSrcOffset  += compressedSize;
                currentDestOffset += originSize;
                destLengthSum     += originSize;
            }

            return(destLengthSum);
        }