我尝试使用skiasharp编辑作为流的图像,但是当我尝试将其转换为SKBitmap
时,结果变量始终为none。我正在使用Xam.Plugin.Media
来获取图像。
var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions() { SaveToAlbum = false });
if (photo != null)
{
var imageStream = photo.GetStream();
SKBitmap bitmap = SKBitmap.Decode(imageStream);
using (SKPaint textPaint = new SKPaint { TextSize = 48 })
using (SKCanvas canvas = new SKCanvas(bitmap))
{
canvas.DrawText("test", 0, 0, textPaint);
}
SKImage image = SKImage.FromBitmap(bitmap);
SKData encoded = image.Encode();
Stream stream = encoded.AsStream();
PhotoImage.Source = ImageSource.FromStream(() => { return stream; });
}
答案 0 :(得分:0)
我获得以下内容后添加此行:
var imageStream = photo.GetStream();
imageStream.seek(0, SeekOrigin.Begin);