/// <summary>Loads an image into memory but doesn't set it as the displayed image.</summary> private bool PreloadImage(string fileName) { if (ImageViewerUtils.GetExtension(fileName).Equals("gif")) { // Animated Image Graphics.GetAnimatedImageData(fileName); } else { // Image if (Graphics.GetTexture(fileName) == null) { return(false); } } return(true); }
/////////////////////////// // Image Loading // /////////////////////////// private bool LoadImage(string fileName) { File = fileName; string extension = ImageViewerUtils.GetExtension(fileName); bool isGif = extension.Equals("gif"); bool success = false; // Image if (!isGif) { Texture texture = Graphics.GetTexture(fileName); if (texture != null) { success = true; texture.Smooth = true; Image = new Sprite(texture); } else if (!extension.Equals("ico")) { return(false); } } // Animated GIF or image that failed to load normally (ie some .icos) if (isGif || !success) { Image = Graphics.GetAnimatedImage(fileName); if (Image.Texture == null) { return(false); } } Image.Origin = new Vector2f(Image.Texture.Size.X / 2, Image.Texture.Size.Y / 2); Image.Position = new Vector2f(Image.Texture.Size.X / 2, Image.Texture.Size.Y / 2); DefaultRotation = ImageViewerUtils.GetDefaultRotationFromEXIF(fileName); return(true); }