public static bool LoadFromFile(string filepath, out MyFileTextureParams outParams) { outParams = new MyFileTextureParams(); if (string.IsNullOrEmpty(filepath)) { return(false); } filepath = MyResourceUtils.GetTextureFullPath(filepath); if (m_dictCached.TryGetValue(filepath, out outParams)) { return(true); } if (!MyFileSystem.FileExists(filepath)) { MyRender11.Log.WriteLine("Missing texture: " + filepath); return(false); } try { using (var s = MyFileSystem.OpenRead(filepath)) { Image image = Image.Load(s); outParams.Resolution.X = image.Description.Width; outParams.Resolution.Y = image.Description.Height; outParams.Format = image.Description.Format; outParams.Mipmaps = image.Description.MipLevels; outParams.ArraySize = image.Description.ArraySize; } m_dictCached.Add(filepath, outParams); return(true); } catch (Exception) { MyRenderProxy.Assert(false, "The file in textures exists, but cannot be loaded. Please, investigate!"); return(false); } }
public static bool LoadFromFile(string filepath, out MyFileTextureParams outParams) { outParams = new MyFileTextureParams(); if (string.IsNullOrEmpty(filepath)) return false; filepath = MyResourceUtils.GetTextureFullPath(filepath); if (m_dictCached.TryGetValue(filepath, out outParams)) return true; if (!MyFileSystem.FileExists(filepath)) { MyRender11.Log.WriteLine("Missing texture: " + filepath); return false; } try { using (var s = MyFileSystem.OpenRead(filepath)) { Image image = Image.Load(s); outParams.Resolution.X = image.Description.Width; outParams.Resolution.Y = image.Description.Height; outParams.Format = image.Description.Format; outParams.Mipmaps = image.Description.MipLevels; outParams.ArraySize = image.Description.ArraySize; } m_dictCached.Add(filepath, outParams); return true; } catch (Exception) { MyRenderProxy.Assert(false, "The file in textures exists, but cannot be loaded. Please, investigate!"); return false; } }