mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-11 02:45:19 +03:00
Remove ScannedImageRenderer (in favour of the interface and implementors)
This commit is contained in:
parent
b3836aa91e
commit
fcb86ec0ad
@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Images.Transforms;
|
||||
|
||||
namespace NAPS2.Images
|
||||
{
|
||||
// TODO: Delete this in favour of IScannedImageRenderer and implementors
|
||||
public class ScannedImageRenderer
|
||||
{
|
||||
public async Task<IImage> Render(ScannedImage image, int outputSize = 0)
|
||||
{
|
||||
using (var snapshot = image.Preserve())
|
||||
{
|
||||
return await Render(snapshot, outputSize);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IImage> Render(ScannedImage.Snapshot snapshot, int outputSize = 0)
|
||||
{
|
||||
return await Task.Factory.StartNew(() =>
|
||||
{
|
||||
var storage = StorageManager.ConvertToImage(snapshot.Source.BackingStorage, new StorageConvertParams());
|
||||
if (outputSize > 0)
|
||||
{
|
||||
double scaleFactor = Math.Min(outputSize / (double)storage.Height, outputSize / (double)storage.Width);
|
||||
storage = Transform.Perform(storage, new ScaleTransform(scaleFactor));
|
||||
}
|
||||
return Transform.PerformAll(storage, snapshot.TransformList);
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<Stream> RenderToStream(ScannedImage image)
|
||||
{
|
||||
using (var snapshot = image.Preserve())
|
||||
{
|
||||
return await RenderToStream(snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Stream> RenderToStream(ScannedImage.Snapshot snapshot)
|
||||
{
|
||||
using (var transformed = await Render(snapshot))
|
||||
{
|
||||
return StorageManager.Convert<MemoryStreamStorage>(transformed, new StorageConvertParams
|
||||
{
|
||||
// TODO: Is this right?
|
||||
Lossless = snapshot.Source.Metadata.Lossless
|
||||
}).Stream;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@ namespace NAPS2.ImportExport
|
||||
{
|
||||
public class DirectImportOperation : OperationBase
|
||||
{
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly ImageRenderer imageRenderer;
|
||||
|
||||
public DirectImportOperation(ScannedImageRenderer scannedImageRenderer)
|
||||
public DirectImportOperation(ImageRenderer imageRenderer)
|
||||
{
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.imageRenderer = imageRenderer;
|
||||
|
||||
AllowCancel = true;
|
||||
AllowBackground = true;
|
||||
@ -50,7 +50,7 @@ namespace NAPS2.ImportExport
|
||||
img.AddTransform(transform);
|
||||
}
|
||||
// TODO: Don't bother, here, in recovery, etc.
|
||||
img.SetThumbnail(Transform.Perform(await scannedImageRenderer.Render(img), new ThumbnailTransform()));
|
||||
img.SetThumbnail(Transform.Perform(await imageRenderer.Render(img), new ThumbnailTransform()));
|
||||
imageCallback(img);
|
||||
|
||||
Status.CurrentProgress++;
|
||||
|
@ -12,23 +12,23 @@ using NAPS2.Lang.Resources;
|
||||
using NAPS2.Logging;
|
||||
using NAPS2.Operation;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Util;
|
||||
|
||||
namespace NAPS2.ImportExport.Images
|
||||
{
|
||||
// TODO: Avoid GDI dependency
|
||||
public class SaveImagesOperation : OperationBase
|
||||
{
|
||||
private readonly ImageSettingsContainer imageSettingsContainer;
|
||||
private readonly IOverwritePrompt overwritePrompt;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly BitmapRenderer bitmapRenderer;
|
||||
private readonly TiffHelper tiffHelper;
|
||||
|
||||
public SaveImagesOperation(ImageSettingsContainer imageSettingsContainer, IOverwritePrompt overwritePrompt, ScannedImageRenderer scannedImageRenderer, TiffHelper tiffHelper)
|
||||
public SaveImagesOperation(ImageSettingsContainer imageSettingsContainer, IOverwritePrompt overwritePrompt, BitmapRenderer bitmapRenderer, TiffHelper tiffHelper)
|
||||
{
|
||||
this.imageSettingsContainer = imageSettingsContainer;
|
||||
this.overwritePrompt = overwritePrompt;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.bitmapRenderer = bitmapRenderer;
|
||||
this.tiffHelper = tiffHelper;
|
||||
|
||||
ProgressTitle = MiscResources.SaveImagesProgress;
|
||||
@ -175,14 +175,14 @@ namespace NAPS2.ImportExport.Images
|
||||
var encoderParams = new EncoderParameters(1);
|
||||
encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, quality);
|
||||
// TODO: Something more generic
|
||||
using (Bitmap bitmap = ((GdiImage) await scannedImageRenderer.Render(snapshot)).Bitmap)
|
||||
using (Bitmap bitmap = await bitmapRenderer.Render(snapshot))
|
||||
{
|
||||
bitmap.Save(path, encoder, encoderParams);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Bitmap bitmap = ((GdiImage)await scannedImageRenderer.Render(snapshot)).Bitmap)
|
||||
using (Bitmap bitmap = await bitmapRenderer.Render(snapshot))
|
||||
{
|
||||
bitmap.Save(path, format);
|
||||
}
|
||||
|
@ -8,18 +8,17 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Util;
|
||||
|
||||
namespace NAPS2.ImportExport.Images
|
||||
{
|
||||
public class TiffHelper
|
||||
{
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly BitmapRenderer bitmapRenderer;
|
||||
|
||||
public TiffHelper(ScannedImageRenderer scannedImageRenderer)
|
||||
public TiffHelper(BitmapRenderer bitmapRenderer)
|
||||
{
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.bitmapRenderer = bitmapRenderer;
|
||||
}
|
||||
|
||||
public async Task<bool> SaveMultipage(List<ScannedImage.Snapshot> snapshots, string location, TiffCompression compression, ProgressHandler progressCallback, CancellationToken cancelToken)
|
||||
@ -41,7 +40,7 @@ namespace NAPS2.ImportExport.Images
|
||||
var iparams = new EncoderParameters(1);
|
||||
Encoder iparam = Encoder.Compression;
|
||||
// TODO: More generic (?)
|
||||
using (var bitmap = ((GdiImage)await scannedImageRenderer.Render(snapshots[0])).Bitmap)
|
||||
using (var bitmap = await bitmapRenderer.Render(snapshots[0]))
|
||||
{
|
||||
ValidateBitmap(bitmap);
|
||||
var iparamPara = new EncoderParameter(iparam, (long)GetEncoderValue(compression, bitmap));
|
||||
@ -56,7 +55,7 @@ namespace NAPS2.ImportExport.Images
|
||||
var compressionEncoder = Encoder.Compression;
|
||||
|
||||
File.Delete(location);
|
||||
using (var bitmap0 = ((GdiImage)await scannedImageRenderer.Render(snapshots[0])).Bitmap)
|
||||
using (var bitmap0 = await bitmapRenderer.Render(snapshots[0]))
|
||||
{
|
||||
ValidateBitmap(bitmap0);
|
||||
encoderParams.Param[0] = new EncoderParameter(compressionEncoder, (long)GetEncoderValue(compression, bitmap0));
|
||||
@ -76,7 +75,7 @@ namespace NAPS2.ImportExport.Images
|
||||
return false;
|
||||
}
|
||||
|
||||
using (var bitmap = ((GdiImage)await scannedImageRenderer.Render(snapshots[i])).Bitmap)
|
||||
using (var bitmap = await bitmapRenderer.Render(snapshots[i]))
|
||||
{
|
||||
ValidateBitmap(bitmap);
|
||||
encoderParams.Param[0] = new EncoderParameter(compressionEncoder, (long)GetEncoderValue(compression, bitmap));
|
||||
|
@ -23,6 +23,7 @@ using PdfSharp.Pdf.Security;
|
||||
|
||||
namespace NAPS2.ImportExport.Pdf
|
||||
{
|
||||
// TODO: Avoid Task.Result use here (and elsewhere)
|
||||
public class PdfSharpExporter : IPdfExporter
|
||||
{
|
||||
static PdfSharpExporter()
|
||||
@ -33,12 +34,18 @@ namespace NAPS2.ImportExport.Pdf
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly MemoryStreamRenderer memoryStreamRenderer;
|
||||
private readonly OcrRequestQueue ocrRequestQueue;
|
||||
|
||||
public PdfSharpExporter(ScannedImageRenderer scannedImageRenderer, OcrRequestQueue ocrRequestQueue)
|
||||
public PdfSharpExporter()
|
||||
{
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
memoryStreamRenderer = new MemoryStreamRenderer();
|
||||
ocrRequestQueue = OcrRequestQueue.Default;
|
||||
}
|
||||
|
||||
public PdfSharpExporter(MemoryStreamRenderer memoryStreamRenderer, OcrRequestQueue ocrRequestQueue)
|
||||
{
|
||||
this.memoryStreamRenderer = memoryStreamRenderer;
|
||||
this.ocrRequestQueue = ocrRequestQueue;
|
||||
}
|
||||
|
||||
@ -142,7 +149,7 @@ namespace NAPS2.ImportExport.Pdf
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Stream stream = scannedImageRenderer.RenderToStream(snapshot).Result)
|
||||
using (Stream stream = memoryStreamRenderer.Render(snapshot).Result)
|
||||
using (var img = XImage.FromStream(stream))
|
||||
{
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
@ -195,7 +202,7 @@ namespace NAPS2.ImportExport.Pdf
|
||||
|
||||
string tempImageFilePath = Path.Combine(Paths.Temp, Path.GetRandomFileName());
|
||||
|
||||
using (Stream stream = scannedImageRenderer.RenderToStream(snapshot).Result)
|
||||
using (Stream stream = memoryStreamRenderer.Render(snapshot).Result)
|
||||
using (var img = XImage.FromStream(stream))
|
||||
{
|
||||
if (cancelToken.IsCancellationRequested)
|
||||
|
@ -27,17 +27,15 @@ namespace NAPS2.ImportExport.Pdf
|
||||
{
|
||||
private readonly IErrorOutput errorOutput;
|
||||
private readonly IPdfPasswordProvider pdfPasswordProvider;
|
||||
private readonly ThumbnailRenderer thumbnailRenderer;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly ImageRenderer imageRenderer;
|
||||
private readonly IPdfRenderer pdfRenderer;
|
||||
private readonly IComponentInstallPrompt componentInstallPrompt;
|
||||
|
||||
public PdfSharpImporter(IErrorOutput errorOutput, IPdfPasswordProvider pdfPasswordProvider, ThumbnailRenderer thumbnailRenderer, ScannedImageRenderer scannedImageRenderer, IPdfRenderer pdfRenderer, IComponentInstallPrompt componentInstallPrompt)
|
||||
public PdfSharpImporter(IErrorOutput errorOutput, IPdfPasswordProvider pdfPasswordProvider, ImageRenderer imageRenderer, IPdfRenderer pdfRenderer, IComponentInstallPrompt componentInstallPrompt)
|
||||
{
|
||||
this.errorOutput = errorOutput;
|
||||
this.pdfPasswordProvider = pdfPasswordProvider;
|
||||
this.thumbnailRenderer = thumbnailRenderer;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.imageRenderer = imageRenderer;
|
||||
this.pdfRenderer = pdfRenderer;
|
||||
this.componentInstallPrompt = componentInstallPrompt;
|
||||
}
|
||||
@ -192,7 +190,7 @@ namespace NAPS2.ImportExport.Pdf
|
||||
var image = new ScannedImage(new PdfFileStorage(pdfPath));
|
||||
if (!importParams.NoThumbnails || importParams.DetectPatchCodes)
|
||||
{
|
||||
using (var bitmap = await scannedImageRenderer.Render(image))
|
||||
using (var bitmap = await imageRenderer.Render(image))
|
||||
{
|
||||
if (!importParams.NoThumbnails)
|
||||
{
|
||||
|
@ -16,11 +16,11 @@ namespace NAPS2.ImportExport
|
||||
{
|
||||
public class PrintDocumentPrinter : IScannedImagePrinter
|
||||
{
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly ImageRenderer imageRenderer;
|
||||
|
||||
public PrintDocumentPrinter(ScannedImageRenderer scannedImageRenderer)
|
||||
public PrintDocumentPrinter(ImageRenderer imageRenderer)
|
||||
{
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.imageRenderer = imageRenderer;
|
||||
}
|
||||
|
||||
public async Task<bool> PromptToPrint(List<ScannedImage> images, List<ScannedImage> selectedImages)
|
||||
@ -82,7 +82,7 @@ namespace NAPS2.ImportExport
|
||||
int i = 0;
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
var image = Task.Factory.StartNew(() => scannedImageRenderer.Render(imagesToPrint[i])).Unwrap().Result;
|
||||
var image = Task.Factory.StartNew(() => imageRenderer.Render(imagesToPrint[i])).Unwrap().Result;
|
||||
try
|
||||
{
|
||||
var pb = e.PageBounds;
|
||||
|
@ -350,7 +350,6 @@
|
||||
<Compile Include="Dependencies\PlatformSupport.cs" />
|
||||
<Compile Include="Images\AutoDeskew.cs" />
|
||||
<Compile Include="Operation\OperationProgress.cs" />
|
||||
<Compile Include="Images\ScannedImageRenderer.cs" />
|
||||
<Compile Include="Dependencies\DownloadFormat.cs" />
|
||||
<Compile Include="Dependencies\DownloadInfo.cs" />
|
||||
<Compile Include="Ocr\Language.cs" />
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -11,7 +10,6 @@ using NAPS2.Operation;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Images.Storage;
|
||||
using NAPS2.Images.Transforms;
|
||||
using NAPS2.Util;
|
||||
using NAPS2.WinForms;
|
||||
|
||||
namespace NAPS2.Recovery
|
||||
@ -19,19 +17,19 @@ namespace NAPS2.Recovery
|
||||
public class RecoveryManager
|
||||
{
|
||||
private readonly IFormFactory formFactory;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly ImageRenderer imageRenderer;
|
||||
private readonly OperationProgress operationProgress;
|
||||
|
||||
public RecoveryManager(IFormFactory formFactory, ScannedImageRenderer scannedImageRenderer, OperationProgress operationProgress)
|
||||
public RecoveryManager(IFormFactory formFactory, ImageRenderer imageRenderer, OperationProgress operationProgress)
|
||||
{
|
||||
this.formFactory = formFactory;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.imageRenderer = imageRenderer;
|
||||
this.operationProgress = operationProgress;
|
||||
}
|
||||
|
||||
public void RecoverScannedImages(Action<ScannedImage> imageCallback)
|
||||
{
|
||||
var op = new RecoveryOperation(formFactory, scannedImageRenderer);
|
||||
var op = new RecoveryOperation(formFactory, imageRenderer);
|
||||
if (op.Start(imageCallback))
|
||||
{
|
||||
operationProgress.ShowProgress(op);
|
||||
@ -41,7 +39,7 @@ namespace NAPS2.Recovery
|
||||
private class RecoveryOperation : OperationBase
|
||||
{
|
||||
private readonly IFormFactory formFactory;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly ImageRenderer imageRenderer;
|
||||
|
||||
private FileStream lockFile;
|
||||
private DirectoryInfo folderToRecoverFrom;
|
||||
@ -49,10 +47,10 @@ namespace NAPS2.Recovery
|
||||
private int imageCount;
|
||||
private DateTime scannedDateTime;
|
||||
|
||||
public RecoveryOperation(IFormFactory formFactory, ScannedImageRenderer scannedImageRenderer)
|
||||
public RecoveryOperation(IFormFactory formFactory, ImageRenderer imageRenderer)
|
||||
{
|
||||
this.formFactory = formFactory;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.imageRenderer = imageRenderer;
|
||||
|
||||
ProgressTitle = MiscResources.ImportProgress;
|
||||
AllowCancel = true;
|
||||
@ -152,7 +150,7 @@ namespace NAPS2.Recovery
|
||||
{
|
||||
scannedImage.AddTransform(transform);
|
||||
}
|
||||
scannedImage.SetThumbnail(Transform.Perform(await scannedImageRenderer.Render(scannedImage), new ThumbnailTransform()));
|
||||
scannedImage.SetThumbnail(Transform.Perform(await imageRenderer.Render(scannedImage), new ThumbnailTransform()));
|
||||
imageCallback(scannedImage);
|
||||
|
||||
Status.CurrentProgress++;
|
||||
|
@ -10,8 +10,8 @@ namespace NAPS2.WinForms
|
||||
{
|
||||
partial class FBlackWhite : ImageForm
|
||||
{
|
||||
public FBlackWhite(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
: base(changeTracker, scannedImageRenderer)
|
||||
public FBlackWhite(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
: base(changeTracker, bitmapRenderer)
|
||||
{
|
||||
InitializeComponent();
|
||||
ActiveControl = txtThreshold;
|
||||
|
@ -10,8 +10,8 @@ namespace NAPS2.WinForms
|
||||
{
|
||||
partial class FBrightnessContrast : ImageForm
|
||||
{
|
||||
public FBrightnessContrast(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
: base(changeTracker, scannedImageRenderer)
|
||||
public FBrightnessContrast(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
: base(changeTracker, bitmapRenderer)
|
||||
{
|
||||
InitializeComponent();
|
||||
ActiveControl = txtBrightness;
|
||||
|
@ -20,8 +20,8 @@ namespace NAPS2.WinForms
|
||||
|
||||
private int originalWidth, originalHeight;
|
||||
|
||||
public FCrop(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
: base(changeTracker, scannedImageRenderer)
|
||||
public FCrop(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
: base(changeTracker, bitmapRenderer)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -53,7 +53,8 @@ namespace NAPS2.WinForms
|
||||
private readonly KeyboardShortcutManager ksm;
|
||||
private readonly ThumbnailRenderer thumbnailRenderer;
|
||||
private readonly WinFormsExportHelper exportHelper;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly BitmapRenderer bitmapRenderer;
|
||||
private readonly ImageRenderer imageRenderer;
|
||||
private readonly NotificationManager notify;
|
||||
private readonly CultureInitializer cultureInitializer;
|
||||
private readonly IWorkerServiceFactory workerServiceFactory;
|
||||
@ -74,7 +75,7 @@ namespace NAPS2.WinForms
|
||||
|
||||
#region Initialization and Culture
|
||||
|
||||
public FDesktop(StringWrapper stringWrapper, RecoveryManager recoveryManager, OcrManager ocrManager, IProfileManager profileManager, IScanPerformer scanPerformer, IScannedImagePrinter scannedImagePrinter, ChangeTracker changeTracker, StillImage stillImage, IOperationFactory operationFactory, KeyboardShortcutManager ksm, ThumbnailRenderer thumbnailRenderer, WinFormsExportHelper exportHelper, ScannedImageRenderer scannedImageRenderer, NotificationManager notify, CultureInitializer cultureInitializer, IWorkerServiceFactory workerServiceFactory, OperationProgress operationProgress, UpdateChecker updateChecker)
|
||||
public FDesktop(StringWrapper stringWrapper, RecoveryManager recoveryManager, OcrManager ocrManager, IProfileManager profileManager, IScanPerformer scanPerformer, IScannedImagePrinter scannedImagePrinter, ChangeTracker changeTracker, StillImage stillImage, IOperationFactory operationFactory, KeyboardShortcutManager ksm, ThumbnailRenderer thumbnailRenderer, WinFormsExportHelper exportHelper, BitmapRenderer bitmapRenderer, ImageRenderer imageRenderer, NotificationManager notify, CultureInitializer cultureInitializer, IWorkerServiceFactory workerServiceFactory, OperationProgress operationProgress, UpdateChecker updateChecker)
|
||||
{
|
||||
this.stringWrapper = stringWrapper;
|
||||
this.recoveryManager = recoveryManager;
|
||||
@ -88,7 +89,8 @@ namespace NAPS2.WinForms
|
||||
this.ksm = ksm;
|
||||
this.thumbnailRenderer = thumbnailRenderer;
|
||||
this.exportHelper = exportHelper;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.bitmapRenderer = bitmapRenderer;
|
||||
this.imageRenderer = imageRenderer;
|
||||
this.notify = notify;
|
||||
this.cultureInitializer = cultureInitializer;
|
||||
this.workerServiceFactory = workerServiceFactory;
|
||||
@ -1703,7 +1705,7 @@ namespace NAPS2.WinForms
|
||||
}
|
||||
if (includeBitmap)
|
||||
{
|
||||
using (var firstBitmap = ((GdiImage)await scannedImageRenderer.Render(imageList[0])).Bitmap)
|
||||
using (var firstBitmap = await bitmapRenderer.Render(imageList[0]))
|
||||
{
|
||||
ido.SetData(DataFormats.Bitmap, true, new Bitmap(firstBitmap));
|
||||
ido.SetData(DataFormats.Rtf, true, await RtfEncodeImages(firstBitmap, imageList));
|
||||
@ -1724,7 +1726,7 @@ namespace NAPS2.WinForms
|
||||
}
|
||||
foreach (var img in images.Skip(1))
|
||||
{
|
||||
using (var bitmap = ((GdiImage)await scannedImageRenderer.Render(img)).Bitmap)
|
||||
using (var bitmap = await bitmapRenderer.Render(img))
|
||||
{
|
||||
// TODO: Is this the right format?
|
||||
if (!AppendRtfEncodedImage(bitmap, bitmap.RawFormat, sb, true))
|
||||
@ -1861,7 +1863,7 @@ namespace NAPS2.WinForms
|
||||
{
|
||||
var thumb = worker != null
|
||||
? StorageManager.ImageFactory.Decode(new MemoryStream(worker.Service.RenderThumbnail(snapshot, thumbnailList1.ThumbnailSize.Height)), ".jpg")
|
||||
: scannedImageRenderer.Render(snapshot, thumbnailList1.ThumbnailSize.Height).Result;
|
||||
: imageRenderer.Render(snapshot, thumbnailList1.ThumbnailSize.Height).Result;
|
||||
|
||||
if (!ThumbnailStillNeedsRendering(next))
|
||||
{
|
||||
|
@ -10,8 +10,8 @@ namespace NAPS2.WinForms
|
||||
{
|
||||
partial class FHueSaturation : ImageForm
|
||||
{
|
||||
public FHueSaturation(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
: base(changeTracker, scannedImageRenderer)
|
||||
public FHueSaturation(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
: base(changeTracker, bitmapRenderer)
|
||||
{
|
||||
InitializeComponent();
|
||||
ActiveControl = txtHue;
|
||||
|
@ -20,8 +20,8 @@ namespace NAPS2.WinForms
|
||||
private bool guideExists;
|
||||
private Point guideStart, guideEnd;
|
||||
|
||||
public FRotate(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
: base(changeTracker, scannedImageRenderer)
|
||||
public FRotate(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
: base(changeTracker, bitmapRenderer)
|
||||
{
|
||||
InitializeComponent();
|
||||
txtAngle.Text += '\u00B0';
|
||||
|
@ -10,8 +10,8 @@ namespace NAPS2.WinForms
|
||||
{
|
||||
partial class FSharpen : ImageForm
|
||||
{
|
||||
public FSharpen(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
: base(changeTracker, scannedImageRenderer)
|
||||
public FSharpen(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
: base(changeTracker, bitmapRenderer)
|
||||
{
|
||||
InitializeComponent();
|
||||
ActiveControl = txtSharpen;
|
||||
|
@ -46,16 +46,16 @@ namespace NAPS2.WinForms
|
||||
private ToolStripButton tsHueSaturation;
|
||||
private ToolStripButton tsBlackWhite;
|
||||
private ToolStripButton tsSharpen;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly BitmapRenderer bitmapRenderer;
|
||||
private readonly KeyboardShortcutManager ksm;
|
||||
private readonly OperationProgress operationProgress;
|
||||
|
||||
public FViewer(ChangeTracker changeTracker, IOperationFactory operationFactory, WinFormsExportHelper exportHelper, ScannedImageRenderer scannedImageRenderer, KeyboardShortcutManager ksm, OperationProgress operationProgress)
|
||||
public FViewer(ChangeTracker changeTracker, IOperationFactory operationFactory, WinFormsExportHelper exportHelper, BitmapRenderer scannedImageRenderer, KeyboardShortcutManager ksm, OperationProgress operationProgress)
|
||||
{
|
||||
this.changeTracker = changeTracker;
|
||||
this.operationFactory = operationFactory;
|
||||
this.exportHelper = exportHelper;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.bitmapRenderer = bitmapRenderer;
|
||||
this.ksm = ksm;
|
||||
this.operationProgress = operationProgress;
|
||||
InitializeComponent();
|
||||
@ -109,8 +109,7 @@ namespace NAPS2.WinForms
|
||||
{
|
||||
tiffViewer1.Image?.Dispose();
|
||||
tiffViewer1.Image = null;
|
||||
var newImage = await scannedImageRenderer.Render(ImageList.Images[ImageIndex]);
|
||||
tiffViewer1.Image = ((GdiImage)newImage).Bitmap;
|
||||
tiffViewer1.Image = await bitmapRenderer.Render(ImageList.Images[ImageIndex]);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
|
@ -14,7 +14,7 @@ namespace NAPS2.WinForms
|
||||
partial class ImageForm : FormBase
|
||||
{
|
||||
private readonly ChangeTracker changeTracker;
|
||||
private readonly ScannedImageRenderer scannedImageRenderer;
|
||||
private readonly BitmapRenderer bitmapRenderer;
|
||||
|
||||
protected Bitmap workingImage, workingImage2;
|
||||
private bool initComplete;
|
||||
@ -29,10 +29,10 @@ namespace NAPS2.WinForms
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected ImageForm(ChangeTracker changeTracker, ScannedImageRenderer scannedImageRenderer)
|
||||
protected ImageForm(ChangeTracker changeTracker, BitmapRenderer bitmapRenderer)
|
||||
{
|
||||
this.changeTracker = changeTracker;
|
||||
this.scannedImageRenderer = scannedImageRenderer;
|
||||
this.bitmapRenderer = bitmapRenderer;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ namespace NAPS2.WinForms
|
||||
Size = new Size(600, 600);
|
||||
|
||||
var maxDimen = Screen.AllScreens.Max(s => Math.Max(s.WorkingArea.Height, s.WorkingArea.Width));
|
||||
workingImage = ((GdiImage)await scannedImageRenderer.Render(Image, maxDimen * 2)).Bitmap;
|
||||
workingImage = await bitmapRenderer.Render(Image, maxDimen * 2);
|
||||
if (closed)
|
||||
{
|
||||
workingImage?.Dispose();
|
||||
|
Loading…
Reference in New Issue
Block a user