public void PostProcessStep2(ScannedImage image, Bitmap bitmap, ScanProfile profile, ScanParams scanParams, int pageNumber, bool supportsNativeUI = true)
{
if (!scanParams.NoThumbnails)
{
image.SetThumbnail(thumbnailRenderer.RenderThumbnail(bitmap));
}
if (scanParams.SkipPostProcessing)
{
return;
}
if (profile.StretchHistogram && !profile.HistogramStretchConfig.IsNull)
{
AddTransformAndUpdateThumbnail(image, ref bitmap, new StretchHistogramTransform {
Parameters = profile.HistogramStretchConfig
});
}
if ((!profile.UseNativeUI || !supportsNativeUI) && profile.BrightnessContrastAfterScan)
{
if (profile.Brightness != 0)
{
AddTransformAndUpdateThumbnail(image, ref bitmap, new BrightnessTransform {
Brightness = profile.Brightness
});
}
if (profile.Contrast != 0)
{
AddTransformAndUpdateThumbnail(image, ref bitmap, new TrueContrastTransform {
Contrast = profile.Contrast
});
}
}
if (profile.FlipDuplexedPages && pageNumber % 2 == 0)
{
AddTransformAndUpdateThumbnail(image, ref bitmap, new RotationTransform(RotateFlipType.Rotate180FlipNone));
}
if (profile.AutoDeskew)
{
var op = operationFactory.Create <DeskewOperation>();
if (op.Start(new[] { image }))
{
operationProgress.ShowProgress(op);
op.Wait();
}
}
if (scanParams.DetectPatchCodes && image.PatchCode == PatchCode.None)
{
image.PatchCode = PatchCodeDetector.Detect(bitmap);
}
}