All products / Saraff.Twain.NET / Contents
Using a IStreamProvider for caching data of acquired image
When acquiring a large number of images or large images may need caching data of acquired image outside the RAM. To do this, you need to implement the IStreamProvider interface and place it to the IoC container. This feature is available starting with a Saraff.Twain.NET 1.0.23.558.
internal sealed class StreamProvider:Component, IStreamProvider {
public Stream GetStream() {
return new FileStream(Path.GetTempFileName(),FileMode.Create,FileAccess.ReadWrite,FileShare.Read,64*1024,FileOptions.DeleteOnClose);
}
}
using IoC = Saraff.IoC;
//...
_container = new IoC.ServiceContainer();
_container.Bind<IStreamProvider, StreamProvider>();
// ...
_twain32 = _container.CreateInstance<Twain32>();
// ...
_twain32.Acquire();
For more details see a Saraff.Twain.NET Dependency Injection Samples.