Exemple #1
0
 /// <summary>
 /// Load a wrm image.
 /// </summary>
 /// <param name="file">The path of the image.</param>
 /// <returns>A new instance of the WORM class.</returns>
 public static WORM FromFile(string file)
 {
     try
     {
         WORM wrm = new WORM();
         wrm.Load(file);
         return(wrm);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "\r\nIn WORM.FromFile(string)");
     }
 }
Exemple #2
0
        public static IMAGE LoadImage(string path, bool showError = false)
        {
            if (string.IsNullOrEmpty(path) || !File.Exists(path))
            {
                return(null);
            }

            ImgFormat fmt = GetImageFormat(path);

            if (fmt == ImgFormat.nil)
            {
                fmt = GetImageFormatFromPath(path);
            }

            try
            {
                switch (fmt)
                {
                case ImgFormat.png:
                    PNG png = new PNG();
                    png.Load(path);
                    return(png);

                case ImgFormat.bmp:
                    BMP bmp = new BMP();
                    bmp.Load(path);
                    return(bmp);

                case ImgFormat.gif:
                    Gif gif = new Gif();
                    gif.Load(path);
                    return(gif);

                case ImgFormat.jpg:
                    JPEG jpeg = new JPEG();
                    jpeg.Load(path);
                    return(jpeg);

                case ImgFormat.tif:
                    TIFF tiff = new TIFF();
                    tiff.Load(path);
                    return(tiff);

                case ImgFormat.webp:
                    Webp webp = new Webp();
                    webp.Load(path);
                    return(webp);

                case ImgFormat.wrm:
                    WORM worm = new WORM();
                    worm.Load(path);
                    return(worm);
                }
            }
            catch (Exception e)
            {
                if (showError)
                {
                    e.ShowError();
                }
            }
            return(null);
        }