writeablebitmap

WriteableBitmap exception when having multiple threads

落爺英雄遲暮 提交于 2019-12-25 17:39:34
问题 I create about 10 threads doing the same work - downloading image from the Internet. After the download is completed it will raise this callback function: private void DownloadImageWrapper(IRestResponse response, params object[] args) { byte[] imageData = response.RawBytes; using (Stream ms = new MemoryStream(imageData)) { WriteableBitmap wbImg = PictureDecoder.DecodeJpeg(ms); callback.DynamicInvoke(wbImg, file); }; } The exception is thrown in line with WriteableBitmap. I read that lock will

WriteableBitmapEx in console application?

Deadly 提交于 2019-12-24 08:58:50
问题 I was wondering if it's possible to use the WriteableBitmap class / the WriteableBitmapEx framework in an ordinary C# console application? I have tried to add it via nuget and also included a using statement for System.Windows.Media.Imaging, but the type is not being recognized. 回答1: The System.Windows.Media.Imaging namespace resides in the PresentationCore.dll. In your project explorer, right click on References and pick "Add Reference...", then chose PresentationCore. 来源: https:/

How can i convert WriteableBitmap to jpg or some other common format?

℡╲_俬逩灬. 提交于 2019-12-24 04:26:10
问题 I have one application that allows user to do various things like rotating and scaling an image and finally when the user clicks on save, the image should get saved on the server. Everything works out fine but the problem is since I am directly saving the WriteableBitmap after converting it to bytearray using WriteableBitmapEx, the saved image is also WriteableBitmap and so I am not able to view it using common Picture Viewer. I want my image to be saved as a JPEG. How can I do this? 回答1: Hey

Can I use Silverlight's WriteableBitmap to save non-visible parts of my UI to a bitmap?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 10:09:36
问题 Say I have some grid that you need to scroll down to see all of its lines, and I'm interested in saving some lines that are not currently visible as a bitmap. Is it feasible, or do I have to actually scroll down, "take a snapshot", and then scroll up again? This is a feasibility question, and thus I don't have code to share. 回答1: Yes. You can render any UIElement (and its children) to a writeable bitmap. When you do that you also specify a transform. That means you can display any part of the

The fastest way to convert canvas to the writeablebitmap in WPF?

喜夏-厌秋 提交于 2019-12-22 09:59:59
问题 I currently have one writeablebitmap image and canvas with drawings and I want to send the images to the peer.In order to reduce the bandwidth, I would like to convert canvas to the writeablebitmap, thus I can blit both the images to a new writeablebitmap. The problem is I cannot find a good way to convert the canvas. Therefore, I would like to ask if there is a direct way to convert the canvas to a writeablebitmap class. 回答1: This is taken from this blog post but instead of writing to a file

Why is my unsafe code block slower than my safe code?

99封情书 提交于 2019-12-22 04:56:06
问题 I am attempting to write some code that will expediently process video frames. I am receiving the frames as a System.Windows.Media.Imaging.WriteableBitmap . For testing purposes, I am just applying a simple threshold filter that will process a BGRA format image and assign each pixel to either be black or white based on the average of the BGR pixels. Here is my "Safe" version: public static void ApplyFilter(WriteableBitmap Bitmap, byte Threshold) { // Let's just make this work for this format

Handling image load exception gracefully

混江龙づ霸主 提交于 2019-12-20 06:45:23
问题 I'm loading user images using Silverlight 3. Everything works fine and I can set the file stream to a BitmapImage and it gets rendered OK. The problem is that if I try to load something that's not an image (like a .exe that's been renamed to .png) Silverlight crashes with a System.Exception that says "Catastrophic failure". The MSDN documentation unhelpfully says that it should be so there msdn link and I should listen to the ImageFailed event (which never gets fired). Am I missing something

Take screenshot Webbrowser in wp7

﹥>﹥吖頭↗ 提交于 2019-12-20 05:28:31
问题 I have a code to take screenshot in wp7. int Width = (int)LayoutRoot.RenderSize.Width; int Height = (int)LayoutRoot.RenderSize.Height; // Write the map control to a WwriteableBitmap WriteableBitmap screenshot = new WriteableBitmap(LayoutRoot, new TranslateTransform()); using (MemoryStream ms = new MemoryStream()) { // Save it to a memory stream screenshot.SaveJpeg(ms, Width, Height, 0, 100); // Take saved memory stream and put it back into an BitmapImage BitmapImage img = new BitmapImage();

WPF/WinForms/GDI interop: converting a WriteableBitmap to a System.Drawing.Image?

浪子不回头ぞ 提交于 2019-12-20 03:44:09
问题 How can I convert a WPF WriteableBitmap object to a System.Drawing.Image? My WPF client app sends bitmap data to a web service, and the web service needs to construct a System.Drawing.Image on that end. I know I can get the data of a WriteableBitmap, send the info over to the web service: // WPF side: WriteableBitmap bitmap = ...; int width = bitmap.PixelWidth; int height = bitmap.PixelHeight; int[] pixels = bitmap.Pixels; myWebService.CreateBitmap(width, height, pixels); But on the web

WriteableBitmap Memory Leak?

青春壹個敷衍的年華 提交于 2019-12-18 12:12:52
问题 i am using the code below to create a live tile, based on an UI element. It renders the uiElement on a WriteableBitmap , saves the bitmap + returns the filename. This method is run in a windows phone background task agent an i am running into memory limits. private string CreateLiveTileImage(Canvas uiElement, int width, int heigth) { var wbmp = new WriteableBitmap(width, heigth); try { wbmp.Render(uiElement, null); wbmp.Invalidate(); var tileImageName = _liveTileStoreLocation; using (var