Example #1
0
        public Bitmap GetImage(string name)
        {
            if (name == "default" || name.Length == 0)
            {
                return(Properties.Resources._default);
            }
            if (!Path.IsPathRooted(name))
            {
                name = collectionPath.CompletePath + name;
            }
            var selPath = new DirectoryPath(name);

            if (collectionPath.IsSubDirectory(selPath))               //image is in our directory
            {
                LoadedImage picture = images.Find(item => item.Name == name);
                return((picture == null) ? LoadImage(name) : picture.Image);
            }
            return(Properties.Resources._default);
        }
Example #2
0
        private Bitmap LoadImage(string name)
        {
            var picture = new Bitmap(name);

            if (picture == null)
            {
                throw new FileNotFoundException();
            }

            if (!ValidateBitmap(picture))
            {
                picture.Dispose();
                name    = SaveImage(name);
                picture = new Bitmap(collectionPath.DirectoryName + name);
            }

            var item = new LoadedImage {
                Image = picture, Name = name
            };

            images.Add(item);
            return(picture);
        }