Example #1
0
        /// <summary>
        /// Create a new texture.
        /// </summary>
        /// <param name="texturePath">Path to the texture.</param>
        public Texture(string texturePath)
        {
            //Set the texture path, and get the MD5SUM.
            Md5Sum      = CalculateMD5(texturePath);
            TexturePath = texturePath;

            //Add the texture to the heap.
            TextureHeap.Add(this, Color.White);
        }
Example #2
0
        /// <summary>
        /// Create a new texture from a color.
        /// </summary>
        /// <param name="color">Color to make the texture.</param>
        public Texture(Color color)
        {
            //Set the MD5 sum.
            MemoryStream colorTemp = new MemoryStream(new byte[] { color.A, color.R, color.G, color.B });

            Md5Sum = CalculateMD5(colorTemp);
            colorTemp.Dispose();

            //Add the texture to the heap.
            TextureHeap.Add(this, color);
        }
Example #3
0
        /// <summary>
        /// Change the current texture to another one.
        /// </summary>
        /// <param name="texturePath">Path of the texture.</param>
        public void ChangeTexture(string texturePath)
        {
            //Remove texture data if needed.
            TextureHeap.Remove(this);

            //Set the texture path, and get the MD5SUM.
            Md5Sum      = CalculateMD5(texturePath);
            TexturePath = texturePath;

            //Add this texture to the heap.
            TextureHeap.Add(this, Color.White);
        }
Example #4
0
        /// <summary>
        /// Dispose.
        /// </summary>
        public void Dispose()
        {
            //Remove resources.
            if (!Disposed)
            {
                //Remove the texture from the heap.
                TextureHeap.Remove(this);

                //Disposed.
                Disposed = true;
            }
        }
Example #5
0
        /// <summary>
        /// Create a new texture from a texture 2d.
        /// </summary>
        /// <param name="tex">Texture 2D.</param>
        public Texture(Texture2D tex)
        {
            //Set the texture path, and get the MD5SUM.
            MemoryStream stream = new MemoryStream();

            tex.SaveAsPng(stream, tex.Width, tex.Height);
            stream.Position = 0;
            Md5Sum          = CalculateMD5(stream);
            stream.Dispose();

            //Add the texture to the heap.
            TextureHeap.Add(this, tex);
        }
Example #6
0
        /// <summary>
        /// Change the current texture to another one.
        /// </summary>
        /// <param name="color">Color to change to.</param>
        public void ChangeTexture(Color color)
        {
            //Remove texture data if needed.
            TextureHeap.Remove(this);

            //Get the Md5Sum, reset path.
            MemoryStream colorTemp = new MemoryStream(new byte[] { color.A, color.R, color.G, color.B });

            Md5Sum      = CalculateMD5(colorTemp);
            TexturePath = null;
            colorTemp.Dispose();

            //Add this texture to the heap.
            TextureHeap.Add(this, color);
        }
Example #7
0
        /// <summary>
        /// Change the texture data.
        /// </summary>
        /// <param name="tex">Texture data.</param>
        public void ChangeTexture(Texture2D tex)
        {
            //Remove texture data if needed.
            TextureHeap.Remove(this);

            //Get the Md5Sum, reset path.
            MemoryStream stream = new MemoryStream();

            tex.SaveAsPng(stream, tex.Width, tex.Height);
            stream.Position = 0;
            Md5Sum          = CalculateMD5(stream);
            stream.Dispose();
            TexturePath = null;

            //Add this texture to the heap.
            TextureHeap.Add(this, tex);
        }