public static void Thumbnail(FileStoreInfo originalImageFileInfo, ThumbnailProperty thumbnailProperty, IThumbnailNameProvider thumbnailWriteProvider = null, params ThumbnailProperty[] thumbnailProperties)
 {
     var defaultThumbnailWriteProvider = thumbnailWriteProvider;
     if (originalImageFileInfo == null)
         throw new ArgumentNullException("originalImageFileInfo");
     if (string.IsNullOrEmpty(originalImageFileInfo.FileNameWithExtension))
         throw new ArgumentException("originalImageFileInfo.FileNameWithExtension不能为空");
     if (thumbnailProperty == null)
         throw new ArgumentNullException("thumbnailProperty");
     if (!File.Exists(originalImageFileInfo.FullFileName))
         throw new FileNotFoundException(string.Format("路径:{0}的不存在", originalImageFileInfo.FullFileName));
     if (thumbnailWriteProvider == null)
         defaultThumbnailWriteProvider = new DefaultThumbnailNameProvider();
     var unionThumbnailPropertyies = new[] { thumbnailProperty };
     if (thumbnailProperties != null)
     {
         unionThumbnailPropertyies = unionThumbnailPropertyies.Union(thumbnailProperties).ToArray();
     }
     var originalImage = System.Drawing.Image.FromFile(originalImageFileInfo.FullFileName);
     foreach (var property in unionThumbnailPropertyies)
     {
         var fileInfo = defaultThumbnailWriteProvider.GetThumbnailFileInfo(originalImageFileInfo, thumbnailProperty);
         var thumbnailImage = CreateThumbnailImage(originalImage, property);
         thumbnailImage.Save(fileInfo.FullFileName);
     }
 }
Exemple #2
0
        public static void Thumbnail(FileStoreInfo originalImageFileInfo, ThumbnailProperty thumbnailProperty, IThumbnailNameProvider thumbnailWriteProvider = null, params ThumbnailProperty[] thumbnailProperties)
        {
            var defaultThumbnailWriteProvider = thumbnailWriteProvider;

            if (originalImageFileInfo == null)
            {
                throw new ArgumentNullException("originalImageFileInfo");
            }
            if (string.IsNullOrEmpty(originalImageFileInfo.FileNameWithExtension))
            {
                throw new ArgumentException("originalImageFileInfo.FileNameWithExtension不能为空");
            }
            if (thumbnailProperty == null)
            {
                throw new ArgumentNullException("thumbnailProperty");
            }
            if (!File.Exists(originalImageFileInfo.FullFileName))
            {
                throw new FileNotFoundException(string.Format("路径:{0}的不存在", originalImageFileInfo.FullFileName));
            }
            if (thumbnailWriteProvider == null)
            {
                defaultThumbnailWriteProvider = new DefaultThumbnailNameProvider();
            }
            var unionThumbnailPropertyies = new[] { thumbnailProperty };

            if (thumbnailProperties != null)
            {
                unionThumbnailPropertyies = unionThumbnailPropertyies.Union(thumbnailProperties).ToArray();
            }
            var originalImage = System.Drawing.Image.FromFile(originalImageFileInfo.FullFileName);

            foreach (var property in unionThumbnailPropertyies)
            {
                var fileInfo       = defaultThumbnailWriteProvider.GetThumbnailFileInfo(originalImageFileInfo, thumbnailProperty);
                var thumbnailImage = CreateThumbnailImage(originalImage, property);
                thumbnailImage.Save(fileInfo.FullFileName);
            }
        }