コード例 #1
0
ファイル: XNBtoBIN.cs プロジェクト: FreeReign/UltimaXNA
        public override bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file)
        {
            processed_file = null;

            if (!InternalCheckExtension(filename, ".xnb"))
                return false;

            object obj = InterXLib.Display.XNBReader.ReadObject(AllProcessors.GraphicsDevice, filename);
            if (obj is Microsoft.Xna.Framework.Graphics.Texture2D)
            {
                Texture2D texture = (obj as Texture2D);

                List<byte> all_data = new List<byte>();

                uint[] pixels = new uint[texture.Width * texture.Height];
                texture.GetData<uint>(pixels);
                int i = 0;

                for (int y = 0; y < texture.Height; y++)
                {
                    for (int x = 0; x < texture.Width; x++)
                    {
                        AddValueToByteList(all_data, pixels[i++]);
                    }
                }
                processed_file = new ProcessedFile(filename, all_data.ToArray(), allow_compression_of_files);
            }

            return true;
        }
コード例 #2
0
ファイル: PNGtoBIN.cs プロジェクト: FreeReign/UltimaXNA
        public override bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file)
        {
            processed_file = null;

            if (!InternalCheckExtension(filename, ".png"))
                return false;

            Texture2D texture;
            using (FileStream stream = new FileStream(filename, FileMode.Open))
            {
                texture = Texture2D.FromStream(AllProcessors.GraphicsDevice, stream);
            }

            if (texture != null)
            {
                List<byte> all_data = new List<byte>();

                uint[] pixels = new uint[texture.Width * texture.Height];
                texture.GetData<uint>(pixels);
                int i = 0;

                for (int y = 0; y < texture.Height; y++)
                {
                    for (int x = 0; x < texture.Width; x++)
                    {
                        AddValueToByteList(all_data, pixels[i++]);
                    }
                }
                processed_file = new ProcessedFile(filename, all_data.ToArray(), allow_compression_of_files);
            }

            return true;
        }
コード例 #3
0
ファイル: AllProcessors.cs プロジェクト: FreeReign/UltimaXNA
        public override bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file)
        {
            foreach (AProcessor processor in m_Processors)
                if (processor.TryProcess(filename, data, allow_compression_of_files, out processed_file))
                    return true;

            processed_file = null;
            return false;
        }
コード例 #4
0
ファイル: HtoBIN.cs プロジェクト: FreeReign/UltimaXNA
        public override bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file)
        {
            processed_file = null;

            // extension must be .h (header file).
            if (!InternalCheckExtension(filename, ".h"))
                return false;

            // must be a single array of numbers, separated by commas. We allow for hex (0x####) and base ten (#####) numbers.
            StringBuilder sb_data = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {
                char c = (char)data[i];
                if (c == '/' && (char)data[i + 1] == '/')
                {
                    // ignore the rest of the line.
                    bool newline = false;
                    while (!newline)
                    {
                        c = (char)data[i++];
                        if (c == '\n' || c == '\r')
                        {
                            newline = true;
                            i--;
                        }
                    }
                }
                else if (Char.IsNumber(c) || c == 'x')
                    sb_data.Append(c);
                else if (c == ',')
                    sb_data.Append(c);
            }
            if (sb_data.Length == 0)
                return false;
            if (sb_data[sb_data.Length - 1] == ',')
                sb_data.Remove(sb_data.Length - 1, 1);
            string[] all_numbers = sb_data.ToString().Split(',');
            List<byte> all_data = new List<byte>();
            for (int i = 0; i < all_numbers.Length; i++)
            {
                if (!InternalCanProcessThisNumber(all_numbers[i], all_data))
                    return false;
            }
            processed_file = new ProcessedFile(filename, all_data.ToArray(), true);
            return true;
        }
コード例 #5
0
ファイル: ExcludeFiles.cs プロジェクト: FreeReign/UltimaXNA
 public override bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file)
 {
     processed_file = null;
     return false;
 }
コード例 #6
0
ファイル: AProcessor.cs プロジェクト: FreeReign/UltimaXNA
 public abstract bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file);