2013-01-19 42 views
0

我已经看了十几个示例(并尝试了一些以上),并且我找不到在WPF中可以在Windows存储上轻松设置RenderTargetBitmap或WriteableBitmap的方法。从头开始显示位图WPF

最后我想直接操作一个数组,我可以在30赫兹左右的时间在屏幕上进行操作。

这个例子可能已经得到了我最接近:

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); 

上面的例子有两个问题对我来说:它似乎并没有画任何东西到屏幕上,我认为MYDC使用DirectX(我猜测不适用于Windows App Store)。

编辑:

这个MS示例正是我一直在寻找!

http://code.msdn.microsoft.com/windowsapps/0f5d56ae-5e57-48e1-9cd9-993115b027b9/sourcecode?fileId=44756&pathId=962809525

+0

也许这链接可以帮助http://social.msdn.microsoft.com/forums/en-US/wpf/thread/984da366-33d3-4fd3-b4bd-4782971785f8/ – MethodMan

+1

当这真是关于Windows应用商店应用,它不能是WPF。你想绘制一个背景位图并在Windows Store应用程序中显示该位图? – Clemens

+0

@Clemens:从我听说你不能用GDI,DirectX等在Windows商店应用程序中绘制,所以你仅限于WPF – micahhoover

回答