I use LeadTools for scanning.
I want to convert scanning image to byte.
void twainSession_AcquirePage(object sender, TwainAcquirePageEventArgs e)
{
It seems that you can cast the result from .ConvertToSource to a BitmapSource instead of a ImageSource.
I am not 100% sure how this translate to your case but the doc from LeadTools show this VB sample:
Dim source As BitmapSource
Using raster As RasterImage = RasterImageConverter.ConvertFromSource(bitmap, ConvertFromSourceOptions.None)
Console.WriteLine("Converted to RasterImage, bits/pixel is {0} and order is {1}", raster.BitsPerPixel, raster.Order)
' Perform image processing on the raster image using LEADTOOLS
Dim cmd As New FlipCommand(False)
cmd.Run(raster)
' Convert the image back to WPF using default options
source = DirectCast(RasterImageConverter.ConvertToSource(raster, ConvertToSourceOptions.None), BitmapSource)
End Using
I think it should be like
BitmapSource source = RasterImageConverter.ConvertToSource(ScanImage, ConvertToSourceOptions.None) as BitmapSource;
Then you can copy the BitmapSource pixels with BitmapSource.CopyPixels