Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("Format: {path} {width} {height} {blockXSize} {blockYSize}");
            }
            else
            {
                string path       = args[0];
                int    width      = int.Parse(args[1]);
                int    height     = int.Parse(args[2]);
                int    blockXSize = int.Parse(args[3]);
                int    blockYSize = int.Parse(args[4]);
                byte[] data       = File.ReadAllBytes(path);

                using (DirectBitmap bitmap = new DirectBitmap(width, height))
                {
                    AstcDecoder decoder = new AstcDecoder();
                    decoder.DecodeASTC(data, width, height, blockXSize, blockYSize, bitmap.Bits);

                    string dirPath = Path.GetDirectoryName(path);
                    string name    = Path.GetFileNameWithoutExtension(path);
                    string newPath = Path.Combine(dirPath, name + "_decoded.png");
                    bitmap.Bitmap.Save(newPath, ImageFormat.Png);
                }

                Console.WriteLine("Finished");
            }

            Console.ReadKey();
        }
Exemplo n.º 2
0
        public static DirectBitmap ASTCTextureToBitmap(Texture2D texture, byte[] data)
        {
            int          width     = texture.Width;
            int          height    = texture.Height;
            int          blockSize = texture.ASTCBlockSize();
            DirectBitmap bitmap    = new DirectBitmap(width, height);

            try
            {
                AstcDecoder.DecodeASTC(data, width, height, blockSize, blockSize, bitmap.Bits);
                return(bitmap);
            }
            catch
            {
                bitmap.Dispose();
                throw;
            }
        }