예제 #1
0
        private static Bitmap ToBitmap(byte[] xifile)
        {
            Level5_XI xi = new Level5_XI();

            xi.Open(xifile);
            return(xi.ToBitmap());
        }
예제 #2
0
        public static GenericTexture ToGenericTexture(byte[] xifile)
        {
            GenericTexture tex = new GenericTexture();
            Level5_XI      xi  = new Level5_XI();

            xi.Open(xifile);
            if (xi.SwitchFile && xi.ImageFormat == 0x1D)
            {
                tex.Mipmaps.Add(xi.BuildImageDataFromBlock(8)[0]);
                tex.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.CompressedRgbS3tcDxt1Ext;
                tex.Width          = (uint)xi.Height;
                tex.Height         = (uint)xi.Width;
            }
            else
            if (xi.SwitchFile && xi.ImageFormat == 0x1F)
            {
                tex.Mipmaps.Add(xi.BuildImageDataFromBlock(16)[0]);
                tex.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
                tex.Width          = (uint)xi.Height;
                tex.Height         = (uint)xi.Width;
            }
            else
            if (xi.SwitchFile && xi.ImageFormat == 0x1)
            {
                tex.Mipmaps.Add(xi.BuildImageData()[0]);
                tex.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgb8;
                tex.PixelFormat    = OpenTK.Graphics.OpenGL.PixelFormat.Rgb;
                tex.Width          = (uint)xi.Height;
                tex.Height         = (uint)xi.Width;
            }
            else
            {
                var texture = xi.ToBitmap();
                tex.FromBitmap(texture);
                texture.Dispose();
            }
            return(tex);
        }