看来您可以将结果从 .ConvertToSource 转换为 BitmapSource 而不是 ImageSource。
我不是 100% 确定这如何转化为您的案例,但 LeadTools 的文档显示了这个 VB 示例:
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
我认为它应该像
BitmapSource source = RasterImageConverter.ConvertToSource(ScanImage, ConvertToSourceOptions.None) as BitmapSource;
然后您可以使用BitmapSource.CopyPixels复制 BitmapSource 像素