Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. WriteableBitmap b = new WriteableBitmap(Weight*frame_size,Height*frame_size);
  2. // WriteableBitmap uses BGRA format which is 4 bytes per pixel.
  3. byte[] imageArray = new byte[b.PixelHeight * b.PixelWidth * 4];
  4. for (int i = 0; i < imageArray.Length; i += 4)
  5. {
  6. imageArray[i] = 0; // Blue
  7. imageArray[i + 1] = 0; // Green
  8. imageArray[i + 2] = 255; // Red
  9. imageArray[i + 3] = 0;
  10. }
  11. //Open a stream to copy the image contents to the WriteableBitmap's pixel buffer
  12. using (Stream stream = b.PixelBuffer.AsStream())
  13. {
  14. await stream.WriteAsync(imageArray, 0, imageArray.Length);
  15. }
  16.  
  17. SoftwareBitmap outputBitmap = SoftwareBitmap.CreateCopyFromBuffer(b.PixelBuffer,BitmapPixelFormat.Bgra8,b.PixelWidth,b.PixelHeight);
Add Comment
Please, Sign In to add comment