rendertargetbitmap

RenderTargetBitmap doesn't seem to render my rectangle

十年热恋 提交于 2020-04-07 04:39:46
问题 I have the following code: LinearGradientBrush linGrBrush = new LinearGradientBrush(); linGrBrush.StartPoint = new Point(0,0); linGrBrush.EndPoint = new Point(1, 0); linGrBrush.GradientStops.Add(new GradientStop(Colors.Red, 0.0)); linGrBrush.GradientStops.Add(new GradientStop(Colors.Yellow, 0.5)); linGrBrush.GradientStops.Add(new GradientStop(Colors.White, 1.0)); Rectangle rect = new Rectangle(); rect.Width = 1000; rect.Height = 1; rect.Fill = linGrBrush; rect.Arrange(new Rect(0, 0, 1, 1000))

Error using using RenderTargetBitmap in UWP

余生长醉 提交于 2020-01-02 04:52:23
问题 I'm trying to create a bitmap image, and have the following code: RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); await renderTargetBitmap.RenderAsync(uielement); IBuffer pixels = await renderTargetBitmap.GetPixelsAsync(); . . . var pixelArray = pixels.ToArray(); In order to get a ToArray() extension, I came across this question. So I added: using System.Runtime.InteropServices.WindowsRuntime; // For ToArray To my code. However, when I run, I get the following error:

How do you capture current frame from a MediaElement in WinRT (8.1)?

纵饮孤独 提交于 2020-01-01 14:55:09
问题 I am trying to implement a screenshot functionality in a WinRT app that shows Video via a MediaElement. I have the following code, it saves a screenshot that's the size of the MediaElement but the image is empty (completely black). Tried with various types of Media files. If I do a Win Key + Vol Down on Surface RT, the screen shot includes the Media frame content, but if I use the following code, it's blackness all around :( private async Task SaveCurrentFrame() { RenderTargetBitmap

WPF RenderTargetBitmap downscaling TextRenderMode to GreyScale

痴心易碎 提交于 2020-01-01 05:42:05
问题 RenderTargetBitmap removes downgrades a RichtextBox's TextRenderingMode to GreyScale. So a captured PNG looks poor quality and doesnt match the WPF control If I use WINDOWS ALT+PRINT SCREEN, the text is captured perfectly. So how can I render the text control to the same quality as ALT+PRINT SCREEN. Any advice would seriously be appreciated All the best 回答1: You can use the same technique to render your window into the bitmap as windows using when taking a screen shot with Alt + Print Screen

Saving Windows.Media.Drawing with BmpBitmapEncoder black image - how to remove alpha?

南楼画角 提交于 2019-12-25 03:54:44
问题 I'm using SVG# (http://sharpvectors.codeplex.com/), to batch convert SVG files to other formats. The SVG images being converted are black line drawings with no background. I've little experience with WPF or the System.Windows.Media namespace, so please excuse me if this is a basic question. I'm using a modified version of the ImageSvgConverter from SVG#, which accepts a System.Windows.Media.Drawing object, which is then converted using a System.Windows.Media encoder ( BmpBitmapEncoder ,

RenderTargetBitmap Memory Leak

拥有回忆 提交于 2019-12-23 13:12:34
问题 am trying to render an image with RenderTargetBitmap every time i create an instance from RenderTargetBitmap to render image the memory increased and when am done the memory never released and this is the code : RenderTargetBitmap rtb = new RenderTargetBitmap((int)(renderWidth * dpiX / 96.0), (int)(renderHeight * dpiY / 96.0), dpiX, dpiY, PixelFormats.Pbgra32); DrawingVisual dv = new DrawingVisual(); using (DrawingContext ctx = dv.RenderOpen()) { VisualBrush vb = new VisualBrush(target); ctx

How to render a WPF Hwnd with Graphics Object

一曲冷凌霜 提交于 2019-12-22 22:29:07
问题 After the RenderTargetBitmap is much too slow. I tried a different approach. Unfortunately my attempt was not successful. Hopefully some of you guys can figure out why this code is not working. var myPopup = new Popup(); var child = new Grid() { Background = new VisualBrush(myVisual)}; myPopup.StaysOpen = false; myPopup.Child = child; myPopup.IsOpen = false; myPopup.Opened += (sender, args) => { var source = ((HwndSource)PresentationSource.FromVisual(myPopup.Child)); var image = new Bitmap

Rendering a UserControl in code rather than XAML

非 Y 不嫁゛ 提交于 2019-12-20 05:31:29
问题 I want to use RenderTargetBitmap to render a UserControl to a bitmap without having to write the XAML for it. When I do this I get a blank image, am I missing a crucial step? ValTool.Controls.VideoFisheyeOverlayControl vfoc = new Controls.VideoFisheyeOverlayControl(); vfoc.Width = (int)this.VideoContainer.ActualWidth; vfoc.Height = (int)this.VideoContainer.ActualHeight; vfoc.FieldsOfView=this.FieldsOfView; vfoc.CountLines = this.CountLines; vfoc.UpdateLayout(); vfoc.InvalidateVisual();

Any way to save an UIElement created programmatically in an image file?

柔情痞子 提交于 2019-12-19 04:14:19
问题 I'm trying to save an UIElement created programmatically in a JPG/PNG/BMP image in a Windows Phone 8.1 (C#) application. I'm using the class RenderTargetBitmap using the method RenderAsync() but it only works with UI elements created in the XAML code. When I use it on UI elements created directly in C# I have this exception: "System.ArgumentException (Value does not fall within the expected range.)" Am I doing something wrong or this class doesn't allow rendering of UIElement(s) created

Convert RenderTargetBitmap to BitmapImage

荒凉一梦 提交于 2019-12-17 18:41:12
问题 I have a RenderTargetBitmap , I need to convert it to BitmapImage . Please check the code below. RenderTargetBitmap bitMap = getRenderTargetBitmap(); Image image = new Image();// This is a Image image.Source = bitMap; In the above code I have used Image.Now I need to use a BitmapImage. How can I do this? RenderTargetBitmap bitMap = getRenderTargetBitmap(); BitmapImage image = new BitmapImage();// This is a BitmapImage // how to set bitMap as source of BitmapImage ? 回答1: Although it doesn't