How to find out if SoftwareBitmap is fully black, when not on UI thread?

John Torjo 861 Reputation points


I have a SoftwareBitmap, and I'd like to know if it's fully black. This is due to a bug on MediaPlayer, but that's a totally different story.

I don't know how to convert it to a WritableBitmap on a non UI thread -- so, long story short, is it possible to get access to all the bytes from the software bitmap?
I know it's Bgra8, so I could simply test each 4 bytes to be 0xff, 0, 0, 0.

How do I do that?

Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. John Torjo 861 Reputation points

    I'll post this here for posterity. It IS possible

    int width = 960, height = 540;
    SoftwareBitmap soft = new SoftwareBitmap(BitmapPixelFormat.Bgra8, width, height);
    var buffer = new Windows.Storage.Streams.Buffer ( (uint)( 4 * width * height));
    DataReader dr = DataReader.FromBuffer(buffer);
    var bytes = new byte[4 * width * height];
    0 comments No comments

0 additional answers

Sort by: Most helpful