Exemplo n.º 1
0
        public static Texture2d Load(string filename, ResourceManager resourceManager = null, TextureOptions textureOptions = null)
        {
            try
            {
                textureOptions = textureOptions ?? TextureOptions.Load(TextureOptions.GetOptionsFilename(filename), resourceManager);
            }
            catch (FileNotFoundException)
            {
                Trace.WriteLine($"No texture options for {filename}");
            }

            if (File.Exists(filename))
            {
                using (var stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                    return(Load(stream, filename, textureOptions));
            }

            if (resourceManager == null)
            {
                return(null);
            }
            var resourceName = filename.Substring(0, filename.LastIndexOf(".")).Replace('-', '_');

            using (var bitmap = resourceManager.GetObject(resourceName) as Bitmap)
                if (bitmap != null)
                {
                    return(Load(bitmap, $"file:{filename}", textureOptions));
                }
                else
                {
                    Trace.WriteLine($"Texture not found: {filename} / {resourceName}");
                    return(null);
                }
        }
Exemplo n.º 2
0
 public static TextureOptions LoadTextureOptions(string forBitmapFilename, ResourceContainer resourceContainer = null)
 => TextureOptions.Load(TextureOptions.GetOptionsFilename(forBitmapFilename), resourceContainer);