0

I have an Application written mostly in a PCL. When consuming this in an WPF Application I have a platformspecific codeblock that looks like this:

BitmapSource bitmapSource = BitmapSource.Create(generic.Width, generic.Height, 300, 300, PixelFormats.Bgra32, null, generic.ByteArray, generic.Stride);
        bitmapSource.Freeze();
        return bitmapSource;

where 'generic' is the PCL's platformagnostic representation of an image.

Now I want to Write an UWP Application based on this PCL, but BitmapSource.Create does not seem to exist there. What are my alternatives?

Update: I should inform that the PCL is under my control, in other Words I can change the behaviour if my approach is wrong. What I need is some way to display an image, which is generated in the PCL, pixel by pixel, in both WPF and UWP.

1 Answers1

0

WPF and Universal Windows apps use different Xaml libraries in different namespace (System.Windows vs Windows.UI.Xaml) and so cannot directly share controls.

To create a programmatically generated bitmap in a Universal app use the WriteableBitmap class rather than directly creating a BitmapSource. The WritableBitmap is a BitmapSource which provides access to its PixelBuffer for the app to manipulate the bitmap's pixels.

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
  • Thanks. I was already started to head down that road. Using WriteableBitmap and writing to its PixelBuffer rendered my images! – Julian Hanssen Sep 12 '15 at 14:21