예제 #1
0
        public virtual Bitmap DecodeTexture(VoidPtr addr, int w, int h, int mipLevel)
        {
            int aw = w.Align(BlockWidth), ah = h.Align(BlockHeight);

            using (DIB dib = new DIB(w, h, BlockWidth, BlockHeight, PixelFormat.Format32bppArgb))
            {
                int sStep   = BlockWidth * BlockHeight * BitsPerPixel / 8;
                int bStride = aw * BitsPerPixel / 8;
                for (int y = 0; y < ah; y += BlockHeight)
                {
                    ARGBPixel *dPtr = (ARGBPixel *)dib.Scan0 + (y * aw);
                    VoidPtr    sPtr = addr + (y * bStride);
                    for (int x = 0; x < aw; x += BlockWidth, dPtr += BlockWidth, sPtr += sStep)
                    {
                        DecodeBlock(sPtr, dPtr, aw);
                    }
                }
                return(dib.ToBitmap());
            }
        }
예제 #2
0
        public virtual Bitmap DecodeTexture(TEX0v1 *texture, int mipLevel)
        {
            int     w = (int)(ushort)texture->_width, h = (int)(ushort)texture->_height;
            VoidPtr addr = texture->PixelData + GetMipOffset(ref w, ref h, mipLevel);
            int     aw = w.Align(BlockWidth), ah = h.Align(BlockHeight);

            using (DIB dib = new DIB(w, h, BlockWidth, BlockHeight, PixelFormat.Format32bppArgb))
            {
                int sStep   = BlockWidth * BlockHeight * BitsPerPixel / 8;
                int bStride = aw * BitsPerPixel / 8;
                for (int y = 0; y < ah; y += BlockHeight)
                {
                    ARGBPixel *dPtr = (ARGBPixel *)dib.Scan0 + (y * aw);
                    VoidPtr    sPtr = addr + (y * bStride);
                    for (int x = 0; x < aw; x += BlockWidth, dPtr += BlockWidth, sPtr += sStep)
                    {
                        DecodeBlock(sPtr, dPtr, aw);
                    }
                }
                return(dib.ToBitmap());
            }
        }