0

I've looked at a dozen examples (and tried more than a few) and I can't find a way to easily set up a RenderTargetBitmap or WriteableBitmap in WPF that can go on the Windows store.

Eventually I want to directly manipulate an array that I can blt on to the screen at 30 Hz or so.

This example has probably gotten me the closest:

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

The example above has 2 problems for me: it doesn't seem to draw anything to the screen, and I think MyDC uses DirectX (which I guess doesn't work with the Windows App Store).

EDIT:

This MS example is exactly what I was looking for!

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

micahhoover
  • 2,101
  • 8
  • 33
  • 53
  • Perhaps this link can help http://social.msdn.microsoft.com/forums/en-US/wpf/thread/984da366-33d3-4fd3-b4bd-4782971785f8/ – MethodMan Jan 19 '13 at 20:03
  • 1
    When this is really about a Windows Store App, it can't be WPF. You want to draw into a background bitmap and display that in a Windows Store App? – Clemens Jan 19 '13 at 22:37
  • @Clemens: From what I've heard you can't draw with GDI, DirectX, etc. in a Windows store app, so you are limited to WPF – micahhoover Jan 21 '13 at 22:04
  • 1
    It's not WPF. When you build a Windows Store App, the platform is [Windows Runtime](http://en.wikipedia.org/wiki/Windows_Runtime), or WinRT for short. It also has XAML and compares more to Silverlight than to WPF, but it is a different thing. See also [this answer](http://stackoverflow.com/a/9935294/1136211). – Clemens Jan 21 '13 at 22:07

1 Answers1

0

Clemens was right up above. To me it seems like WPF and XAML are basically the same thing, but they aren't.

My approach above was more or less stabbing around in the dark. I am going to try and use the tutorial as my starting point.

http://msdn.microsoft.com/en-us/library/windows/apps/hh986965.aspx

micahhoover
  • 2,101
  • 8
  • 33
  • 53