我试图获取以下视图的屏幕截图。我已经得到了位图,现在需要将其转换为图像以添加到PDF生成器中。
using (var screenshot = Bitmap.CreateBitmap(200, 100,Bitmap.Config.Argb8888))
{
var canvas = new Canvas(screenshot);
rootView.Draw(canvas);
using (var screenshotOutputStream = new FileStream(screenshotPath,System.IO.FileMode.Create))
{
screenshot.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 90, screenshotOutputStream);
screenshotOutputStream.Flush();
screenshotOutputStream.Close();
}
}
我的问题是如何将
Android.Graphics.Bitmap -->screenshot
转换为 Image
?我想用来自 BitMap 的 Image 替换 url。String imageUrl = "myURL";
Image image = Image.GetInstance (new Uri (imageUrl));
document.Add(image);
Xamarin.Android
中运行。您有没有任何建议可以获取视图的屏幕截图并将其分配给图像以生成 PDF。 - casillas