示例#1
0
        /// <summary>
        /// Loads a texture from a byte array.
        /// </summary>
        /// <param name="bytes">The byte array to load from.</param>
        /// <returns>The loaded texture.</returns>
        public static Pvr LoadFromBytes(byte[] bytes)
        {
            var length     = bytes.Length;
            var srcPointer = Marshal.AllocHGlobal(length);

            Marshal.Copy(bytes, 0, srcPointer, length);

            var pointer = UnmanagedProxy.LoadFromMemory(srcPointer);
            var pvr     = new Pvr(pointer);

            return(pvr);
        }
示例#2
0
        /// <summary>
        /// Loads a texture from a file.
        /// </summary>
        /// <param name="path">The path of a file to load from.</param>
        /// <returns>The loaded texture.</returns>
        public static Pvr LoadFromFile(string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException("File not found", path);
            }

            var fullPath = Path.GetFullPath(path);
            var pointer  = UnmanagedProxy.LoadFromFile(path);
            var pvr      = new Pvr(pointer);

            return(pvr);
        }
示例#3
0
 /// <summary>
 /// Flips the texture horizontally.
 /// </summary>
 /// <returns>Whether it was flipped successfully.</returns>
 public bool FlipHorizontal()
 {
     return(UnmanagedProxy.FlipHorizontal(_pointer));
 }
示例#4
0
 /// <summary>
 /// Frees the memory space used by the texture.
 /// </summary>
 public void Dispose()
 {
     UnmanagedProxy.Dispose(_pointer);
 }
示例#5
0
 /// <summary>
 /// Flips the texture vertically.
 /// </summary>
 /// <returns>Whether it was flipped successfully.</returns>
 public bool FlipVertical()
 {
     return(UnmanagedProxy.FlipVertical(_pointer));
 }