示例#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);
        }