GetExtension() public static méthode

public static GetExtension ( string fileName ) : string
fileName string
Résultat string
Exemple #1
0
        /// <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);
        }
Exemple #2
0
        ///////////////////////////
        //     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);
        }
Exemple #3
0
        public static bool IsValidExtension(string fileName, string[] extensions)
        {
            string extension = ImageViewerUtils.GetExtension(fileName);

            return(Array.Exists(extensions, delegate(string s) { return s == extension; }));
        }