示例#1
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);
        }
示例#2
0
        /// <summary>
        /// Dispose.
        /// </summary>
        public void Dispose()
        {
            //Remove resources.
            if (!Disposed)
            {
                //Remove the texture from the heap.
                TextureHeap.Remove(this);

                //Disposed.
                Disposed = true;
            }
        }
示例#3
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);
        }
示例#4
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);
        }