writablebitmap

Copying from BitmapSource to WritableBitmap

ⅰ亾dé卋堺 提交于 2019-12-21 04:20:49
问题 I am trying to copy a part of a BitmapSource to a WritableBitmap. This is my code so far: var bmp = image.Source as BitmapSource; var row = new WriteableBitmap(bmp.PixelWidth, bottom - top, bmp.DpiX, bmp.DpiY, bmp.Format, bmp.Palette); row.Lock(); bmp.CopyPixels(new Int32Rect(top, 0, bmp.PixelWidth, bottom - top), row.BackBuffer, row.PixelHeight * row.BackBufferStride, row.BackBufferStride); row.AddDirtyRect(new Int32Rect(0, 0, row.PixelWidth, row.PixelHeight)); row.Unlock(); I get

Image in the interface is not updated after WritableBitmap has changed

别等时光非礼了梦想. 提交于 2019-12-12 16:20:35
问题 I am trying to update the image by drawing circles every time mouse pointer is moved. The pixelBuffer is stored in map object and updated with CircleFilledWithGradientMethod() . I load the pixel buffer in to WriteableBitmap Bitmap and then try to display it by setting image source of an image element in my XAML UI to Bitmap. What happens, is that when I first move my mouse, I see the very first 2 circles drawn but then as I move the mouse, the image does not get updated. Why could that be? Is

Incorrect Byte[] from WriteableBitmap in C# UWP10

别说谁变了你拦得住时间么 提交于 2019-12-11 13:08:45
问题 I want to get the base64 string from WriteableBitmap. I believe the byte[] to be incorrect. Because: The code for creating image from base64 is working. Tested this when sending base64 string from file. However i can't see anything when i'm using my function for WriteableBitmap to base64. My attempts so far. public static string GetByteArrayFromImage(WriteableBitmap writeableBitmap) { Stream stream = writeableBitmap.PixelBuffer.AsStream(); MemoryStream memoryStream = new MemoryStream();

How to use WriteableBitmap.setpixel() efficiently in windows 10 uwp?

佐手、 提交于 2019-12-06 12:43:30
问题 I have a scenario where choosing a image file and then using BitmapDecoder converting the source to a WriteableBitmap and setting an image.source to the WriteableBitmap. Now when a user taps on the image I get the co-ordinates and then want to color the entire region surrounding that pixel with a particular color.(Like the fill option in paint). The code I've used is private void setPixelColors(int xCord, int yCord, int newColor) { Color color = bit.GetPixel(xCord, yCord); if (color.R <= 5 &&

Copying from BitmapSource to WritableBitmap

廉价感情. 提交于 2019-12-03 12:22:10
I am trying to copy a part of a BitmapSource to a WritableBitmap. This is my code so far: var bmp = image.Source as BitmapSource; var row = new WriteableBitmap(bmp.PixelWidth, bottom - top, bmp.DpiX, bmp.DpiY, bmp.Format, bmp.Palette); row.Lock(); bmp.CopyPixels(new Int32Rect(top, 0, bmp.PixelWidth, bottom - top), row.BackBuffer, row.PixelHeight * row.BackBufferStride, row.BackBufferStride); row.AddDirtyRect(new Int32Rect(0, 0, row.PixelWidth, row.PixelHeight)); row.Unlock(); I get "ArgumentException: Value does not fall within the expected range." in the line of CopyPixels . I tried swapping