[英]Display A Bitmap WPF From Scratch
我看了十二個示例(並嘗試了多個示例),但我找不到在Windows商店中可以輕松地在WPF中設置RenderTargetBitmap或WriteableBitmap的方法。
最終,我想直接操作一個可以以30 Hz左右的速度在屏幕上顯示的數組。
這個例子可能使我最接近:
DrawingVisual MyDrawingVisual = new DrawingVisual();
//Open its drawing context:
DrawingContext MyDC = MyDrawingVisual.RenderOpen();
// At this point you can draw
Pen p = new Pen();
p.Thickness = 5;
p.Brush = new SolidColorBrush(Colors.Green);
MyDC.DrawLine(p, new Point(1.0, 1.0), new Point(10.0, 10.0));
RenderTargetBitmap MyRenderTargetBitmap = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Default);
MyRenderTargetBitmap.Render(MyDrawingVisual);
RenderTargetBitmap rtbm = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32);
rtbm.Render(MyCanvas);
上面的示例對我來說有2個問題:它似乎沒有在屏幕上繪制任何內容,而且我認為MyDC使用DirectX(我猜它在Windows App Store中不起作用)。
編輯:
這個MS例子正是我要的!
克萊門斯就在上面。 在我看來,WPF和XAML基本上是同一回事,但事實並非如此。
我上面的方法或多或少地在黑暗中刺傷。 我將嘗試以本教程為起點。
http://msdn.microsoft.com/zh-CN/library/windows/apps/hh986965.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.