Пример #1
0
        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
        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
        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
        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
 public override bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file)
 {
     processed_file = null;
     return false;
 }
Пример #6
0
 public abstract bool TryProcess(string filename, byte[] data, bool allow_compression_of_files, out ProcessedFile processed_file);