我想在我的xamarin窗体解决方案中使用skia图形库加载和渲染图像。当我尝试渲染图像(运行Android项目),我收到以下错误:Xamarin窗体(安卓项目)使用Skia图形库的错误渲染图像
Value cannot be null. Parameter name: codec
这里是代码:
void OnPainting(object sender, SKPaintSurfaceEventArgs e)
{
var surface = e.Surface;
var canvas = surface.Canvas;
canvas.Clear(SKColors.White);
var filename = "test.jpg";
using (var stream = new SKFileStream(filename))
using (var bitmap = SKBitmap.Decode(stream)) // the error occurs on this line
using (var paint = new SKPaint())
{
canvas.DrawBitmap(bitmap, SKRect.Create(200, 200), paint);
}
}
我找不到任何的示例代码在线xamarin。任何示例代码或链接将不胜感激。
在此先感谢
它正在工作,谢谢! – noobie