Пример #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Surface2D"/> class.
        /// </summary>
        /// <param name="source">The <see cref="SurfaceSource"/> from which to create the surface.</param>
        /// <param name="options">The surface's configuration options.</param>
        /// <returns>The instance of <see cref="Surface2D"/> that was created.</returns>
        public static Surface2D Create(SurfaceSource source, SurfaceOptions options = SurfaceOptions.Default)
        {
            Contract.Require(source, nameof(source));

            var uv = UltravioletContext.DemandCurrent();

            return(uv.GetFactoryMethod <Surface2DFromSourceFactory>()(uv, source, options));
        }
Пример #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="PlatformNativeSurface"/> class.
        /// </summary>
        /// <param name="stream">The stream from which to load the surface.</param>
        /// <returns>The instance of <see cref="PlatformNativeSurface"/> that was created.</returns>
        public static PlatformNativeSurface Create(Stream stream)
        {
            var uv      = UltravioletContext.DemandCurrent();
            var factory = uv.GetFactoryMethod <PlatformNativeSurfaceFactory>();

            var data = new Byte[stream.Length];

            stream.Read(data, 0, data.Length);

            using (var mstream = new MemoryStream(data))
                using (var src = SurfaceSource.Create(mstream))
                {
                    return(factory(src));
                }
        }
Пример #3
0
        /// <summary>
        /// Creates a new instance of the <see cref="PlatformNativeSurface"/> class.
        /// </summary>
        /// <param name="source">The surface source from which to create the surface.</param>
        /// <returns>The instance of <see cref="PlatformNativeSurface"/> that was created.</returns>
        public static PlatformNativeSurface Create(SurfaceSource source)
        {
            var uv = UltravioletContext.DemandCurrent();

            return(uv.GetFactoryMethod <PlatformNativeSurfaceFactory>()(source));
        }