Exemplo n.º 1
0
        internal static void GeneratePostImageResizes(Settings settings, PostRepository postRepository)
        {
            var size         = settings.ItemImageSize;
            var maximumLevel = DeepZoomImage.DetermineMaximumLevel(size);

            var workingPath      = Path.GetFullPath(WorkingFolderName);
            var imageFormat      = settings.PostImageEncoding;
            var extension        = imageFormat.ToString().ToLower();
            var fileNameIdFormat = settings.FileNameIdFormat;

            foreach (var postId in postRepository.RetrievePostIds())
            {
                var relativeBinnedImagePath   = Post.ComputeBinnedPath(postId, extension, fileNameIdFormat);
                var absoluteBinnedImagePath   = Path.Combine(workingPath, relativeBinnedImagePath);
                var relativeBinnedImageFolder = Post.ComputeBinnedPath(postId, null, fileNameIdFormat) + "_files";
                var absoluteBinnedImageFolder = Path.Combine(workingPath, relativeBinnedImageFolder);
                Directory.CreateDirectory(absoluteBinnedImageFolder);
                using (var inputStream =
                           new FileStream(absoluteBinnedImagePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (var sourceBitmap = new Bitmap(inputStream))
                    {
                        GeneratePostImageResizes(sourceBitmap, size, maximumLevel, (level, resizedBitmap) =>
                        {
                            var levelImageName = "{0}.{1}".FormatInvariant(level, extension);
                            var levelImagePath = Path.Combine(absoluteBinnedImageFolder, levelImageName);
                            using (var outputStream =
                                       new FileStream(levelImagePath, FileMode.Create, FileAccess.Write, FileShare.Read))
                            {
                                resizedBitmap.Save(outputStream, imageFormat);
                            }
                        }
                                                 );
                    }
            }
        }
Exemplo n.º 2
0
        internal static void GenerateImageSlices(Settings settings, PostRepository postRepository)
        {
            var size             = settings.ItemImageSize;
            var maximumLevel     = DeepZoomImage.DetermineMaximumLevel(size);
            var imageFormat      = settings.PostImageEncoding;
            var imageExtension   = imageFormat.ToString().ToLower();
            var fileNameIdFormat = settings.FileNameIdFormat;

            foreach (var postId in postRepository.RetrievePostIds())
            {
                SlicePostImage(postId, size, maximumLevel, imageExtension, fileNameIdFormat, imageFormat, settings.TileSize, settings.TileOverlap);
            }
        }