Пример #1
0
        public static RealArgbColor DecodeBitmapPixelXbox(byte[] bitmapData, Bitmap.Image image, D3DTexture9 pTexture, int layerIndex, int mipmapIndex)
        {
            RealArgbColor result = new RealArgbColor(1, 0, 0, 0);

            if (image.Type != BitmapType.Texture3D && (
                    (image.Type == BitmapType.Texture2D && layerIndex == 1) ||
                    (image.Type == BitmapType.CubeMap && layerIndex >= 0 && layerIndex < 6) ||
                    (image.Type == BitmapType.Array && layerIndex >= 0 && layerIndex < image.Depth)) &&
                (pTexture.GetBaseOffset() > 0 || pTexture.GetMipOffset() > 0))
            {
                uint blockWidth  = 0;
                uint blockHeight = 0;
                int  dataOffset  = 0;
                int  layerOffset = 0;

                // verify the mipmap level index
                var minMipLevel = pTexture.GetMinMipLevel();
                var maxMipLevel = pTexture.GetMaxMipLevel();

                // if mipmapIndex is too low
                if (mipmapIndex < minMipLevel)
                {
                    mipmapIndex = minMipLevel;
                }
                // if mipmapIndex is too high
                if (mipmapIndex > maxMipLevel)
                {
                    mipmapIndex = maxMipLevel;
                }

                var currentHeight = image.Height >> mipmapIndex;
                var currentWidth  = image.Width >> mipmapIndex;

                if (currentWidth < 1)
                {
                    currentWidth = 1;
                }

                if (currentHeight < 1)
                {
                    currentHeight = 1;
                }


                //XGGetTextureDesc
                XboxGraphics.XGTEXTURE_DESC textureDesc = new XboxGraphics.XGTEXTURE_DESC();


                XboxGraphics.XGGetBlockDimensions(XboxGraphics.XGGetGpuFormat(textureDesc.D3DFormat), out blockWidth, out blockHeight);

                layerOffset = 0; // Unknown XG function


                if (mipmapIndex > 0 && pTexture.GetMipOffset() > 0)
                {
                    dataOffset = pTexture.GetMipOffset() + layerOffset;
                }
                else
                {
                    dataOffset = pTexture.GetBaseOffset() + layerOffset;
                }

                for (int h = 0; h < currentHeight; h++)
                {
                    for (int w = 0; w < currentWidth; w++)
                    {
                    }
                }
            }


            return(result);
        }