Jon*_*iga 6 c# xamarin xamarin.forms
我需要传递一个Image _thresholdedImage像字节数组这样的图像 ( )...我不知道我怎么能做到这一点。任何的想法?谢谢!
_thresholdedImage.Source = ImageSource.FromStream (() => photo.Source);
var tessResult = await _tesseractApi.SetImage(imageBytes);
Run Code Online (Sandbox Code Playgroud)
我无法在 X.Forms 中转换它,而是将以下代码与依赖项服务一起使用。谢谢你们。
public async Task<byte[]> GetBytesFromImage(string filePath)
{
ConvertImageToBW(filePath);
// Create another bitmap that will hold the results of the filter.
Bitmap thresholdedBitmap = Bitmap.CreateBitmap (BitmapFactory.DecodeFile(filePath));
thresholdedBitmap = BitmapFactory.DecodeFile (thresholdedImagePath);
byte[] bitmapData;
using (var stream = new MemoryStream())
{
thresholdedBitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
bitmapData = stream.ToArray();
}
return bitmapData;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16275 次 |
| 最近记录: |