mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-13 06:27:11 +03:00
Sample improvements
This commit is contained in:
parent
e7f83fc371
commit
2bbfc3b70e
@ -19,6 +19,7 @@ namespace NAPS2.Sdk.Samples
|
||||
// To save memory, we can store scanned images on disk after initial processing.
|
||||
// This will put files in the system temp folder by default, which can be
|
||||
// overriden by changing FileStorageManager.Current.
|
||||
// TODO: Probably this should go on StorageManager? It's weird to have to remember what's where
|
||||
ScannedImage.ConfigureBackingStorage<IFileStorage>();
|
||||
|
||||
IScanDriver driver = new WiaScanDriver();
|
||||
|
29
NAPS2.Sdk.Samples/HelloWorldSample.cs
Normal file
29
NAPS2.Sdk.Samples/HelloWorldSample.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NAPS2.Images;
|
||||
using NAPS2.Scan;
|
||||
using NAPS2.Scan.Wia;
|
||||
|
||||
namespace NAPS2.Sdk.Samples
|
||||
{
|
||||
public class HelloWorldSample
|
||||
{
|
||||
public static async Task Run()
|
||||
{
|
||||
// This is the absolute bare bones example of scanning.
|
||||
// See the other samples for more description and functionality.
|
||||
|
||||
IScanDriver driver = new WiaScanDriver();
|
||||
ScannedImageSource imageSource = driver.Scan(new ScanProfile(), new ScanParams());
|
||||
await imageSource.ForEach(scannedImage =>
|
||||
{
|
||||
using (scannedImage)
|
||||
{
|
||||
Console.WriteLine("Scanned a page!");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -48,6 +48,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FileStorageSample.cs" />
|
||||
<Compile Include="HelloWorldSample.cs" />
|
||||
<Compile Include="ScanToBitmapSample.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -55,6 +55,7 @@ namespace NAPS2.Sdk.Samples
|
||||
// ForEach allows you to asynchronously process images as they arrive.
|
||||
await imageSource.ForEach(async scannedImage =>
|
||||
{
|
||||
// Make sure ScannedImage and rendered images are disposed after use
|
||||
using (scannedImage)
|
||||
using (Bitmap bitmap = await renderer.Render(scannedImage))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user