Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

New Post: BitmapContext.CopyPixels on WinRT

$
0
0
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

Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>