private Bitmap ProduceBitmap2(Image img, ref Size size) { using (Bitmap resized = ImageTransform.ResizeImage(img, size, false, Interpolation)) { using (Bitmap grayscale = ImageTransform.GrayScale(resized, Red / 100.0F, Green / 100.0F, Blue / 100.0F, -((100 - Brightness) / 100.0F), (Contrast / 100.0F), IsGrayScale ? ImageTransform.Formula.SimpleAverage : Formula)) { using (Bitmap whiten = ImageTransform.Whitenize(grayscale, mWhitePoint, false)) { if (SelectedTool == Tool.Dithering) { return(ImageTransform.DitherImage(whiten, mDithering)); } else if (SelectedTool == Tool.Centerline) { //apply variable threshold (if needed) + 50% threshold (always) return(ImageTransform.Threshold(ImageTransform.Threshold(whiten, Threshold / 100.0F, UseThreshold), 50.0F / 100.0F, true)); } else { return(ImageTransform.Threshold(whiten, Threshold / 100.0F, UseThreshold)); } } } } }
private Bitmap ProduceBitmap(Image img, Size size) { if (SelectedTool == Tool.Vectorize && UseDownSampling && DownSampling > 1) //if downsampling { using (Image downsampled = ImageTransform.ResizeImage(img, new Size((int)(size.Width * 1 / DownSampling), (int)(size.Height * 1 / DownSampling)), false, InterpolationMode.HighQualityBicubic)) return(ProduceBitmap2(downsampled, ref size)); } else { return(ProduceBitmap2(img, ref size)); } }
private void ResizeRecalc() { lock (this) { if (mResized != null) { mResized.Dispose(); } mResized = ImageTransform.ResizeImage(mOriginal, CalculateResizeToFit(mOriginal.Size, mBoxSize), false, Interpolation); } }
private Bitmap ProduceWhitepointDemo(Image img, Size size) { using (Bitmap resized = ImageTransform.ResizeImage(mResized, mResized.Size, false, Interpolation)) using (Bitmap grayscale = ImageTransform.GrayScale(resized, Red / 100.0F, Green / 100.0F, Blue / 100.0F, -((100 - Brightness) / 100.0F), (Contrast / 100.0F), IsGrayScale ? ImageTransform.Formula.SimpleAverage : Formula)) return(ImageTransform.Whitenize(grayscale, mWhitePoint, true)); }