BitmapContext.CopyPixels on WinRT

Oct 29, 2013 at 11:35 PM
To fix a bug in WinRT, call ToArray() twice.
#if NETFX_CORE
      private unsafe void CopyPixels()
      {
         var data = writeableBitmap.PixelBuffer.ToArray();
         data = writeableBitmap.PixelBuffer.ToArray(); // *** FIX ***
         fixed (byte* srcPtr = data)
         {
            fixed (int* dstPtr = pixels)
            {
               for (var i = 0; i < length; i++)
               {
                  dstPtr[i] = (srcPtr[i * 4 + 3] << 24) | (srcPtr[i * 4 + 2] << 16) | (srcPtr[i * 4 + 1] << 8) | srcPtr[i * 4 + 0];
               }
            }
         }
      }
#endif