private Pipeline CreateTilePipeline(Rectangle boundsOnResizedImage) { var tilePipeline = new Pipeline(); var fileCache = FileCache.GetInstance(); var fileName = _filePrefix + "_" + _tiles.Count + _fileExtension; fileCache.RegisterPublicTempFileName(fileName, false); tilePipeline.Add(new Crop(boundsOnResizedImage)); if ((_bitmapViewer.SourceImageParams.ColorProfile != null && _bitmapViewer.SourceImageParams.ColorProfile.ColorSpace == ColorSpace.Cmyk) || _bitmapViewer.SourceImageParams.PixelFormat.HasAlpha) { var cc = new Transforms.ColorConverter(PixelFormat.Format24bppRgb) { ColorManagementEngine = ColorManagementEngine.LittleCms, DestinationProfile = ColorProfile.FromSrgb() }; tilePipeline.Add(cc); } tilePipeline.Add(ImageWriter.Create(fileCache.GetAbsolutePublicCachePath(fileName), _encoderOptions)); return(tilePipeline); }
private string SavePreviewImage() { if (!_previewImageEnabled) { return(""); } var fileName = _fileCache.GetPublicTempFileName(".jpg"); var width = (int)(Math.Max(SourceImageParams.Width * ActualSizeHorizontalScale / _previewImageResizeRatio, 1)); var height = (int)(Math.Max(SourceImageParams.Height * ActualSizeVerticalScale / _previewImageResizeRatio, 1)); var pipeline = new Pipeline { ImageReader.Create(_fileCache.GetAbsolutePrivateCachePath(SourceCacheFilename)), new Resize(width, height, ResizeInterpolationMode.Anisotropic9) }; if ((SourceImageParams.ColorProfile != null && SourceImageParams.PixelFormat.ColorSpace != ColorSpace.Rgb) || SourceImageParams.PixelFormat.HasAlpha) { var cc = new Transforms.ColorConverter(PixelFormat.Format24bppRgb) { ColorManagementEngine = ColorManagementEngine.LittleCms, DestinationProfile = ColorProfile.FromSrgb() }; pipeline.Add(cc); } pipeline.Add(new JpegWriter(_fileCache.GetAbsolutePublicCachePath(fileName), 60)); pipeline.Run(); pipeline.DisposeAllElements(); return(_fileCache.GetRelativePublicCachePath(fileName)); }